21 m_handle(
nullptr, sqlite3_finalize),
25 statement::operator bool() const noexcept
27 return static_cast<bool>(m_handle);
34 return m_handle.get();
43 if (m_done)
return false;
45 const int result = sqlite3_step(
handle());
47 if (result == SQLITE_ROW)
return true;
48 if (result == SQLITE_DONE) {
65 return sqlite3_changes(sqlite3_db_handle(
handle()));
70 if (SQLITE_OK != sqlite3_bind_int(
handle(), index, value))
78 if (SQLITE_OK != sqlite3_bind_double(
handle(), index, value))
94 if (SQLITE_OK != sqlite3_bind_blob(
handle(), index, value.
data(), value.
size(), SQLITE_TRANSIENT))
102 if (SQLITE_OK != sqlite3_bind_text(
handle(), index, value, size, type ==
bindtype::transiently ? SQLITE_TRANSIENT : SQLITE_STATIC))
110 if (SQLITE_OK != sqlite3_bind_text16(
handle(), index, value, size, type ==
bindtype::transiently ? SQLITE_TRANSIENT : SQLITE_STATIC))
118 bind(index, value.c_str(), value.size());
123 bind(index, value.c_str(), value.size() *
sizeof(char16_t));
126 void statement::throw_last_error()
const
128 throw_error_code(sqlite3_db_handle(
handle()));
141 if (!m_statement->
step())
143 m_statement =
nullptr;
151 return m_statement != other.m_statement;
row operator*() const noexcept
Dereference operation.
A SQLite dynamically typed value object, aka "sqlite3_value".
size_t size() const
Used to get the size of the contained 'blob'.
const void * data() const
The raw data of the blob's contents.
bool operator!=(const row_iterator &other) const noexcept
Comparison operation.
means that the content will likely change in the near future and that SQLite should make its own priv...
bool step() const
Evaluates a prepared statement.
void bind(const int index, const int value) const
Binds an integer value to a parameter in an SQL prepared statement.
sqlite3_stmt * handle() const noexcept
Returns pointer to the underlying "sqlite3_stmt" object.
Helps when iterating over rows in a "SELECT" statement.
int execute() const
Executes a prepared statement and will return the number of changes to the database.
bindtype
Used to specify the way to bind a value to a statement.
Represents a single SQL statement that has been compiled into binary form and is ready to be evaluate...
Represents a returned row when stepping through a "SELECT" statement.
row_iterator() noexcept=default
Default constructor.
row_iterator end(const statement &statement) noexcept
Returns an iterator to the end.
row_iterator begin(const statement &statement) noexcept
Returns an iterator to the first row of a statement.
statement() noexcept
Default constructor.
row_iterator & operator++() noexcept
Increment iterator to the next row object of the statement.