#include <CppSQLite3.h>
Public Member Functions | |
| CppSQLite3Query () | |
| CppSQLite3Query (const CppSQLite3Query &rQuery) | |
| CppSQLite3Query (sqlite3 *pDB, sqlite3_stmt *pVM, bool bEof, bool bOwnVM=true) | |
| CppSQLite3Query & | operator= (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 |
Definition at line 229 of file CppSQLite3.h.
| CppSQLite3Query::CppSQLite3Query | ( | ) |
| CppSQLite3Query::CppSQLite3Query | ( | const CppSQLite3Query & | rQuery | ) |
| CppSQLite3Query::CppSQLite3Query | ( | sqlite3 * | pDB, | |
| sqlite3_stmt * | pVM, | |||
| bool | bEof, | |||
| bool | bOwnVM = true | |||
| ) |
| CppSQLite3Query::~CppSQLite3Query | ( | ) | [virtual] |
Definition at line 671 of file CppSQLite3.cpp.
References finalize().
{
try
{
finalize();
}
catch (...)
{
}
}

| 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);
}
}

| bool CppSQLite3Query::eof | ( | ) |
Definition at line 1119 of file CppSQLite3.cpp.
References checkVM(), and mbEof.
Referenced by creaImageIO::TimestampDatabaseHandler::CheckTimestamp(), creaImageIO::SQLiteTreeHandler::DBImportTreeDescription(), creaImageIO::SQLiteTreeHandler::DBLoadChildren(), creaImageIO::SQLiteTreeHandler::DBRecursiveRemoveNode(), CppSQLite3DB::execScalar(), creaImageIO::Synchronizer::GetAttribute(), creaImageIO::SQLiteTreeHandler::GetAttribute(), creaImageIO::SQLiteTreeHandler::GetAttributes(), creaImageIO::Synchronizer::GetIgnoreList(), creaImageIO::Synchronizer::GetList(), creaImageIO::SQLiteTreeHandler::GetNumberOfChildren(), creaImageIO::SQLiteTreeHandler::GetUpLevelNodeId(), creaImageIO::TimestampDatabaseHandler::IsIndexed(), creaImageIO::TimestampDatabaseHandler::RemoveFile(), and creaImageIO::Synchronizer::UpdateAddList().


| 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);
}


| 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);
}

| 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);
}


| bool CppSQLite3Query::fieldIsNull | ( | int | nField | ) |
Definition at line 957 of file CppSQLite3.cpp.
References fieldDataType().
{
return (fieldDataType(nField) == SQLITE_NULL);
}

| 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);
}

| 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);
}


| 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);
}

| 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);
}


| 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);
}
}
}

| 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);
}

| 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);
}


| 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);
}
}


| 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);
}

| 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);
}

| 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);
}
}


| const char * CppSQLite3Query::getStringField | ( | int | nField, | |
| const char * | szNullValue = "" | |||
| ) |
Definition at line 871 of file CppSQLite3.cpp.
References fieldDataType(), and mpVM.
Referenced by creaImageIO::SQLiteTreeHandler::DBImportTreeDescription(), creaImageIO::SQLiteTreeHandler::DBLoadChildren(), creaImageIO::SQLiteTreeHandler::DBRecursiveRemoveNode(), creaImageIO::Synchronizer::GetAttribute(), creaImageIO::SQLiteTreeHandler::GetAttribute(), creaImageIO::SQLiteTreeHandler::GetAttributes(), creaImageIO::Synchronizer::GetList(), getStringField(), creaImageIO::SQLiteTreeHandler::GetUpLevelNodeId(), creaImageIO::TimestampDatabaseHandler::IsIndexed(), and creaImageIO::TimestampDatabaseHandler::RemoveFile().
{
if (fieldDataType(nField) == SQLITE_NULL)
{
return szNullValue;
}
else
{
return (const char*)sqlite3_column_text(mpVM, nField);
}
}


| 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);
}

| void CppSQLite3Query::nextRow | ( | ) |
Definition at line 1133 of file CppSQLite3.cpp.
References checkVM(), DONT_DELETE_MSG, mbEof, mpDB, and mpVM.
Referenced by creaImageIO::TimestampDatabaseHandler::CheckTimestamp(), creaImageIO::SQLiteTreeHandler::DBImportTreeDescription(), creaImageIO::SQLiteTreeHandler::DBLoadChildren(), creaImageIO::SQLiteTreeHandler::DBRecursiveRemoveNode(), creaImageIO::Synchronizer::GetAttribute(), creaImageIO::SQLiteTreeHandler::GetAttribute(), creaImageIO::SQLiteTreeHandler::GetAttributes(), creaImageIO::Synchronizer::GetIgnoreList(), creaImageIO::Synchronizer::GetList(), creaImageIO::SQLiteTreeHandler::GetNumberOfChildren(), creaImageIO::SQLiteTreeHandler::GetUpLevelNodeId(), creaImageIO::TimestampDatabaseHandler::IsIndexed(), creaImageIO::TimestampDatabaseHandler::RemoveFile(), and creaImageIO::Synchronizer::UpdateAddList().
{
checkVM();
int nRet = sqlite3_step(mpVM);
if (nRet == SQLITE_DONE)
{
// no rows
mbEof = true;
}
else if (nRet == SQLITE_ROW)
{
// more rows, nothing to do
}
else
{
nRet = sqlite3_finalize(mpVM);
mpVM = 0;
const char* szError = sqlite3_errmsg(mpDB);
throw CppSQLite3Exception(nRet,
(char*)szError,
DONT_DELETE_MSG);
}
}


| int CppSQLite3Query::numFields | ( | ) |
Definition at line 733 of file CppSQLite3.cpp.
References checkVM(), and mnCols.
Referenced by creaImageIO::TimestampDatabaseHandler::CheckTimestamp(), creaImageIO::SQLiteTreeHandler::DBImportTreeDescription(), creaImageIO::SQLiteTreeHandler::DBLoadChildren(), creaImageIO::SQLiteTreeHandler::DBRecursiveRemoveNode(), CppSQLite3DB::execScalar(), creaImageIO::SQLiteTreeHandler::GetAttribute(), creaImageIO::SQLiteTreeHandler::GetAttributes(), creaImageIO::SQLiteTreeHandler::GetNumberOfChildren(), creaImageIO::SQLiteTreeHandler::GetUpLevelNodeId(), creaImageIO::TimestampDatabaseHandler::IsIndexed(), and creaImageIO::TimestampDatabaseHandler::RemoveFile().


| 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;
}

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] |
Definition at line 341 of file CppSQLite3.h.
Referenced by CppSQLite3Query(), fieldDataType(), fieldDeclType(), fieldIndex(), fieldName(), fieldValue(), getBlobField(), numFields(), and operator=().
sqlite3* CppSQLite3Query::mpDB [private] |
Definition at line 335 of file CppSQLite3.h.
Referenced by CppSQLite3Query(), finalize(), and nextRow().
sqlite3_stmt* CppSQLite3Query::mpVM [private] |
Definition at line 337 of file CppSQLite3.h.
Referenced by checkVM(), CppSQLite3Query(), fieldDataType(), fieldDeclType(), fieldIndex(), fieldName(), fieldValue(), finalize(), getBlobField(), getFloatField(), getIntField(), getStringField(), nextRow(), and operator=().
1.7.1