9#ifndef HEADER_SQLITEPP_STATEMENT_IFACE_INCLUDED
10#define HEADER_SQLITEPP_STATEMENT_IFACE_INCLUDED
13#include "string_param.hpp"
15#include "memory_iface.hpp"
54 #
if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 20, 0)
55 ,
unsigned int flags = 0
72 #
if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 20, 0)
73 ,
unsigned int flags = 0
77#if __cpp_char8_t >= 201811
84 #
if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 20, 0)
85 ,
unsigned int flags = 0
89 return create(db, (
const char *)
sql.c_str()
102 #
if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 20, 0)
103 ,
unsigned int flags = 0
166#if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 31, 1)
213 void bind(
int idx, int64_t val)
260 #if __cpp_char8_t >= 201811
336 void bind(
int idx, T * ptr,
const char * type,
void(*destroy)(T*))
351 { this->
bind(idx, ptr.
release(),
typeid(T).name(), [](T * p) { delete p; }); }
432 static constexpr bool supported_column_type =
437 #if __cpp_char8_t >= 201811
465 SQLITEPP_ENABLE_IF(supported_column_type<T>,
538 const char *
sql() const noexcept
541#if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 14, 0)
553 void check_error(
int res)
const;
636 template<auto_reset_flags Flags>
683 void destroy() noexcept
sqlite3_bind_parameter_count
sqlite3_bind_parameter_index
sqlite3_bind_parameter_name
#define SQLITE_VERSION_NUMBER
RAII wrapper that resets statement on destruction.
Definition statement_iface.hpp:638
auto_reset()
Constructs an empty instance with no statement.
Definition statement_iface.hpp:641
auto_reset(const std::unique_ptr< statement > &st) noexcept
Constructs an instance referring to a given statement.
Definition statement_iface.hpp:650
~auto_reset() noexcept
Resets the statement if present.
Definition statement_iface.hpp:675
auto_reset(statement *st) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition statement_iface.hpp:655
statement * operator->() const noexcept
Access the stored statement.
Definition statement_iface.hpp:679
A reference to a null terminated string.
Definition string_param.hpp:37
Database Connection.
Definition database_iface.hpp:108
Base functionality for all fake wrapper classes
Definition handle.hpp:27
sqlite3_stmt * c_ptr() const noexcept
Definition handle.hpp:45
Parses text containing multiple SQL statements.
Definition statement_iface.hpp:587
std::unique_ptr< statement > next()
Return the next statement if any.
statement_parser(const database &db, std::string_view sql)
Create a parser for the given database and SQL text.
Definition statement_iface.hpp:590
Prepared Statement Object.
Definition statement_iface.hpp:41
explain_type isexplain() const noexcept
Query the EXPLAIN Setting for the statement.
Definition statement_iface.hpp:174
bool step()
Evaluate the statement.
void bind_reference(int idx, const std::string_view &val, void(*unref)(const char *))
Bind a string reference to a parameter of the statement.
class database & database() const noexcept
Returns the database to which this statement belongs.
Definition statement_iface.hpp:124
void bind_reference(int idx, const blob_view &val, void(*unref)(const std::byte *))
Bind a blob reference to a parameter of the statement.
bool readonly() const noexcept
Determine if the statement writes to the database.
Definition statement_iface.hpp:183
void reset() noexcept
Reset the statement.
Definition statement_iface.hpp:144
void bind(int idx, const value &val)
Bind a dynamically typed value to a parameter of the statement.
void bind(int idx, const std::u8string_view &val)
Bind a string value to a parameter of the statement.
void bind(int idx, std::nullptr_t)
Bind a NULL value to a parameter of the statement.
Definition statement_iface.hpp:199
bool busy() const noexcept
Determine if the statement has been reset.
Definition statement_iface.hpp:152
const value & raw_column_value(int idx) const noexcept
Get result values from a query as a raw value object.
Definition statement_iface.hpp:473
void bind_reference(int idx, const std::u8string_view &val)
Bind a string reference to a parameter of the statement.
void bind(int idx, std::unique_ptr< T > ptr)
Bind a custom pointer to a parameter of the statement.
Definition statement_iface.hpp:350
const char * sql() const noexcept
Returns a pointer to a copy of the SQL text used to create the statement.
Definition statement_iface.hpp:538
void bind(int idx, int val)
Bind an int value to a parameter of the statement.
Definition statement_iface.hpp:206
int column_type(int idx) const noexcept
Default datatype of the result column.
Definition statement_iface.hpp:483
allocated_string expanded_sql() const
Returns SQL text of the statement with bound parameters expanded.
void bind(int idx, T *ptr, const char *type, void(*destroy)(T *))
Definition statement_iface.hpp:336
void bind(int idx, const zero_blob &val)
Bind a blob of zeroes to a parameter of the statement.
Definition statement_iface.hpp:324
int column_count() const noexcept
Number of columns in a result set.
Definition statement_iface.hpp:413
void bind(int idx, int64_t val)
Bind an int64_t value to a parameter of the statement.
Definition statement_iface.hpp:213
static std::unique_ptr< statement > create(const database &db, std::string_view &sql, unsigned int flags=0)
Compile an SQL statement.
const char * column_table_name(int idx) const noexcept
Table that is the origin of a result column.
Definition statement_iface.hpp:512
const char * bind_parameter_name(int idx) const noexcept
Returns the name of a parameter with a given index.
Definition statement_iface.hpp:396
const char * column_origin_name(int idx) const noexcept
Table column that is the origin of a result column.
Definition statement_iface.hpp:520
static std::unique_ptr< statement > create(const database &db, const string_param &sql, unsigned int flags=0)
Compile an SQL statement.
void bind_reference(int idx, const std::u8string_view &val, void(*unref)(const char8_t *))
Bind a string reference to a parameter of the statement.
const char * column_database_name(int idx) const noexcept
Database that is the origin of a result column.
Definition statement_iface.hpp:504
~statement() noexcept
Equivalent to sqlite3_finalize.
Definition statement_iface.hpp:116
void bind(int idx, double val)
Bind a double value to a parameter of the statement.
Definition statement_iface.hpp:220
static std::unique_ptr< statement > create(const database &db, std::u8string_view &sql, unsigned int flags=0)
Compile an SQL statement.
Definition statement_iface.hpp:101
explain_type
Return type for isexplain()
Definition statement_iface.hpp:159
@ explain_query_plan
The statement is an EXPLAIN QUERY PLAN.
@ explain
The statement is an EXPLAIN statement.
@ not_explain
The statement is an ordinary statement.
const char * column_name(int idx) const noexcept
Name of the result column.
Definition statement_iface.hpp:496
T column_value(int idx) const noexcept
Get result value from a query.
void bind(int idx, const blob_view &val)
Bind a blob value to a parameter of the statement.
void bind_reference(int idx, const std::string_view &val)
Bind a string reference to a parameter of the statement.
void bind_reference(int idx, const blob_view &val)
Bind a blob reference to a parameter of the statement.
int bind_parameter_count() const noexcept
Returns the number of SQL parameters.
Definition statement_iface.hpp:380
void clear_bindings() noexcept
Reset all bindings on the statement.
Definition statement_iface.hpp:372
int bind_parameter_index(const string_param &name) const noexcept
Returns the index of a parameter with a given name.
Definition statement_iface.hpp:388
const char * column_declared_type(int idx) const noexcept
Declared datatype of a result column.
Definition statement_iface.hpp:528
void bind(int idx, const std::string_view &val)
Bind a string value to a parameter of the statement.
static std::unique_ptr< statement > create(const database &db, const u8string_param &sql, unsigned int flags=0)
Compile an SQL statement.
Definition statement_iface.hpp:83
int data_count() const noexcept
Number of columns in a result set.
Definition statement_iface.hpp:427
Dynamically Typed Value Object.
Definition value_iface.hpp:35
An efficient blob of zeroes of a given size.
Definition span.hpp:256
sqlite3_column_database_name
auto_reset_flags
Bitwise mask of resets to perform for thinsqlitepp::auto_reset.
Definition statement_iface.hpp:612
@ reset
Reset the statement (does not affect the bindings)
@ clear_bindings
Reset the bindings.
ThinSQLite++ namespace.
Definition backup_iface.hpp:17