Wrapper class for SQLite database. More...
#include <cmtkSQLite.h>
Classes | |
class | Exception |
Exception class for class-specific error reporting. More... | |
Public Types | |
typedef SQLite | Self |
This class. | |
typedef sqlite3_uint64 | PrimaryKeyType |
Primary key type for the underlying database. This is used to uniquely identify table entries. | |
typedef std::vector < std::vector< std::string > > | TableType |
Table type: matrix of strings. | |
Public Member Functions | |
SQLite (const std::string &dbPath, const bool readOnly=false) | |
Constructor: open SQLite database. | |
virtual | ~SQLite () |
Destructor: close database. | |
bool | Good () const |
Test "good" flag. | |
void | Exec (const std::string &sql) |
Execute an SQL command with no return value. | |
void | Query (const std::string &sql, Self::TableType &table) const |
Query database and return table. | |
bool | TableExists (const std::string &tableName) const |
Check if table exists. | |
void | DebugModeOn () |
Turn on debug mode. | |
void | DebugModeOff () |
Turn off debug mode. | |
Static Public Attributes | |
static const PrimaryKeyType | NOTFOUND = static_cast<PrimaryKeyType>( -1 ) |
Primary key value when object is not found: this should be guaranteed to never be used by the database as an actual primary key. | |
Protected Attributes | |
sqlite3 * | m_DB |
Database object. | |
bool | m_Good |
Flag for "good" database object. | |
bool | m_DebugMode |
Debug mode flag: if this is set, all executed SQL queries will be printed to standard error. |
Wrapper class for SQLite database.
Definition at line 52 of file cmtkSQLite.h.
typedef sqlite3_uint64 cmtk::SQLite::PrimaryKeyType |
Primary key type for the underlying database. This is used to uniquely identify table entries.
Definition at line 59 of file cmtkSQLite.h.
typedef SQLite cmtk::SQLite::Self |
typedef std::vector< std::vector< std::string > > cmtk::SQLite::TableType |
Table type: matrix of strings.
Definition at line 65 of file cmtkSQLite.h.
cmtk::SQLite::SQLite | ( | const std::string & | dbPath, |
const bool | readOnly = false |
||
) |
Constructor: open SQLite database.
dbPath | Path to the SQLite3 database file. |
readOnly | If this flag is set, the database is opened read-only. If false, the database is opened for read/write, and a non-existing database will be created. |
Definition at line 38 of file cmtkSQLite.cxx.
References NULL.
cmtk::SQLite::~SQLite | ( | ) | [virtual] |
Destructor: close database.
Definition at line 52 of file cmtkSQLite.cxx.
void cmtk::SQLite::DebugModeOff | ( | ) | [inline] |
Turn off debug mode.
Definition at line 103 of file cmtkSQLite.h.
void cmtk::SQLite::DebugModeOn | ( | ) | [inline] |
Turn on debug mode.
Definition at line 100 of file cmtkSQLite.h.
void cmtk::SQLite::Exec | ( | const std::string & | sql ) |
Execute an SQL command with no return value.
Definition at line 59 of file cmtkSQLite.cxx.
References NULL, and cmtk::StdErr.
Referenced by cmtk::ImageXformDB::ImageXformDB().
bool cmtk::SQLite::Good | ( | ) | const [inline] |
Test "good" flag.
Definition at line 85 of file cmtkSQLite.h.
void cmtk::SQLite::Query | ( | const std::string & | sql, |
Self::TableType & | table | ||
) | const |
Query database and return table.
Definition at line 98 of file cmtkSQLite.cxx.
References cmtkSQLiteQueryCallback(), NULL, and cmtk::StdErr.
bool cmtk::SQLite::TableExists | ( | const std::string & | tableName ) | const |
Check if table exists.
Definition at line 119 of file cmtkSQLite.cxx.
Referenced by cmtk::ImageXformDB::ImageXformDB().
sqlite3* cmtk::SQLite::m_DB [mutable, protected] |
bool cmtk::SQLite::m_DebugMode [protected] |
Debug mode flag: if this is set, all executed SQL queries will be printed to standard error.
Definition at line 113 of file cmtkSQLite.h.
bool cmtk::SQLite::m_Good [protected] |
Flag for "good" database object.
Definition at line 110 of file cmtkSQLite.h.
Referenced by ~SQLite().
const PrimaryKeyType cmtk::SQLite::NOTFOUND = static_cast<PrimaryKeyType>( -1 ) [static] |
Primary key value when object is not found: this should be guaranteed to never be used by the database as an actual primary key.
Definition at line 62 of file cmtkSQLite.h.