Public Member Functions | Private Member Functions | Private Attributes

CppSQLite3Table Class Reference

#include <CppSQLite3.h>

List of all members.

Public Member Functions

 CppSQLite3Table ()
 CppSQLite3Table (const CppSQLite3Table &rTable)
 CppSQLite3Table (char **paszResults, int nRows, int nCols)
virtual ~CppSQLite3Table ()
CppSQLite3Tableoperator= (const CppSQLite3Table &rTable)
int numFields ()
int numRows ()
const char * fieldName (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="")
bool fieldIsNull (int nField)
bool fieldIsNull (const char *szField)
void setRow (int nRow)
void finalize ()

Private Member Functions

void checkResults ()

Private Attributes

int mnCols
int mnRows
int mnCurrentRow
char ** mpaszResults

Detailed Description

Definition at line 351 of file CppSQLite3.h.


Constructor & Destructor Documentation

CppSQLite3Table::CppSQLite3Table (  ) 

Definition at line 1243 of file CppSQLite3.cpp.

References mnCols, mnCurrentRow, mnRows, and mpaszResults.

{

        mpaszResults = 0;

        mnRows = 0;

        mnCols = 0;

        mnCurrentRow = 0;

}

CppSQLite3Table::CppSQLite3Table ( const CppSQLite3Table rTable  ) 

Definition at line 1261 of file CppSQLite3.cpp.

References mnCols, mnCurrentRow, mnRows, and mpaszResults.

{

        mpaszResults = rTable.mpaszResults;

        // Only one object can own the results

        const_cast<CppSQLite3Table&>(rTable).mpaszResults = 0;

        mnRows = rTable.mnRows;

        mnCols = rTable.mnCols;

        mnCurrentRow = rTable.mnCurrentRow;

}

CppSQLite3Table::CppSQLite3Table ( char **  paszResults,
int  nRows,
int  nCols 
)

Definition at line 1283 of file CppSQLite3.cpp.

References mnCols, mnCurrentRow, mnRows, and mpaszResults.

{

        mpaszResults = paszResults;

        mnRows = nRows;

        mnCols = nCols;

        mnCurrentRow = 0;

}

CppSQLite3Table::~CppSQLite3Table (  )  [virtual]

Definition at line 1301 of file CppSQLite3.cpp.

References finalize().

{

        try

        {

                finalize();

        }

        catch (...)

        {

        }

}

Here is the call graph for this function:


Member Function Documentation

void CppSQLite3Table::checkResults (  )  [private]

Definition at line 1731 of file CppSQLite3.cpp.

References CPPSQLITE_ERROR, DONT_DELETE_MSG, and mpaszResults.

Referenced by fieldIsNull(), fieldName(), fieldValue(), numFields(), numRows(), and setRow().

{

        if (mpaszResults == 0)

        {

                throw CppSQLite3Exception(CPPSQLITE_ERROR,

                                                                "Null Results pointer",

                                                                DONT_DELETE_MSG);

        }

}

Here is the caller graph for this function:

bool CppSQLite3Table::fieldIsNull ( int  nField  ) 

Definition at line 1643 of file CppSQLite3.cpp.

References checkResults(), and fieldValue().

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

{

        checkResults();

        return (fieldValue(nField) == 0);

}

Here is the call graph for this function:

Here is the caller graph for this function:

bool CppSQLite3Table::fieldIsNull ( const char *  szField  ) 

Definition at line 1657 of file CppSQLite3.cpp.

References checkResults(), and fieldValue().

{

        checkResults();

        return (fieldValue(szField) == 0);

}

Here is the call graph for this function:

const char * CppSQLite3Table::fieldName ( int  nCol  ) 

Definition at line 1671 of file CppSQLite3.cpp.

References checkResults(), CPPSQLITE_ERROR, DONT_DELETE_MSG, mnCols, and mpaszResults.

{

        checkResults();



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

        {

                throw CppSQLite3Exception(CPPSQLITE_ERROR,

                                                                "Invalid field index requested",

                                                                DONT_DELETE_MSG);

        }



        return mpaszResults[nCol];

}

Here is the call graph for this function:

const char * CppSQLite3Table::fieldValue ( int  nField  ) 

Definition at line 1411 of file CppSQLite3.cpp.

References checkResults(), CPPSQLITE_ERROR, DONT_DELETE_MSG, mnCols, mnCurrentRow, and mpaszResults.

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

{

        checkResults();



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

        {

                throw CppSQLite3Exception(CPPSQLITE_ERROR,

                                                                "Invalid field index requested",

                                                                DONT_DELETE_MSG);

        }



        int nIndex = (mnCurrentRow*mnCols) + mnCols + nField;

        return mpaszResults[nIndex];

}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1443 of file CppSQLite3.cpp.

References checkResults(), CPPSQLITE_ERROR, DONT_DELETE_MSG, mnCols, mnCurrentRow, and mpaszResults.

