SQLite Containers
|
Class for managing SQLite prepared statements. More...
#include <SqliteStmt.hpp>
Public Member Functions | |
SqliteStmt ()=default | |
Default constructor. | |
SqliteStmt (sqlite3 *sqlite_db, const char *query) | |
Constructs a SqliteStmt and prepares the statement. | |
SqliteStmt (sqlite3 *sqlite_db, const std::string &query) | |
Constructs a SqliteStmt and prepares the statement. | |
~SqliteStmt () | |
Destructor. | |
void | init (sqlite3 *sqlite_db, const char *query) |
Initializes the statement. | |
void | init (sqlite3 *sqlite_db, const std::string &query) |
Initializes the statement. | |
sqlite3_stmt * | get_stmt () noexcept |
Gets the prepared SQLite statement. | |
void | reset () |
Resets the prepared statement. | |
void | clear_bindings () |
Clears all bindings on the prepared statement. | |
void | execute (sqlite3 *sqlite_db) |
Executes the prepared statement. | |
void | execute () |
Executes the prepared statement. | |
int | step () |
template<typename T > | |
T | extract_column (const int &index, typename std::enable_if< std::is_integral< T >::value >::type *=0) |
Extracts a value from a SQLite statement column. | |
template<typename T > | |
T | extract_column (const int &index, typename std::enable_if< std::is_floating_point< T >::value >::type *=0) |
template<typename T > | |
T | extract_column (const int &index, typename std::enable_if< std::is_same< T, std::string >::value >::type *=0) |
template<typename T > | |
T | extract_column (const int &index, typename std::enable_if< std::is_same< T, std::vector< char > >::value >::type *=0) |
template<typename T > | |
T | extract_column (const int &index, typename std::enable_if< std::is_same< T, std::vector< uint8_t > >::value >::type *=0) |
template<typename T > | |
T | extract_column (const int &index, typename std::enable_if< !std::is_integral< T >::value &&!std::is_floating_point< T >::value &&!std::is_same< T, std::string >::value &&!std::is_same< T, std::vector< char > >::value &&!std::is_same< T, std::vector< uint8_t > >::value &&std::is_trivially_copyable< T >::value >::type *=0) |
template<typename T > | |
bool | bind_value (const int &index, const T &value, typename std::enable_if< std::is_integral< T >::value >::type *=0) |
Binds a value to a SQLite statement. | |
template<typename T > | |
bool | bind_value (const int &index, const T &value, typename std::enable_if< std::is_floating_point< T >::value >::type *=0) |
template<typename T > | |
bool | bind_value (const int &index, const T &value, typename std::enable_if< std::is_same< T, std::string >::value >::type *=0) |
template<typename T > | |
bool | bind_value (const int &index, const T &value, typename std::enable_if< std::is_same< T, std::vector< char > >::value >::type *=0) |
template<typename T > | |
bool | bind_value (const int &index, const T &value, typename std::enable_if< std::is_same< T, std::vector< uint8_t > >::value >::type *=0) |
template<typename T > | |
bool | bind_value (const int &index, const T &value, typename std::enable_if< !std::is_integral< T >::value &&!std::is_floating_point< T >::value &&!std::is_same< T, std::string >::value &&!std::is_same< T, std::vector< char > >::value &&!std::is_same< T, std::vector< uint8_t > >::value &&std::is_trivially_copyable< T >::value >::type *=0) |
Private Attributes | |
sqlite3_stmt * | m_stmt = nullptr |
Pointer to the prepared SQLite statement. | |
Class for managing SQLite prepared statements.
Definition at line 11 of file SqliteStmt.hpp.
|
default |
Default constructor.
|
inline |
Constructs a SqliteStmt and prepares the statement.
sqlite_db | Pointer to the SQLite database. |
query | SQL query to prepare. |
sqlite_exception | if the query preparation fails. |
Definition at line 21 of file SqliteStmt.hpp.
|
inline |
Constructs a SqliteStmt and prepares the statement.
sqlite_db | Pointer to the SQLite database. |
query | SQL query to prepare. |
sqlite_exception | if the query preparation fails. |
Definition at line 29 of file SqliteStmt.hpp.
|
inline |
Destructor.
Definition at line 34 of file SqliteStmt.hpp.
|
inline |
Definition at line 207 of file SqliteStmt.hpp.
|
inline |
Definition at line 183 of file SqliteStmt.hpp.
|
inline |
Binds a value to a SQLite statement.
index | Index of the parameter to bind. |
value | The value to bind. |
Definition at line 177 of file SqliteStmt.hpp.
|
inline |
Definition at line 189 of file SqliteStmt.hpp.
|
inline |
Definition at line 195 of file SqliteStmt.hpp.
|
inline |
Definition at line 201 of file SqliteStmt.hpp.
|
inline |
Clears all bindings on the prepared statement.
sqlite_exception | if the clear bindings operation fails. |
Definition at line 85 of file SqliteStmt.hpp.
|
inline |
Executes the prepared statement.
sqlite_exception | if the execution fails. |
Definition at line 100 of file SqliteStmt.hpp.
|
inline |
Executes the prepared statement.
sqlite_db | Pointer to the SQLite database. |
sqlite_exception | if the execution fails. |
Definition at line 94 of file SqliteStmt.hpp.
|
inline |
Definition at line 152 of file SqliteStmt.hpp.
|
inline |
Definition at line 120 of file SqliteStmt.hpp.
|
inline |
Extracts a value from a SQLite statement column.
index | Index of the column to extract. |
Definition at line 114 of file SqliteStmt.hpp.
|
inline |
Definition at line 126 of file SqliteStmt.hpp.
|
inline |
Definition at line 136 of file SqliteStmt.hpp.
|
inline |
Definition at line 144 of file SqliteStmt.hpp.
|
inlinenoexcept |
Gets the prepared SQLite statement.
Definition at line 71 of file SqliteStmt.hpp.
|
inline |
Initializes the statement.
sqlite_db | Pointer to the SQLite database. |
query | SQL query to prepare. |
sqlite_exception | if the query preparation fails. |
Definition at line 44 of file SqliteStmt.hpp.
|
inline |
Initializes the statement.
sqlite_db | Pointer to the SQLite database. |
query | SQL query to prepare. |
sqlite_exception | if the query preparation fails. |
Definition at line 65 of file SqliteStmt.hpp.
|
inline |
Resets the prepared statement.
sqlite_exception | if the reset operation fails. |
Definition at line 77 of file SqliteStmt.hpp.
|
inline |
brief Advances the prepared statement to the next result row or completion. return Result code: SQLITE_ROW for a new row, SQLITE_DONE for completion, or an error code.
Definition at line 106 of file SqliteStmt.hpp.
|
private |
Pointer to the prepared SQLite statement.
Definition at line 220 of file SqliteStmt.hpp.