32#ifndef GUARD_SQLITE_COMMAND_HPP_INCLUDED
33#define GUARD_SQLITE_COMMAND_HPP_INCLUDED
64 return {std::string(name), std::forward<T>(value)};
120 template <
typename... Args>
bool operator()(Args &&...args) {
121 if constexpr (
sizeof...(Args) == 0) {
125 ((void)(*
this % std::forward<Args>(args)), ...);
146 void bind(
int idx, std::int64_t v);
158 template <
typename Text>
159 requires std::convertible_to<Text, std::string_view>
169 void bind(
int idx,
void const *buf,
size_t buf_size);
176 void bind(
int idx, std::vector<unsigned char>
const &v);
177 void bind(
int idx, std::span<const unsigned char> v);
178 void bind(
int idx, std::span<const std::byte> v);
180 template <
typename Value>
void bind_value(
int idx, Value &&value);
184 template <
typename Value>
void bind(std::string_view name, Value &&value) {
188 template <
typename Value>
190 void bind(
int idx, Value &&value) {
230 template <
typename Text>
231 requires std::convertible_to<Text, std::string_view>
252 template <
typename Value>
289 auto micros = std::chrono::duration_cast<std::chrono::microseconds>(value).count();
290 bind(idx,
static_cast<std::int64_t
>(micros));
293 std::chrono::duration_cast<std::chrono::microseconds>(value.time_since_epoch())
295 bind(idx,
static_cast<std::int64_t
>(micros));
296 }
else if constexpr (std::is_enum_v<decayed>) {
297 bind(idx,
static_cast<std::int64_t
>(value));
298 }
else if constexpr (std::is_integral_v<decayed>) {
299 bind(idx,
static_cast<std::int64_t
>(value));
300 }
else if constexpr (std::is_floating_point_v<decayed>) {
301 bind(idx,
static_cast<double>(value));
303 bind(idx, std::string_view(std::forward<Value>(value)));
312 "Unsupported type for sqlite::command::bind_value");
Owning RAII wrapper for sqlite3* handles plus attachment helpers and statement caching.
std::remove_cvref_t< T > decay_t
constexpr bool needs_generic_binding_v
constexpr bool is_time_point_v
constexpr bool is_byte_vector_v
constexpr bool is_optional_v
constexpr bool is_unsigned_char_span_v
constexpr bool always_false_v
constexpr bool is_string_like_v
constexpr bool is_duration_v
constexpr bool is_byte_span_v
named_parameter< std::decay_t< T > > named(std::string_view name, T &&value)
null_type nil
nil is used instead of NULL within the operator % syntax in this wrapper
command is the base class of all sql command classes An object of this class is not copyable
void bind(int idx, void const *buf, size_t buf_size)
binds the binary/blob buf to the given 1 based index
void bind_text_impl(int idx, std::string_view text)
command & operator%(double p)
replacement for void command::bind(int idx,double); Indexes are given automatically first call uses 1...
command & operator%(std::span< const unsigned char > p)
command & operator=(command const &)=delete
void access_check() const
command & operator%(Value &&value)
command & operator%(std::int64_t p)
replacement for void command::bind(int idx,std::int64_t); Indexes are given automatically first call ...
command & operator%(std::span< const std::byte > p)
void bind(int idx, double v)
binds the double v to the given 1 based index
void bind(int idx, int v)
binds the 32-Bit integer v to the given 1 based index
struct sqlite3 * get_handle()
void bind(int idx, std::int64_t v)
binds the 64-Bit integer v to the given 1 based index
void bind(int idx, std::span< const unsigned char > v)
void bind(std::string_view name, Value &&value)
bool step_once()
step_once executes the sql command a single time. If you have used placeholders you must have replace...
bool operator()(Args &&...args)
Binds all supplied arguments (if any) and executes the statement.
command & operator%(null_type const &p)
replacement for void command::bind(int idx); To use this operator% you have to use the global object ...
command & operator%(int p)
replacement for void command::bind(int idx,int); Indexes are given automatically first call uses 1 as...
command & operator%(named_parameter< T > param)
void bind(int idx, std::span< const std::byte > v)
void clear()
clear is used if you'd like to reuse a command object
command & operator%(std::vector< unsigned char > const &p)
replacement for void command::bind(int idx,std::vector<unsigned char> const&); Indexes are given auto...
void bind(int idx, Text &&text)
binds the text/string v to the given 1 based index
command(connection &con, std::string const &sql)
command constructor
void bind(int idx, std::vector< unsigned char > const &v)
binds the binary/blob v to the given 1 based index
virtual ~command()
command destructor
command(command const &)=delete
bool operator()()
works exactly like command::step_once
void bind(int idx, Value &&value)
command & operator%(Text &&p)
replacement for void command::bind(int idx,std::string const&); Indexes are given automatically first...
int parameter_index(std::string_view name) const
void bind(int idx)
binds NULL to the given 1 based index
void bind_value(int idx, Value &&value)
connection is used to open, close, attach and detach a database. Further it has to be passed to all c...
null_type is an empty type used to represent NULL values
Forward-only cursor over the rows produced by a prepared statement.