SQLite::DB Class Reference

Wrapper class for the actual SQLite DB object. More...

#include <SQLiteDB.h>

Collaboration diagram for SQLite::DB:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DB (LPCTSTR pFilename=NULL)
 Default constructor - open a database file if one is received.
 DB (const DB &db)
 Copy constructor.
virtual ~DB ()
 Destructor.
bool IsOpen () const
 Tests if a database was opened and connected to this wrapper.
bool Open (LPCTSTR pFilename)
 Open a database file.
bool Close ()
 Close the current database.
bool Execute (LPCTSTR pSQL)
 Perform an SQL statement.
bool Execute (const std::tstring &sSQL)
 Perform an SQL statement.
Recordset Query (LPCTSTR pSQL)
 Perform a SELECT SQL statement.
Recordset Query (const std::tstring &sSQL)
 Perform a SELECT SQL statement.
Transaction BeginTransaction (Transaction::TransactionType eType, const std::tstring &sName=_T(""))
 Start a transaction.
Statement CreateStatement (LPCTSTR pStatement)
 Compile an SQL statement for this database (can contain parameters).
Statement CreateStatement (const std::tstring &sStatement)
 Compile an SQL statement for this database (can contain parameters).
std::tstring GetLastError ()
 Retrieve the last error for operations on the wrapped database.
sqlite_int64 GetLastInsertRowid () const
 Retrieve the ID of the last row added to the wrapped database.
bool operator!= (const DB &db) const
 Deferential operator.

Static Public Member Functions

static std::string printf (const char *pString,...)
 Helper function for creating statements in an SQL-safe way.

Protected Member Functions

 DB (RealDB *pDB)
 Constructor from an actual database object.
void AddRef () const
 Adds a reference to the actual database object.
void DecRef () const
 Deletes a reference to the actual database object (can delete the object).

Protected Attributes

RealDBm_pDB
 Pointer to the actual database object.

Detailed Description

Wrapper class for the actual SQLite DB object.

Definition at line 454 of file SQLiteDB.h.


Constructor & Destructor Documentation

SQLite::DB::DB ( LPCTSTR  pFilename = NULL  ) 

Default constructor - open a database file if one is received.

Parameters:
pFilename File to open

Definition at line 977 of file SQLiteDB.cpp.

References AddRef(), and m_pDB.

SQLite::DB::DB ( const DB db  )  [inline]

Copy constructor.

Parameters:
db The database wrapper object to copy

Definition at line 464 of file SQLiteDB.h.

References AddRef().

SQLite::DB::DB ( RealDB pDB  )  [inline, protected]

Constructor from an actual database object.

Parameters:
pDB Pointer to the actual database object

Definition at line 474 of file SQLiteDB.h.

References AddRef().


Member Function Documentation

Transaction SQLite::DB::BeginTransaction ( Transaction::TransactionType  eType,
const std::tstring &  sName = _T("") 
)

Start a transaction.

Parameters:
eType Type of transaction to start
sName The name of the transaction (can be NULL)
Returns:
A transaction object wrapping the initialized transaction

Definition at line 1033 of file SQLiteDB.cpp.

References m_pDB.

bool SQLite::DB::Close (  ) 

Close the current database.

Returns:
true if the database was closed successfully

Definition at line 1003 of file SQLiteDB.cpp.

References SQLite::RealDB::Close(), and m_pDB.

Statement SQLite::DB::CreateStatement ( const std::tstring &  sStatement  )  [inline]

Compile an SQL statement for this database (can contain parameters).

Parameters:
sStatement The statement to compile
Returns:
A statement wrapper object

Definition at line 521 of file SQLiteDB.h.

References CreateStatement().

Referenced by CreateStatement().

Statement SQLite::DB::CreateStatement ( LPCTSTR  pStatement  ) 

Compile an SQL statement for this database (can contain parameters).

Parameters:
pStatement The SQL statement to prepare for the database
Returns:
A prepared statement wrapper object

Definition at line 1042 of file SQLiteDB.cpp.

