Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Attributes

cmtk::SQLite Class Reference
[cmtkIO Library]

Wrapper class for SQLite database. More...

#include <cmtkSQLite.h>

Inheritance diagram for cmtk::SQLite:
Inheritance graph
[legend]

List of all members.

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.

Detailed Description

Wrapper class for SQLite database.

Definition at line 52 of file cmtkSQLite.h.


Member Typedef Documentation

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.

This class.

Reimplemented in cmtk::ImageXformDB.

Definition at line 56 of file cmtkSQLite.h.

typedef std::vector< std::vector< std::string > > cmtk::SQLite::TableType

Table type: matrix of strings.

Definition at line 65 of file cmtkSQLite.h.


Constructor & Destructor Documentation

cmtk::SQLite::SQLite ( const std::string &  dbPath,
const bool  readOnly = false 
)

Constructor: open SQLite database.

Parameters:
dbPathPath to the SQLite3 database file.
readOnlyIf 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.

References m_DB, and m_Good.


Member Function Documentation

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().


Member Data Documentation

sqlite3* cmtk::SQLite::m_DB [mutable, protected]

Database object.

Definition at line 107 of file cmtkSQLite.h.

Referenced by ~SQLite().

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.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines