Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

rdbModel::MysqlResults Class Reference

#include <MysqlResults.h>

Inheritance diagram for rdbModel::MysqlResults:

rdbModel::ResultHandle rdbModel::ResultHandle List of all members.

Public Member Functions

virtual unsigned int getNRows () const
 Return number of rows in results.
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 getRow (std::vector< std::string > &fields, 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 bool getRowCon (char *par, unsigned long *treesize, unsigned int *runFrm, unsigned int *runTo, unsigned int i=0, bool clear=true)
virtual bool getRowPtrs (std::vector< std::string * > &fieldPtrs, unsigned int i=0, bool clear=true)
virtual bool getRowPtrs (std::vector< std::string * > &fieldPtrs, unsigned int i=0, bool clear=true)
virtual ~MysqlResults ()
virtual ~MysqlResults ()

Static Public Member Functions

void cleanFieldPtrs (std::vector< std::string * > &fields)
void cleanFieldPtrs (std::vector< std::string * > &fields)

Private Member Functions

 MysqlResults (MYSQL_RES *results=0)
 MysqlResults (MYSQL_RES *results=0)

Private Attributes

MYSQL_RESm_myres
MYSQL_RESm_myres

Friends

class MysqlConnection

Detailed Description

Concrete implementation of ResultHandle, to accompany MysqlConnection.


Constructor & Destructor Documentation

rdbModel::MysqlResults::~MysqlResults  )  [virtual]
 

00015                               {
00016     mysql_free_result(m_myres);
00017   }

rdbModel::MysqlResults::MysqlResults MYSQL_RES results = 0  )  [private]
 

00012                                                : m_myres(results) {
00013   }

virtual rdbModel::MysqlResults::~MysqlResults  )  [virtual]
 

rdbModel::MysqlResults::MysqlResults MYSQL_RES results = 0  )  [private]
 


Member Function Documentation

void rdbModel::ResultHandle::cleanFieldPtrs std::vector< std::string * > &  fields  )  [static, inherited]
 

void rdbModel::ResultHandle::cleanFieldPtrs std::vector< std::string * > &  fields  )  [static, inherited]
 

00007                                                                  {
00008     for (unsigned i = 0; i < fields.size(); i++) {
00009       if (fields[i] != 0) delete fields[i];
00010     }
00011     fields.resize(0);
00012   }

virtual unsigned int rdbModel::MysqlResults::getNRows  )  const [virtual]
 

Return number of rows in results.

Implements rdbModel::ResultHandle.

unsigned int rdbModel::MysqlResults::getNRows  )  const [virtual]
 

Return number of rows in results.

Implements rdbModel::ResultHandle.

00019                                             {
00020     return mysql_num_rows(m_myres);
00021   }

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.

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.

00024                                                         {
00025     mysql_data_seek(m_myres, i);
00026     MYSQL_ROW myRow = mysql_fetch_row(m_myres);
00027 
00028     unsigned nFields = mysql_num_fields(m_myres);
00029 
00030 
00031     if (clear) fields.clear();
00032 
00033     for (unsigned int iField = 0; iField < nFields; iField++) {
00034       if (myRow[iField]) fields.push_back(std::string(myRow[iField]));
00035       else fields.push_back("");
00036     }
00037 
00038     return true;
00039   }

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

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.

00063                                                                           {
00064     mysql_data_seek(m_myres, i);
00065     MYSQL_ROW myRow = mysql_fetch_row(m_myres);
00066     unsigned nFields = mysql_num_fields(m_myres);
00067     unsigned long* lengths;
00068     lengths = mysql_fetch_lengths(m_myres);
00069 
00070     for (unsigned int iField = 0; iField <nFields; iField++) {
00071       if (myRow[iField]&&iField<(nFields-4)){
00072         memcpy(par+1024000*iField,myRow[iField],lengths[iField]);
00073         treesize[iField] = lengths[iField];
00074       }
00075     }
00076 
00077     *runFrm =facilities::Util::stringToInt(myRow[nFields-4]);
00078     *runTo =facilities::Util::stringToInt(myRow[nFields-3]);
00079   std::cout<<" CalVerSft is "<<myRow[nFields-2]<<"  File name  is "<<myRow[nFields-1]<<std::endl;
00080 
00081     return true;
00082 
00083   }

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.

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.

00042                                                             {
00043 
00044     mysql_data_seek(m_myres, i);
00045     MYSQL_ROW myRow = mysql_fetch_row(m_myres);
00046 
00047     unsigned nFields = mysql_num_fields(m_myres);
00048 
00049 
00050     if (clear) fields.clear();
00051 
00052     for (unsigned int iField = 0; iField < nFields; iField++) {
00053       if (myRow[iField]) fields.push_back(new std::string(myRow[iField]));
00054       else fields.push_back(0);
00055     }
00056 
00057     return true;
00058 
00059   }


Friends And Related Function Documentation

MysqlConnection [friend]
 


Member Data Documentation

MYSQL_RES* rdbModel::MysqlResults::m_myres [private]
 

MYSQL_RES* rdbModel::MysqlResults::m_myres [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 19:22:30 2011 for BOSS6.5.5 by  doxygen 1.3.9.1