References m_pDB.

bool SQLite::DB::Execute ( const std::tstring &  sSQL  )  [inline]

Perform an SQL statement.

Parameters:
sSQL The statement to perform
Returns:
true if the statement was performed successfully, false if failed

Definition at line 503 of file SQLiteDB.h.

References Execute().

Referenced by Execute().

bool SQLite::DB::Execute ( LPCTSTR  pSQL  ) 

Perform an SQL statement.

Parameters:
pSQL SQL statement to perform
Returns:
true if the statement was performed successfully, false if failed

Definition at line 1012 of file SQLiteDB.cpp.

References SQLite::RealDB::Execute(), and m_pDB.

Referenced by SQLite::RealTransaction::Close(), SQLite::RealTransaction::Commit(), SQLite::RealTransaction::Execute(), SQLite::RealTransaction::Rollback(), and SQLite::RealTransaction::StartTransaction().

std::tstring SQLite::DB::GetLastError (  ) 

Retrieve the last error for operations on the wrapped database.

Returns:
The description of the last error that occured while performing operations on the database

Definition at line 1050 of file SQLiteDB.cpp.

References SQLite::RealDB::GetLastError(), and m_pDB.

Referenced by SQLite::RealStatement::BindParameter(), SQLite::RealTransaction::Commit(), DoLicensePage(), SQLite::RealStatement::Execute(), SQLite::RealTransaction::Execute(), SQLite::RealTransaction::Query(), SQLite::Realset::Realset(), SQLite::RealStatement::Reset(), and SQLite::RealTransaction::Rollback().

sqlite_int64 SQLite::DB::GetLastInsertRowid (  )  const

Retrieve the ID of the last row added to the wrapped database.

Returns:
The SQLite internal ID of the last row inserted into the database (0 if none)

Definition at line 1099 of file SQLiteDB.cpp.

References SQLite::RealDB::GetLastInsertRowid(), and m_pDB.

Referenced by SQLite::RealStatement::Execute().

bool SQLite::DB::IsOpen (  )  const

Tests if a database was opened and connected to this wrapper.

Returns:
true if the database was opened successfully

Definition at line 986 of file SQLiteDB.cpp.

References SQLite::RealDB::IsOpen(), and m_pDB.

Referenced by Query().

bool SQLite::DB::Open ( LPCTSTR  pFilename  ) 

Open a database file.

Parameters:
pFilename File to open
Returns:
true if the database was opened successfully

Definition at line 995 of file SQLiteDB.cpp.

References m_pDB, and SQLite::RealDB::Open().

Referenced by DoLicensePage().

bool SQLite::DB::operator!= ( const DB db  )  const [inline]

Deferential operator.

Parameters:
db Database to compare
Returns:
true if the database is the same, false if it's a different one

Definition at line 543 of file SQLiteDB.h.

References m_pDB.

std::string SQLite::DB::printf ( const char *  pString,
  ... 
) [static]

Helper function for creating statements in an SQL-safe way.

Parameters:
pString The definition string
Returns:
A prepared, SQLite-safe statement string

Definition at line 1077 of file SQLiteDB.cpp.

Recordset SQLite::DB::Query ( const std::tstring &  sSQL  )  [inline]

Perform a SELECT SQL statement.

Parameters:
sSQL The SELECT SQL statement
Returns:
The results of the query

Definition at line 511 of file SQLiteDB.h.

References Query().

Referenced by Query().

Recordset SQLite::DB::Query ( LPCTSTR  pSQL  ) 

Perform a SELECT SQL statement.

Parameters:
pSQL SQL query to perform
Returns:
The result of the query (empty result set if failed)

Definition at line 1021 of file SQLiteDB.cpp.

References SQLite::RealDB::GetSQLiteDB(), IsOpen(), and m_pDB.

Referenced by DoLicensePage(), and SQLite::RealTransaction::Query().


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

Generated on Mon Jun 18 12:52:59 2012 for Excel to PDF Converter by doxygen 1.6.1