My Project
|
a single database file. More...
#include <ICDBManager.h>
Public Member Functions | |
PE_CORE_DECL void | Release () |
void | addref () |
add reference count of the asset. More... | |
bool | delref () |
decrease reference count of the asset. More... | |
int | GetRefCount () |
get the reference count | |
PE_CORE_DECL int | ExecuteSqlStringFormated (const char *sql,...) |
execute a sql script. More... | |
PE_CORE_DECL int | ExecuteSqlStringFormated (const char16_t *sql,...) |
PE_CORE_DECL int | ExecuteSqlScript (const char *sql, bool bBreakOnError=false) |
execute a sql script. More... | |
PE_CORE_DECL int | sql_prepare (const char *sql,...) |
prepare a sql statement, and return the statement object. More... | |
PE_CORE_DECL int | sql_prepare (const char16_t *sql,...) |
PE_CORE_DECL int | sql_step () |
step through the current sql statement. More... | |
PE_CORE_DECL int | sql_finalize () |
finalize the current statement if it has not been finalized. More... | |
sqlite3_stmt * | GetStatement () |
get the current statement | |
PE_CORE_DECL void | OpenDB () |
ensure that the database is opened. More... | |
PE_CORE_DECL void | CloseDB () |
ensure that the database is closed. More... | |
PE_CORE_DECL bool | IsValid () const |
return true if database is now successfully opened. More... | |
PE_CORE_DECL const string & | GetConnectionString () |
get the connection string. More... | |
sqlite3 * | GetDBHandle () |
get sqlite3 object More... | |
PE_CORE_DECL CICRecordSet * | CreateRecordSet (const char *sql,...) |
Create a managed sql statement(procedure). More... | |
PE_CORE_DECL CICRecordSet * | CreateRecordSet (const char16_t *sql,...) |
PE_CORE_DECL CICRecordSet * | CreateRecordSet1 (const char *sql) |
similar to CreateRecordSet(const char* sql,...), except that there is no limit to input length | |
PE_CORE_DECL CICRecordSet * | CreateRecordSet1 (const char16_t *sql) |
PE_CORE_DECL CICRecordSet * | CreateRecordSet () |
PE_CORE_DECL void | DeleteRecordSet (CICRecordSet *recordset) |
explicitly release a record set. More... | |
PE_CORE_DECL int64 | GetLastInsertRowID () |
PE_CORE_DECL bool | IsCreateFile () |
get if database file is opened by creating a new database file. More... | |
PE_CORE_DECL void | SetCreateFile (bool bCreateFile) |
set if database file is opened by creating a new database file. More... | |
Protected Member Functions | |
void | exec_sql16 (const char16_t *sql) |
execute the command until it is completed. More... | |
void | exec_sql (const char *sql) |
void | prepare_sql (const char16_t *sql,...) |
it is always used with exec_sql16(). More... | |
void | prepare_sql (const char *sql,...) |
void | exec_sql () |
void | exec_sql16 () |
sqlite3_stmt * | exec_sql_prepare () |
sqlite3_stmt * | exec_sql_prepare16 () |
int | exec_sql_finish () |
int | exec_sql_finish (sqlite3_stmt *stmt) |
int | exec_sql_step () |
int | exec_sql_step (sqlite3_stmt *stmt) |
void | OpenDB16 (const char16_t *dbname) |
open database file More... | |
void | OpenDB (const char *dbname) |
string | PrepareDatabaseFile (const string &filename) |
prepare the database file before open it. More... | |
void | init () |
Protected Attributes | |
sqlite3 * | m_db |
database handle | |
vector< RSpair > | m_RSpool |
a pool of sql statements created by the user. More... | |
u16string | m_name |
alias name of the db | |
string | m_filepath |
db file path | |
bool | m_isValid |
whether db is opened. More... | |
bool | m_bEncodingUTF8 |
whether the database use UTF-8 encoding; if false it will be UTF-16 unicode encoding. More... | |
bool | m_bIsCreateFile |
this is true if database file is opened by creating a new database file. More... | |
int | m_nSQLite_OpenFlags |
the opening flags for sqlite3_open_v2(). More... | |
std::u16string | m_wsql |
std::string | m_sql |
void * | m_trail |
sqlite3_stmt * | m_stmt |
ParaEngine::mutex | m_mutex |
this makes all db query thread-safe | |
int | m_refcount |
reference count of the asset. More... | |
Friends | |
class | CICMapTrace |
class | CICRoot |
class | CICGenManager |
class | CICDBManager |
a single database file.
|
inline |
add reference count of the asset.
One may later order the asset manager to remove all asset whose reference count has dropped to 0
void DBEntity::CloseDB | ( | ) |
ensure that the database is closed.
CICRecordSet * DBEntity::CreateRecordSet | ( | const char * | sql, |
... | |||
) |
Create a managed sql statement(procedure).
One can bind data field and execute it through the CICRecordSet,class
sql | sql commands |
... |
void DBEntity::DeleteRecordSet | ( | CICRecordSet * | recordset | ) |
explicitly release a record set.
recordset |
|
inline |
decrease reference count of the asset.
One may later order the asset manager to remove all asset whose reference count has dropped to 0
|
protected |
execute the command until it is completed.
*sql |
int DBEntity::ExecuteSqlScript | ( | const char * | sql, |
bool | bBreakOnError = false |
||
) |
execute a sql script.
similar to ExecuteSqlStringFormated(), except that there is no length limit to sql string.
*sql | this string is usually read from resource file |
bBreakOnError | default to false. if true, the script will break on any error; otherwise, it will continue execute the following commands even when there are previous errors. |
sqlite3_complete((const char*)m_trail)
sqlite3_complete((const char*)m_trail)
int DBEntity::ExecuteSqlStringFormated | ( | const char * | sql, |
... | |||
) |
execute a sql script.
It is equivalent to calling sql_prepare(), sql_step(), sql_finalize() in that order until all commands are completed. this function will handle error messages and will not throw exception.
sql | sql must be less than 2048 in length. |
|
inline |
get the connection string.
It is currently the file path.
|
inline |
get sqlite3 object
bool DBEntity::IsCreateFile | ( | ) |
get if database file is opened by creating a new database file.
one may want to install all tables and initial data if a database file is newly created.
|
inline |
return true if database is now successfully opened.
void DBEntity::OpenDB | ( | ) |
ensure that the database is opened.
|
protected |
open database file
dbname |
|
protected |
it is always used with exec_sql16().
e.g. prepare_sql(...); exec_sql();
*sql | |
... |
|
protected |
prepare the database file before open it.
Some database files are in archives, we will first copy them to a temporary disk location and then load the disk file instead.
filename | the file to be prepared. it can be ":memory:", a disk file or a file in a zip file. |
void DBEntity::Release | ( | ) |
because some of DBEntity is not reference counted. we shall do a (GetRefCount()==0) check
void DBEntity::SetCreateFile | ( | bool | bCreateFile | ) |
set if database file is opened by creating a new database file.
one may want to install all tables and initial data if a database file is newly created.
int DBEntity::sql_finalize | ( | ) |
finalize the current statement if it has not been finalized.
int DBEntity::sql_prepare | ( | const char * | sql, |
... | |||
) |
prepare a sql statement, and return the statement object.
CICSQLException exception may be thrown.
int DBEntity::sql_step | ( | ) |
step through the current sql statement.
|
protected |
whether the database use UTF-8 encoding; if false it will be UTF-16 unicode encoding.
|
protected |
this is true if database file is opened by creating a new database file.
|
protected |
whether db is opened.
|
protected |
the opening flags for sqlite3_open_v2().
default to SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE .
|
protected |
reference count of the asset.
Asset may be referenced by scene objects. Once the reference count drops to 0, the asset may be unloaded, due to asset garbage collection. however, the asset is not completed removed. Pointers to this object will still be valid. only resources (such as texture, mesh data, etc) are unloaded.
|
protected |
a pool of sql statements created by the user.