BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
rdbModel::MysqlResults Class Reference

#include <MysqlResults.h>

+ Inheritance diagram for rdbModel::MysqlResults:

Public Member Functions

virtual ~MysqlResults ()
 
virtual unsigned int getNRows () const
 Return number of rows in results.
 
virtual bool getRow (std::vector< std::string > &fields, unsigned int i=0, bool clear=true)
 
virtual bool getRowPtrs (std::vector< std::string * > &fieldPtrs, unsigned int i=0, bool clear=true)
 
virtual bool getRowCon (char *par, unsigned long *treesize, unsigned int *runFrm, unsigned int *runTo, unsigned int i=0, bool clear=true)
 
- Public Member Functions inherited from rdbModel::ResultHandle
 ResultHandle ()
 
virtual ~ResultHandle ()
 
virtual unsigned int getNRows () const =0
 Return number of rows in results.
 
virtual bool getRow (std::vector< std::string > &fields, unsigned int i=0, bool clear=true)=0
 
virtual bool getRowCon (char *par, unsigned long *treesize, unsigned int *runFrm, unsigned int *runTo, unsigned int i=0, bool clear=true)=0
 
virtual bool getRowPtrs (std::vector< std::string * > &fields, unsigned int i=0, bool clear=true)=0
 

Friends

class MysqlConnection
 

Additional Inherited Members

- Static Public Member Functions inherited from rdbModel::ResultHandle
static void cleanFieldPtrs (std::vector< std::string * > &fields)
 

Detailed Description

Concrete implementation of ResultHandle, to accompany MysqlConnection.

Definition at line 16 of file MysqlResults.h.

Constructor & Destructor Documentation

◆ ~MysqlResults()

rdbModel::MysqlResults::~MysqlResults ( )
virtual

Definition at line 17 of file MysqlResults.cxx.

17 {
18 mysql_free_result(m_myres);
19 }

Member Function Documentation

◆ getNRows()

unsigned int rdbModel::MysqlResults::getNRows ( ) const
virtual

Return number of rows in results.

Implements rdbModel::ResultHandle.

Definition at line 21 of file MysqlResults.cxx.

21 {
22 return mysql_num_rows(m_myres);
23 }

◆ getRow()

bool rdbModel::MysqlResults::getRow ( std::vector< std::string > &  fields,
unsigned int  i = 0,
bool  clear = true 
)
virtual

Get array of field values for ith row of result set

Implements rdbModel::ResultHandle.

Definition at line 25 of file MysqlResults.cxx.

26 {
27 mysql_data_seek(m_myres, i);
28 MYSQL_ROW myRow = mysql_fetch_row(m_myres);
29
30 unsigned nFields = mysql_num_fields(m_myres);
31
32
33 if (clear) fields.clear();
34
35 for (unsigned int iField = 0; iField < nFields; iField++) {
36 if (myRow[iField]) fields.push_back(std::string(myRow[iField]));
37 else fields.push_back("");
38 }
39
40 return true;
41 }

◆ getRowCon()

bool rdbModel::MysqlResults::getRowCon ( char *  par,
unsigned long *  treesize,
unsigned int *  runFrm,
unsigned int *  runTo,
unsigned int  i = 0,
bool  clear = true 
)
virtual

Implements rdbModel::ResultHandle.

Definition at line 64 of file MysqlResults.cxx.

65 {
66 mysql_data_seek(m_myres, i);
67 MYSQL_ROW myRow = mysql_fetch_row(m_myres);
68 unsigned nFields = mysql_num_fields(m_myres);
69 unsigned long* lengths;
70 lengths = mysql_fetch_lengths(m_myres);
71
72 for (unsigned int iField = 0; iField <nFields; iField++) {
73 if (myRow[iField]&&iField<(nFields-4)){
74 memcpy(par+1024000*iField,myRow[iField],lengths[iField]);
75 treesize[iField] = lengths[iField];
76 }
77 }
78
79 *runFrm =facilities::Util::stringToInt(myRow[nFields-4]);
80 *runTo =facilities::Util::stringToInt(myRow[nFields-3]);
81 std::cout<<" CalVerSft is "<<myRow[nFields-2]<<" File name is "<<myRow[nFields-1]<<std::endl;
82
83 return true;
84
85 }
static int stringToInt(const std::string &InStr)

◆ getRowPtrs()

bool rdbModel::MysqlResults::getRowPtrs ( std::vector< std::string * > &  fieldPtrs,
unsigned int  i = 0,
bool  clear = true 
)
virtual

Get array of field values for ith row of result set. If a field value is NULL, return a zero ptr for that element of the array.

--> It is the responsibility of the caller to delete the strings containing the field values. See service cleanFieldPtrs in base class ResultHandle.

Implements rdbModel::ResultHandle.

Definition at line 43 of file MysqlResults.cxx.

44 {
45
46 mysql_data_seek(m_myres, i);
47 MYSQL_ROW myRow = mysql_fetch_row(m_myres);
48
49 unsigned nFields = mysql_num_fields(m_myres);
50
51
52 if (clear) fields.clear();
53
54 for (unsigned int iField = 0; iField < nFields; iField++) {
55 if (myRow[iField]) fields.push_back(new std::string(myRow[iField]));
56 else fields.push_back(0);
57 }
58
59 return true;
60
61 }

Friends And Related Function Documentation

◆ MysqlConnection

friend class MysqlConnection
friend

Definition at line 17 of file MysqlResults.h.


The documentation for this class was generated from the following files: