Nebula
Loading...
Searching...
No Matches
Db::Sqlite3Database Class Reference

#include <sqlite3database.h>

Detailed Description

SQLite3 implementation of Db::Database.

Inherits Db::Database.

Public Types

enum  TempStore { File , Memory }
 temporary storage location More...
 
- Public Types inherited from Db::Database
enum  AccessMode { ReadOnly , ReadWriteExisting , ReadWriteCreate }
 access modes More...
 

Public Member Functions

 Sqlite3Database ()
 constructor
 
virtual ~Sqlite3Database ()
 destructor
 
void SetCacheNumPages (SizeT numCachePages)
 set the SQLite3 database cache size in number of pages
 
SizeT GetCacheNumPages () const
 get SQLite3 database cache size
 
void SetTempStore (TempStore s)
 set temporary storage location
 
TempStore GetTempStore () const
 get temporary storage location
 
void SetSynchronousMode (bool b)
 synchronous mode on/off
 
bool GetSynchronousMode () const
 get synchronous mode
 
void SetBusyTimeout (int ms)
 set busy timeout in milliseconds (default is 100, 0 disabled busy handling)
 
int GetBusyTimeout () const
 get busy timeout in milliseconds
 
virtual bool Open ()
 open the database
 
virtual void Close ()
 close the database
 
virtual bool AttachDatabase (const IO::URI &uri, const Util::String &dbName)
 attach another database to the current database
 
virtual void DetachDatabase (const Util::String &dbName)
 detach an attached database
 
virtual void BeginTransaction ()
 begin a transaction on the database
 
virtual void EndTransaction ()
 end a transaction on the database
 
sqlite3 * GetSqliteHandle () const
 get the SQLite database handle
 
virtual void CopyInMemoryDatabaseToFile (const IO::URI &fileUri)
 copy in memory database to file
 
- Public Member Functions inherited from Db::Database
 Database ()
 constructor
 
virtual ~Database ()
 destructor
 
void SetURI (const IO::URI &uri)
 set the data source URI (usually filename of database file)
 
const IO::URIGetURI () const
 get the database URI
 
void SetAccessMode (AccessMode m)
 set the access mode (ReadOnly or ReadWrite)
 
AccessMode GetAccessMode () const
 get access mode
 
void SetExclusiveMode (bool b)
 enable/disable exclusive mode
 
bool GetExclusiveMode () const
 get exclusive mode
 
void SetIgnoreUnknownColumns (bool b)
 ignore unknown columns (not existing as attribute), yes/no
 
bool GetIgnoreUnknownColumns () const
 get ignore unknown columns flag
 
bool IsOpen () const
 return true if database is open
 
const Util::StringGetError () const
 get last error string
 
virtual void AddTable (const Ptr< Table > &table)
 create a new table in the database
 
virtual void DeleteTable (const Util::String &tableName)
 delete a table from the database
 
bool HasTable (const Util::String &tableName) const
 return true if a table exists by name
 
SizeT GetNumTables () const
 get number of tables in the database
 
const Ptr< Table > & GetTableByIndex (IndexT i) const
 get table by index
 
const Ptr< Table > & GetTableByName (const Util::String &tableName) const
 get table by name
 
void SetInMemoryDatabase (bool b)
 set in-memory database only
 
- Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
 
int GetRefCount () const
 get the current refcount
 
void AddRef ()
 increment refcount by one
 
void Release ()
 decrement refcount and destroy object if refcount is zero
 
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
 
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
 
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
 
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
 
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
 
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
 
const Util::StringGetClassName () const
 get the class name
 
Util::FourCC GetClassFourCC () const
 get the class FourCC code
 

Private Member Functions

 __DeclareClass (Sqlite3Database)
 
void ReadTableLayouts ()
 read table layouts from database
 
void RegisterAttributes (Ptr< Table > &attrTable)
 dynamically register attributes from special _Attributes db table
 

Private Attributes

SizeT cacheNumPages
 
TempStore tempStore
 
bool syncMode
 
int busyTimeout
 
sqlite3 * sqliteHandle
 
Ptr< CommandbeginTransactionCmd
 
Ptr< CommandendTransactionCmd
 

Additional Inherited Members

- Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
 
- Protected Member Functions inherited from Db::Database
void SetError (const Util::String &error)
 set error string
 
IndexT FindTableIndex (const Util::String &tableName) const
 find a table index by name
 
- Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)
 
- Protected Attributes inherited from Db::Database
bool isOpen
 
bool ignoreUnknownColumns
 
IO::URI uri
 
Util::String error
 
AccessMode accessMode
 
bool memoryDatabase
 
bool exclusiveMode
 
Util::Array< Ptr< Table > > tables
 

Member Enumeration Documentation

◆ TempStore

temporary storage location

Enumerator
File 
Memory 

Constructor & Destructor Documentation

◆ Sqlite3Database()

Db::Sqlite3Database::Sqlite3Database ( )

constructor

◆ ~Sqlite3Database()

Db::Sqlite3Database::~Sqlite3Database ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

Db::Sqlite3Database::__DeclareClass ( Sqlite3Database )
private

◆ AttachDatabase()

bool Db::Sqlite3Database::AttachDatabase ( const IO::URI & uri,
const Util::String & dbName )
virtual

attach another database to the current database

This attaches an external database file to this database under the given name.

See the SQLite docs for details!

Reimplemented from Db::Database.

◆ BeginTransaction()

void Db::Sqlite3Database::BeginTransaction ( )
virtual

begin a transaction on the database

Begin a database transaction.

Reimplemented from Db::Database.

◆ Close()

void Db::Sqlite3Database::Close ( )
virtual

close the database

Close the database.

Reimplemented from Db::Database.

◆ CopyInMemoryDatabaseToFile()

void Db::Sqlite3Database::CopyInMemoryDatabaseToFile ( const IO::URI & fileUri)
virtual

copy in memory database to file

Reimplemented from Db::Database.

◆ DetachDatabase()

void Db::Sqlite3Database::DetachDatabase ( const Util::String & dbName)
virtual

detach an attached database

This detaches an external database from this database.

See the SQLite docs for details!

Reimplemented from Db::Database.

◆ EndTransaction()

void Db::Sqlite3Database::EndTransaction ( )
virtual

end a transaction on the database

End the current database transaction.

Reimplemented from Db::Database.

◆ GetBusyTimeout()

int Db::Sqlite3Database::GetBusyTimeout ( ) const
inline

get busy timeout in milliseconds

◆ GetCacheNumPages()

SizeT Db::Sqlite3Database::GetCacheNumPages ( ) const
inline

get SQLite3 database cache size

◆ GetSqliteHandle()

sqlite3 * Db::Sqlite3Database::GetSqliteHandle ( ) const
inline

get the SQLite database handle

◆ GetSynchronousMode()

bool Db::Sqlite3Database::GetSynchronousMode ( ) const
inline

get synchronous mode

◆ GetTempStore()

Sqlite3Database::TempStore Db::Sqlite3Database::GetTempStore ( ) const
inline

get temporary storage location

◆ Open()

bool Db::Sqlite3Database::Open ( )
virtual

open the database

Opens an Sqlite3 database (either opens an existing, or creates a new database).

Configures the database via pragmas, reads in existing tables.

Reimplemented from Db::Database.

◆ ReadTableLayouts()

void Db::Sqlite3Database::ReadTableLayouts ( )
private

read table layouts from database

Reads in the existing database table structure, and attaches them as Table objects.

◆ RegisterAttributes()

void Db::Sqlite3Database::RegisterAttributes ( Ptr< Table > & attrTable)
private

dynamically register attributes from special _Attributes db table

Registers additional attributes defined in the database's special _Attributes table.

This enables an application to function even without knowing all attributes beforehand.

FIXME: we could also check here if the attributes in the database are type-compatibel with the already existing attributes(?).

◆ SetBusyTimeout()

void Db::Sqlite3Database::SetBusyTimeout ( int ms)
inline

set busy timeout in milliseconds (default is 100, 0 disabled busy handling)

◆ SetCacheNumPages()

void Db::Sqlite3Database::SetCacheNumPages ( SizeT numCachePages)
inline

set the SQLite3 database cache size in number of pages

◆ SetSynchronousMode()

void Db::Sqlite3Database::SetSynchronousMode ( bool b)
inline

synchronous mode on/off

◆ SetTempStore()

void Db::Sqlite3Database::SetTempStore ( TempStore s)
inline

set temporary storage location

Member Data Documentation

◆ beginTransactionCmd

Ptr<Command> Db::Sqlite3Database::beginTransactionCmd
private

◆ busyTimeout

int Db::Sqlite3Database::busyTimeout
private

◆ cacheNumPages

SizeT Db::Sqlite3Database::cacheNumPages
private

◆ endTransactionCmd

Ptr<Command> Db::Sqlite3Database::endTransactionCmd
private

◆ sqliteHandle

sqlite3* Db::Sqlite3Database::sqliteHandle
private

◆ syncMode

bool Db::Sqlite3Database::syncMode
private

◆ tempStore

TempStore Db::Sqlite3Database::tempStore
private

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