Zserio C++ runtime library
1.1.0
Built for Zserio 2.15.0
|
#include <SqliteConnection.h>
Public Types | |
enum | ConnectionType { INTERNAL_CONNECTION , EXTERNAL_CONNECTION } |
Public Member Functions | |
SqliteConnection (sqlite3 *connection=nullptr, ConnectionType connectionType=INTERNAL_CONNECTION) | |
~SqliteConnection () | |
void | reset (sqlite3 *connection=nullptr, ConnectionType connectionType=INTERNAL_CONNECTION) |
ConnectionType | getConnectionType () const |
sqlite3 * | getConnection () |
void | executeUpdate (StringView sqlQuery) |
sqlite3_stmt * | prepareStatement (StringView sqlQuery) |
bool | startTransaction () |
void | endTransaction (bool wasTransactionStarted) |
SqliteConnection (const SqliteConnection &)=delete | |
SqliteConnection & | operator= (const SqliteConnection &)=delete |
SqliteConnection (SqliteConnection &&)=delete | |
SqliteConnection & | operator= (SqliteConnection &&)=delete |
Helper class to keep sqlite3 connection and ensure its safe destruction.
The class also provides simple interface to execute SQLite queries.
Definition at line 20 of file SqliteConnection.h.
Connection type.
Enumerator | |
---|---|
INTERNAL_CONNECTION | Internal connection which must be released in destructor. |
EXTERNAL_CONNECTION | External connection managed from outside. |
Definition at line 26 of file SqliteConnection.h.
|
inlineexplicit |
Constructor.
connection | Pointer to the SQLite connection. |
connectionType | Type of the connection. Default is INTERNAL_CONNECTION. |
Definition at line 129 of file SqliteConnection.h.
|
inline |
Destructor.
Definition at line 134 of file SqliteConnection.h.
|
delete |
Copying and moving is disallowed!
|
delete |
Copying and moving is disallowed!
|
inline |
Terminates the current transaction.
The parameter wasTransactionStarted is used for convenience since it's then easier to write code which uses transactions.
wasTransactionStarted | When false, the call does actually nothing. |
Definition at line 198 of file SqliteConnection.h.
|
inline |
Executes a single query which doesn't need to return anything - e.g. DML.
sqlQuery | The query string. |
Definition at line 161 of file SqliteConnection.h.
|
inline |
Gets the current connection.
Definition at line 156 of file SqliteConnection.h.
|
inline |
Gets the current connection type.
When connection is NULL, the connection type is insignificant.
Definition at line 151 of file SqliteConnection.h.
|
delete |
Copying and moving is disallowed!
|
delete |
Copying and moving is disallowed!
|
inline |
Prepares the SQLite statement for the given query.
Note that the user is responsible to proper statement finalization using sqlite3_finalize!
sqlQuery | The query string. |
Definition at line 172 of file SqliteConnection.h.
|
inline |
Resets the connection.
connection | New connection to set. Default is NULL - i.e. unset. |
connectionType | Type of the new connection. |
Definition at line 139 of file SqliteConnection.h.
|
inline |
Starts a new transaction if a transaction is not already started.
Definition at line 186 of file SqliteConnection.h.