Public Member Functions | Private Member Functions | Private Attributes

CppSQLite3Query Class Reference

#include <CppSQLite3.h>

List of all members.

Public Member Functions

 CppSQLite3Query ()
 CppSQLite3Query (const CppSQLite3Query &rQuery)
 CppSQLite3Query (sqlite3 *pDB, sqlite3_stmt *pVM, bool bEof, bool bOwnVM=true)
CppSQLite3Queryoperator= (const CppSQLite3Query &rQuery)
virtual ~CppSQLite3Query ()
int numFields ()
int fieldIndex (const char *szField)
const char * fieldName (int nCol)
const char * fieldDeclType (int nCol)
int fieldDataType (int nCol)
const char * fieldValue (int nField)
const char * fieldValue (const char *szField)
int getIntField (int nField, int nNullValue=0)
int getIntField (const char *szField, int nNullValue=0)
double getFloatField (int nField, double fNullValue=0.0)
double getFloatField (const char *szField, double fNullValue=0.0)
const char * getStringField (int nField, const char *szNullValue="")
const char * getStringField (const char *szField, const char *szNullValue="")
const unsigned char * getBlobField (int nField, int &nLen)
const unsigned char * getBlobField (const char *szField, int &nLen)
bool fieldIsNull (int nField)
bool fieldIsNull (const char *szField)
bool eof ()
void nextRow ()
void finalize ()

Private Member Functions

void checkVM ()

Private Attributes

sqlite3 * mpDB
sqlite3_stmt * mpVM
bool mbEof
int mnCols
bool mbOwnVM

Detailed Description

Definition at line 229 of file CppSQLite3.h.


Constructor & Destructor Documentation

CppSQLite3Query::CppSQLite3Query (  ) 

Definition at line 605 of file CppSQLite3.cpp.

References mbEof, mbOwnVM, mnCols, and mpVM.

{

        mpVM = 0;

        mbEof = true;

        mnCols = 0;

        mbOwnVM = false;

}

CppSQLite3Query::CppSQLite3Query ( const CppSQLite3Query rQuery  ) 

Definition at line 623 of file CppSQLite3.cpp.

References mbEof, mbOwnVM, mnCols, and mpVM.

{

        mpVM = rQuery.mpVM;

        // Only one object can own the VM

        const_cast<CppSQLite3Query&>(rQuery).mpVM = 0;

        mbEof = rQuery.mbEof;

        mnCols = rQuery.mnCols;

        mbOwnVM = rQuery.mbOwnVM;

}

CppSQLite3Query::CppSQLite3Query ( sqlite3 *  pDB,
sqlite3_stmt *  pVM,
bool  bEof,
bool  bOwnVM = true 
)

Definition at line 645 of file CppSQLite3.cpp.

References mbEof, mbOwnVM, mnCols, mpDB, and mpVM.

{

        mpDB = pDB;

        mpVM = pVM;

        mbEof = bEof;

        mnCols = sqlite3_column_count(mpVM);

        mbOwnVM = bOwnVM;

}

CppSQLite3Query::~CppSQLite3Query (  )  [virtual]

Definition at line 671 of file CppSQLite3.cpp.

References finalize().

{

        try

        {

                finalize();

        }

        catch (...)

        {

        }

}

Here is the call graph for this function:


Member Function Documentation

void CppSQLite3Query::checkVM (  )  [private]

Definition at line 1217 of file CppSQLite3.cpp.

References CPPSQLITE_ERROR, DONT_DELETE_MSG, and mpVM.

Referenced by eof(), fieldDataType(), fieldDeclType(), fieldIndex(), fieldName(), fieldValue(), getBlobField(), nextRow(), and numFields().

{

        if (mpVM == 0)

        {

                throw CppSQLite3Exception(CPPSQLITE_ERROR,

                                                                "Null Virtual Machine pointer",

                                                                DONT_DELETE_MSG);

        }

}

Here is the caller graph for this function:

bool CppSQLite3Query::eof (  ) 
int CppSQLite3Query::fieldDataType ( int  nCol  ) 

Definition at line 1089 of file CppSQLite3.cpp.

References checkVM(), CPPSQLITE_ERROR, DONT_DELETE_MSG, mnCols, and mpVM.

Referenced by fieldIsNull(), getFloatField(), getIntField(), and getStringField().

{

        checkVM();



        if (nCol < 0 || nCol > mnCols-1)

        {

                throw CppSQLite3Exception(CPPSQLITE_ERROR,

                                                                "Invalid field index requested",

                                                                DONT_DELETE_MSG);

        }



        return sqlite3_column_type(mpVM, nCol);

}

Here is the call graph for this function:

