RhythmGame 1.4.3
Loading...
Searching...
No Matches
Public Member Functions | List of all members
db::SqliteCppDb::Statement Class Reference

Wrapper for SQLiteCpp::Statement. More...

#include <SqliteCppDb.h>

Public Member Functions

 Statement (SQLite::Statement statement, SqliteCppDb *db)
 
template<typename... T>
auto bind (int index, T &&... values) -> void
 
template<typename... T>
auto bind (const std::string &name, T &&... values) -> void
 
void reset ()
 
void execute (std::stop_token stopToken={})
 
template<std::default_initializable Ret>
auto executeAndGet (std::stop_token stopToken={}) -> std::optional< Ret >
 Executes a query that returns a single row.
 
template<std::default_initializable Ret>
auto executeAndGetAll (std::stop_token stopToken={}) -> std::vector< Ret >
 Executes a query that returns any number of rows.
 

Detailed Description

Wrapper for SQLiteCpp::Statement.

Note
A statement must not be used by multiple threads simultaneously.

Execution accepts an optional stop token. Cancellation is checked after acquiring the connection and during SQL execution and row copying. It throws SQLite::Exception with SQLITE_INTERRUPT without interrupting other statements. Interrupted writes may roll back their transaction.

Constructor & Destructor Documentation

◆ Statement()

db::SqliteCppDb::Statement::Statement ( SQLite::Statement  statement,
SqliteCppDb *  db 
)

Member Function Documentation

◆ bind() [1/2]

template<typename... T>
auto db::SqliteCppDb::Statement::bind ( const std::string &  name,
T &&...  values 
) -> void
inline

◆ bind() [2/2]

template<typename... T>
auto db::SqliteCppDb::Statement::bind ( int  index,
T &&...  values 
) -> void
inline

◆ execute()

void db::SqliteCppDb::Statement::execute ( std::stop_token  stopToken = {})

◆ executeAndGet()

template<std::default_initializable Ret>
auto db::SqliteCppDb::Statement::executeAndGet ( std::stop_token  stopToken = {}) -> std::optional<Ret>
inline

Executes a query that returns a single row.

Returns
An optional holding the result of the query. It will be empty if the query didn't return anything. The cursor is reset after copying the row, including on failure. Bindings are retained. Too few columns for the requested result type cause an exception.
Template Parameters
RetThe type that the result will be stored in can be a tuple or an aggregate. Must be default constructible.

◆ executeAndGetAll()

template<std::default_initializable Ret>
auto db::SqliteCppDb::Statement::executeAndGetAll ( std::stop_token  stopToken = {}) -> std::vector<Ret>
inline

Executes a query that returns any number of rows.

Returns
A vector holding the result of the query. It will be empty if the query didn't return anything. If the query returns fewer columns than specified in the template parameters, this method will throw.
Template Parameters
RetThe type that the result will be stored in can be a tuple or an aggregate. Must be default constructible.

◆ reset()

void db::SqliteCppDb::Statement::reset ( )

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