|
RADLib
RADical C++ application framework
|
SQLite connection wrapper with RADCore event reporting. More...
#include <RADDatabase.h>
Inheritance diagram for RADDatabase::RADSqlDatabase:
Collaboration diagram for RADDatabase::RADSqlDatabase:Public Member Functions | |
| RADSqlDatabase () | |
| Creates a database object with no file assigned yet. More... | |
| RADSqlDatabase (std::string fileName) | |
| Creates a database object targeting fileName. More... | |
| ~RADSqlDatabase () override | |
| Closes the SQLite handle if still open. More... | |
| void | setFileName (std::string fileName) |
| Sets the SQLite database file path used by open(). More... | |
| const std::string & | fileName () const |
| Returns the configured SQLite database file path. More... | |
| bool | open () |
| Opens the configured SQLite database file. More... | |
| void | close () |
| Closes the SQLite connection. More... | |
| bool | isOpen () const |
| Returns true when a SQLite connection is open. More... | |
| std::string | lastError () const |
| Returns the most recent SQLite error message. More... | |
| bool | execute (const std::string &sql) |
| Executes SQL that does not need row results. More... | |
| RADSqlResult | query (const std::string &sql) |
| Executes SQL and returns collected result rows. More... | |
| RADSqlStatement | prepare (const std::string &sql) |
| Prepares a reusable SQL statement. More... | |
| RADCore::RADFutureT< RADSqlResult > | queryAsync (RADCore::RADThreadPool &pool, RADCore::EventLoop &completionLoop, const std::string &sql) |
| Runs query asynchronously on pool and posts completion to completionLoop. More... | |
| bool | beginTransaction () |
| Starts a SQLite transaction. More... | |
| bool | commit () |
| Commits the active transaction. More... | |
| bool | rollback () |
| Rolls back the active transaction. More... | |
| int | schemaVersion () |
| Returns current schema version from the rad_schema_version table. More... | |
| bool | migrateTo (int targetVersion, const std::vector< std::pair< int, std::string >> &migrations) |
| Applies ordered migrations until targetVersion is reached. More... | |
Public Member Functions inherited from RADCore::RADObject | |
| RADObject () | |
| Creates a RADObject bound to the current thread. More... | |
| virtual | ~RADObject () |
| Disconnects tracked event links and releases lifetime token. More... | |
| void | registerLink (const ConnectionRecord &record) |
| Registers a connection for cleanup when this object is destroyed. More... | |
| std::thread::id | threadId () const |
| Returns the thread id this object is currently associated with. More... | |
| EventLoop * | associatedEventLoop () const |
| Returns the associated event loop, if any. More... | |
| ThreadAffinity | threadAffinity () const |
| Returns both thread id and associated loop atomically. More... | |
| std::weak_ptr< void > | lifetimeToken () const |
| Returns a weak token used to drop queued callbacks after destruction. More... | |
| void | moveToThread (std::thread::id tId, EventLoop *loop=nullptr) |
| Moves the object's affinity to tId and optional loop. More... | |
Public Attributes | |
| RADCore::Event< void(std::string) > | errorOccurred |
| Raised when SQLite open, execute, query, or transaction handling fails. More... | |
Friends | |
| class | RADSqlStatement |
| class | RADSqlTransaction |
SQLite connection wrapper with RADCore event reporting.
| RADDatabase::RADSqlDatabase::RADSqlDatabase | ( | ) |
Creates a database object with no file assigned yet.
|
explicit |
Creates a database object targeting fileName.
|
override |
Closes the SQLite handle if still open.
| bool RADDatabase::RADSqlDatabase::beginTransaction | ( | ) |
Starts a SQLite transaction.
| void RADDatabase::RADSqlDatabase::close | ( | ) |
Closes the SQLite connection.
| bool RADDatabase::RADSqlDatabase::commit | ( | ) |
Commits the active transaction.
| bool RADDatabase::RADSqlDatabase::execute | ( | const std::string & | sql | ) |
Executes SQL that does not need row results.
| const std::string& RADDatabase::RADSqlDatabase::fileName | ( | ) | const |
Returns the configured SQLite database file path.
| bool RADDatabase::RADSqlDatabase::isOpen | ( | ) | const |
Returns true when a SQLite connection is open.
| std::string RADDatabase::RADSqlDatabase::lastError | ( | ) | const |
Returns the most recent SQLite error message.
| bool RADDatabase::RADSqlDatabase::migrateTo | ( | int | targetVersion, |
| const std::vector< std::pair< int, std::string >> & | migrations | ||
| ) |
Applies ordered migrations until targetVersion is reached.
| bool RADDatabase::RADSqlDatabase::open | ( | ) |
Opens the configured SQLite database file.
| RADSqlStatement RADDatabase::RADSqlDatabase::prepare | ( | const std::string & | sql | ) |
Prepares a reusable SQL statement.
| RADSqlResult RADDatabase::RADSqlDatabase::query | ( | const std::string & | sql | ) |
Executes SQL and returns collected result rows.
| RADCore::RADFutureT<RADSqlResult> RADDatabase::RADSqlDatabase::queryAsync | ( | RADCore::RADThreadPool & | pool, |
| RADCore::EventLoop & | completionLoop, | ||
| const std::string & | sql | ||
| ) |
Runs query asynchronously on pool and posts completion to completionLoop.
| bool RADDatabase::RADSqlDatabase::rollback | ( | ) |
Rolls back the active transaction.
| int RADDatabase::RADSqlDatabase::schemaVersion | ( | ) |
Returns current schema version from the rad_schema_version table.
| void RADDatabase::RADSqlDatabase::setFileName | ( | std::string | fileName | ) |
Sets the SQLite database file path used by open().
|
friend |
|
friend |
| RADCore::Event<void (std::string) > RADDatabase::RADSqlDatabase::errorOccurred |
Raised when SQLite open, execute, query, or transaction handling fails.