Here is the caller graph for this function:

const char * CppSQLite3Query::fieldDeclType ( int  nCol  ) 

Definition at line 1059 of file CppSQLite3.cpp.

References checkVM(), CPPSQLITE_ERROR, DONT_DELETE_MSG, mnCols, and mpVM.

{

        checkVM();



        if (nCol < 0 || nCol > mnCols-1)

        {

                throw CppSQLite3Exception(CPPSQLITE_ERROR,

                                                                "Invalid field index requested",

                                                                DONT_DELETE_MSG);

        }



        return sqlite3_column_decltype(mpVM, nCol);

}

Here is the call graph for this function:

int CppSQLite3Query::fieldIndex ( const char *  szField  ) 

Definition at line 983 of file CppSQLite3.cpp.

References checkVM(), CPPSQLITE_ERROR, DONT_DELETE_MSG, mnCols, and mpVM.

Referenced by fieldIsNull(), fieldValue(), getBlobField(), getFloatField(), getIntField(), and getStringField().

{

        checkVM();



        if (szField)

        {

                for (int nField = 0; nField < mnCols; nField++)

                {

                        const char* szTemp = sqlite3_column_name(mpVM, nField);



                        if (strcmp(szField, szTemp) == 0)

                        {

                                return nField;

                        }

                }

        }



        throw CppSQLite3Exception(CPPSQLITE_ERROR,

                                                        "Invalid field name requested",

                                                        DONT_DELETE_MSG);

}

Here is the call graph for this function:

Here is the caller graph for this function:

bool CppSQLite3Query::fieldIsNull ( int  nField  ) 

Definition at line 957 of file CppSQLite3.cpp.

References fieldDataType().

{

        return (fieldDataType(nField) == SQLITE_NULL);

}

Here is the call graph for this function:

bool CppSQLite3Query::fieldIsNull ( const char *  szField  ) 

Definition at line 969 of file CppSQLite3.cpp.

References fieldDataType(), and fieldIndex().

{

        int nField = fieldIndex(szField);

        return (fieldDataType(nField) == SQLITE_NULL);

}

Here is the call graph for this function:

const char * CppSQLite3Query::fieldName ( int  nCol  ) 

Definition at line 1029 of file CppSQLite3.cpp.

References checkVM(), CPPSQLITE_ERROR, DONT_DELETE_MSG, mnCols, and mpVM.

Referenced by creaImageIO::SQLiteTreeHandler::DBImportTreeDescription(), and creaImageIO::SQLiteTreeHandler::DBLoadChildren().

{

        checkVM();



        if (nCol < 0 || nCol > mnCols-1)

        {

                throw CppSQLite3Exception(CPPSQLITE_ERROR,

                                                                "Invalid field index requested",

                                                                DONT_DELETE_MSG);

        }



        return sqlite3_column_name(mpVM, nCol);

}

Here is the call graph for this function:

Here is the caller graph for this function:

const char * CppSQLite3Query::fieldValue ( const char *  szField  ) 

Definition at line 777 of file CppSQLite3.cpp.

References fieldIndex(), and mpVM.

{

        int nField = fieldIndex(szField);

        return (const char*)sqlite3_column_text(mpVM, nField);

}

Here is the call graph for this function:

const char * CppSQLite3Query::fieldValue ( int  nField  ) 

Definition at line 747 of file CppSQLite3.cpp.

References checkVM(), CPPSQLITE_ERROR, DONT_DELETE_MSG, mnCols, and mpVM.

Referenced by CppSQLite3DB::execScalar().

{

        checkVM();



        if (nField < 0 || nField > mnCols-1)

        {

                throw CppSQLite3Exception(CPPSQLITE_ERROR,

                                                                "Invalid field index requested",

                                                                DONT_DELETE_MSG);

        }



        return (const char*)sqlite3_column_text(mpVM, nField);

}

Here is the call graph for this function:

Here is the caller graph for this function:

void CppSQLite3Query::finalize (  ) 

Definition at line 1187 of file CppSQLite3.cpp.

References DONT_DELETE_MSG, mbOwnVM, mpDB, and mpVM.

Referenced by operator=(), and ~CppSQLite3Query().

{

        if (mpVM && mbOwnVM)

        {

                int nRet = sqlite3_finalize(mpVM);

                mpVM = 0;

                if (nRet != SQLITE_OK)

                {

                        const char* szError = sqlite3_errmsg(mpDB);

                        throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG);

                }

        }

}

Here is the caller graph for this function:

const unsigned char * CppSQLite3Query::getBlobField ( const char *  szField,
int &  nLen 
)

Definition at line 943 of file CppSQLite3.cpp.

