BOSS 8.0.0
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)
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)
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 ()
 ResultHandle ()
virtual ~ResultHandle ()
 ResultHandle ()
virtual ~ResultHandle ()

Friends

class MysqlConnection

Additional Inherited Members

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

Detailed Description

Concrete implementation of ResultHandle, to accompany MysqlConnection.

Definition at line 17 of file Calibration/rdbModel/include/rdbModel/Db/MysqlResults.h.

Constructor & Destructor Documentation

◆ ~MysqlResults() [1/3]

rdbModel::MysqlResults::~MysqlResults ( )
virtual

Definition at line 17 of file MysqlResults.cxx.

17{ mysql_free_result( m_myres ); }

Referenced by ~MysqlResults().

◆ ~MysqlResults() [2/3]

virtual rdbModel::MysqlResults::~MysqlResults ( )
virtual

◆ ~MysqlResults() [3/3]

virtual rdbModel::MysqlResults::~MysqlResults ( )
virtual

Member Function Documentation

◆ getNRows() [1/3]

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

Return number of rows in results.

Implements rdbModel::ResultHandle.

Definition at line 19 of file MysqlResults.cxx.

19{ return mysql_num_rows( m_myres ); }

Referenced by getNRows().

◆ getNRows() [2/3]

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

Return number of rows in results.

Implements rdbModel::ResultHandle.

◆ getNRows() [3/3]

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

Return number of rows in results.

Implements rdbModel::ResultHandle.

◆ getRow() [1/3]

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 21 of file MysqlResults.cxx.

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

Referenced by getRow().

◆ getRow() [2/3]

virtual 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.

◆ getRow() [3/3]

virtual 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.

◆ getRowCon() [1/3]

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 57 of file MysqlResults.cxx.

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

Referenced by getRowCon().

◆ getRowCon() [2/3]

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

◆ getRowCon() [3/3]

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

◆ getRowPtrs() [1/3]

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 38 of file MysqlResults.cxx.

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

Referenced by getRowPtrs().

◆ getRowPtrs() [2/3]

virtual 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.

◆ getRowPtrs() [3/3]

virtual 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.

◆ MysqlConnection

MysqlConnection
friend

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