#include <CppSQLite3.h>
Public Member Functions | |
CppSQLite3Table () | |
CppSQLite3Table (const CppSQLite3Table &rTable) | |
CppSQLite3Table (char **paszResults, int nRows, int nCols) | |
virtual | ~CppSQLite3Table () |
CppSQLite3Table & | operator= (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 |
Definition at line 351 of file CppSQLite3.h.
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 (...) { } }
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); } }
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); }
bool CppSQLite3Table::fieldIsNull | ( | const char * | szField | ) |
Definition at line 1657 of file CppSQLite3.cpp.
References checkResults(), and fieldValue().
{ checkResults(); return (fieldValue(szField) == 0); }
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]; }
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]; }
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); }
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; } }
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)); } }
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)); } }
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)); } }
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)); } }
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); } }
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); } }
int CppSQLite3Table::numFields | ( | ) |
Definition at line 1383 of file CppSQLite3.cpp.
References checkResults(), and mnCols.
{ checkResults(); return mnCols; }
int CppSQLite3Table::numRows | ( | ) |
Definition at line 1397 of file CppSQLite3.cpp.
References checkResults(), and mnRows.
{ checkResults(); return mnRows; }
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; }
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; }
int CppSQLite3Table::mnCols [private] |
Definition at line 437 of file CppSQLite3.h.
Referenced by CppSQLite3Table(), fieldName(), fieldValue(), numFields(), and operator=().
int CppSQLite3Table::mnCurrentRow [private] |
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().
char** CppSQLite3Table::mpaszResults [private] |
Definition at line 443 of file CppSQLite3.h.
Referenced by checkResults(), CppSQLite3Table(), fieldName(), fieldValue(), finalize(), and operator=().