References fieldIndex(), and getBlobField().

{

        int nField = fieldIndex(szField);

        return getBlobField(nField, nLen);

}

Here is the call graph for this function:

const unsigned char * CppSQLite3Query::getBlobField ( int  nField,
int &  nLen 
)

Definition at line 911 of file CppSQLite3.cpp.

References checkVM(), CPPSQLITE_ERROR, DONT_DELETE_MSG, mnCols, and mpVM.

Referenced by getBlobField().

{

        checkVM();



        if (nField < 0 || nField > mnCols-1)

        {

                throw CppSQLite3Exception(CPPSQLITE_ERROR,

                                                                "Invalid field index requested",

                                                                DONT_DELETE_MSG);

        }



        nLen = sqlite3_column_bytes(mpVM, nField);

        return (const unsigned char*)sqlite3_column_blob(mpVM, nField);

}

Here is the call graph for this function:

Here is the caller graph for this function:

double CppSQLite3Query::getFloatField ( int  nField,
double  fNullValue = 0.0 
)

Definition at line 831 of file CppSQLite3.cpp.

References fieldDataType(), and mpVM.

Referenced by creaImageIO::TimestampDatabaseHandler::CheckTimestamp(), and getFloatField().

{

        if (fieldDataType(nField) == SQLITE_NULL)

        {

                return fNullValue;

        }

        else

        {

                return sqlite3_column_double(mpVM, nField);

        }

}

Here is the call graph for this function:

Here is the caller graph for this function:

double CppSQLite3Query::getFloatField ( const char *  szField,
double  fNullValue = 0.0 
)

Definition at line 857 of file CppSQLite3.cpp.

References fieldIndex(), and getFloatField().

{

        int nField = fieldIndex(szField);

        return getFloatField(nField, fNullValue);

}

Here is the call graph for this function:

int CppSQLite3Query::getIntField ( const char *  szField,
int  nNullValue = 0 
)

Definition at line 817 of file CppSQLite3.cpp.

References fieldIndex(), and getIntField().

{

        int nField = fieldIndex(szField);

        return getIntField(nField, nNullValue);

}

Here is the call graph for this function:

int CppSQLite3Query::getIntField ( int  nField,
int  nNullValue = 0 
)

Definition at line 791 of file CppSQLite3.cpp.

References fieldDataType(), and mpVM.

Referenced by creaImageIO::SQLiteTreeHandler::DBImportTreeDescription(), getIntField(), and creaImageIO::SQLiteTreeHandler::GetNumberOfChildren().

{

        if (fieldDataType(nField) == SQLITE_NULL)

        {

                return nNullValue;

        }

        else

        {

                return sqlite3_column_int(mpVM, nField);

        }

}

Here is the call graph for this function:

Here is the caller graph for this function:

const char * CppSQLite3Query::getStringField ( int  nField,
const char *  szNullValue = "" 
)
const char * CppSQLite3Query::getStringField ( const char *  szField,
const char *  szNullValue = "" 
)

Definition at line 897 of file CppSQLite3.cpp.

References fieldIndex(), and getStringField().

{

        int nField = fieldIndex(szField);

        return getStringField(nField, szNullValue);

}

Here is the call graph for this function:

void CppSQLite3Query::nextRow (  ) 
int CppSQLite3Query::numFields (  ) 
CppSQLite3Query & CppSQLite3Query::operator= ( const CppSQLite3Query rQuery  ) 

Definition at line 695 of file CppSQLite3.cpp.

References finalize(), mbEof, mbOwnVM, mnCols, and mpVM.

{

        try

        {

                finalize();

        }

        catch (...)

        {

        }

        mpVM = rQuery.mpVM;

        // Only one object can own the VM

        const_cast<CppSQLite3Query&>(rQuery).mpVM = 0;

        mbEof = rQuery.mbEof;

        mnCols = rQuery.mnCols;

        mbOwnVM = rQuery.mbOwnVM;

        return *this;

}

Here is the call graph for this function:


Member Data Documentation

bool CppSQLite3Query::mbEof [private]

Definition at line 339 of file CppSQLite3.h.

Referenced by CppSQLite3Query(), eof(), nextRow(), and operator=().

bool CppSQLite3Query::mbOwnVM [private]

Definition at line 343 of file CppSQLite3.h.

Referenced by CppSQLite3Query(), finalize(), and operator=().

int CppSQLite3Query::mnCols [private]
sqlite3* CppSQLite3Query::mpDB [private]

Definition at line 335 of file CppSQLite3.h.

Referenced by CppSQLite3Query(), finalize(), and nextRow().

sqlite3_stmt* CppSQLite3Query::mpVM [private]

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