{

        checkResults();



        if (szField)

        {

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

                {

                        if (strcmp(szField, mpaszResults[nField]) == 0)

                        {

                                int nIndex = (mnCurrentRow*mnCols) + mnCols + nField;

                                return mpaszResults[nIndex];

                        }

                }

        }



        throw CppSQLite3Exception(CPPSQLITE_ERROR,

                                                        "Invalid field name requested",

                                                        DONT_DELETE_MSG);

}

Here is the call graph for this function:

void CppSQLite3Table::finalize (  ) 

Definition at line 1363 of file CppSQLite3.cpp.

References mpaszResults.

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

{

        if (mpaszResults)

        {

                sqlite3_free_table(mpaszResults);

                mpaszResults = 0;

        }

}

Here is the caller graph for this function:

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

Definition at line 1539 of file CppSQLite3.cpp.

References fieldIsNull(), and fieldValue().

{

        if (fieldIsNull(nField))

        {

                return fNullValue;

        }

        else

        {

                return atof(fieldValue(nField));

        }

}

Here is the call graph for this function:

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

Definition at line 1565 of file CppSQLite3.cpp.

References fieldIsNull(), and fieldValue().

{

        if (fieldIsNull(szField))

        {

                return fNullValue;

        }

        else

        {

                return atof(fieldValue(szField));

        }

}

Here is the call graph for this function:

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

Definition at line 1513 of file CppSQLite3.cpp.

References fieldIsNull(), and fieldValue().

{

        if (fieldIsNull(szField))

        {

                return nNullValue;

        }

        else

        {

                return atoi(fieldValue(szField));

        }

}

Here is the call graph for this function:

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

Definition at line 1487 of file CppSQLite3.cpp.

References fieldIsNull(), and fieldValue().

{

        if (fieldIsNull(nField))

        {

                return nNullValue;

        }

        else

        {

                return atoi(fieldValue(nField));

        }

}

Here is the call graph for this function:

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

Definition at line 1591 of file CppSQLite3.cpp.

References fieldIsNull(), and fieldValue().

{

        if (fieldIsNull(nField))

        {

                return szNullValue;

        }

        else

        {

                return fieldValue(nField);

        }

}

Here is the call graph for this function:

const char * CppSQLite3Table::getStringField ( const char *  szField,
const char *  szNullValue = "" 
)

Definition at line 1617 of file CppSQLite3.cpp.

References fieldIsNull(), and fieldValue().

{

        if (fieldIsNull(szField))

        {

                return szNullValue;

        }

        else

        {

                return fieldValue(szField);

        }

}

Here is the call graph for this function:

int CppSQLite3Table::numFields (  ) 

Definition at line 1383 of file CppSQLite3.cpp.

References checkResults(), and mnCols.

{

        checkResults();

        return mnCols;

}

Here is the call graph for this function:

int CppSQLite3Table::numRows (  ) 

Definition at line 1397 of file CppSQLite3.cpp.

References checkResults(), and mnRows.

{

        checkResults();

        return mnRows;

}

Here is the call graph for this function:

CppSQLite3Table & CppSQLite3Table::operator= ( const CppSQLite3Table rTable  ) 

Definition at line 1325 of file CppSQLite3.cpp.

References finalize(), mnCols, mnCurrentRow, mnRows, and mpaszResults.

{

        try

        {

                finalize();

        }

        catch (...)

        {

        }

        mpaszResults = rTable.mpaszResults;

        // Only one object can own the results

        const_cast<CppSQLite3Table&>(rTable).mpaszResults = 0;

        mnRows = rTable.mnRows;

        mnCols = rTable.mnCols;

        mnCurrentRow = rTable.mnCurrentRow;

        return *this;

}

Here is the call graph for this function:

void CppSQLite3Table::setRow ( int  nRow  ) 

Definition at line 1701 of file CppSQLite3.cpp.

References checkResults(), CPPSQLITE_ERROR, DONT_DELETE_MSG, mnCurrentRow, and mnRows.

{

        checkResults();



        if (nRow < 0 || nRow > mnRows-1)

        {

                throw CppSQLite3Exception(CPPSQLITE_ERROR,

                                                                "Invalid row index requested",

                                                                DONT_DELETE_MSG);

        }



        mnCurrentRow = nRow;

}

Here is the call graph for this function:


Member Data Documentation

int CppSQLite3Table::mnCols [private]

Definition at line 437 of file CppSQLite3.h.

Referenced by CppSQLite3Table(), fieldName(), fieldValue(), numFields(), and operator=().

Definition at line 441 of file CppSQLite3.h.

Referenced by CppSQLite3Table(), fieldValue(), operator=(), and setRow().

int CppSQLite3Table::mnRows [private]

Definition at line 439 of file CppSQLite3.h.

Referenced by CppSQLite3Table(), numRows(), operator=(), and setRow().

Definition at line 443 of file CppSQLite3.h.

Referenced by checkResults(), CppSQLite3Table(), fieldName(), fieldValue(), finalize(), and operator=().


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