VSQLite++ 0.3
Loading...
Searching...
No Matches
sqlite::v2::command Struct Reference

command is the base class of all sql command classes An object of this class is not copyable More...

#include <command.hpp>

Inheritance diagram for sqlite::v2::command:
Inheritance graph
Collaboration diagram for sqlite::v2::command:
Collaboration graph

Public Member Functions

 command (connection &con, std::string const &sql)
 command constructor
 command (command const &)=delete
commandoperator= (command const &)=delete
virtual ~command ()
 command destructor
void clear ()
 clear is used if you'd like to reuse a command object
void reset_statement ()
bool step_once ()
 step_once executes the sql command a single time. If you have used placeholders you must have replaced all placeholders
bool operator() ()
 works exactly like command::step_once
template<typename... Args>
bool operator() (Args &&...args)
 Binds all supplied arguments (if any) and executes the statement.
void bind (int idx)
 binds NULL to the given 1 based index
void bind (int idx, int v)
 binds the 32-Bit integer v to the given 1 based index
void bind (int idx, std::int64_t v)
 binds the 64-Bit integer v to the given 1 based index
void bind (int idx, double v)
 binds the double v to the given 1 based index
template<typename Text>
requires std::convertible_to<Text, std::string_view>
void bind (int idx, Text &&text)
 binds the text/string v to the given 1 based index
void bind (int idx, void const *buf, size_t buf_size)
 binds the binary/blob buf to the given 1 based index
void bind (int idx, std::vector< unsigned char > const &v)
 binds the binary/blob v to the given 1 based index
void bind (int idx, std::span< const unsigned char > v)
void bind (int idx, std::span< const std::byte > v)
template<typename Value>
void bind_value (int idx, Value &&value)
int parameter_index (std::string_view name) const
template<typename Value>
void bind (std::string_view name, Value &&value)
template<typename Value>
requires detail::needs_generic_binding_v<Value>
void bind (int idx, Value &&value)
commandoperator% (null_type const &p)
 replacement for void command::bind(int idx); To use this operator% you have to use the global object nil Indexes are given automatically first call uses 1 as index, second 2 and so on
commandoperator% (int p)
 replacement for void command::bind(int idx,int); Indexes are given automatically first call uses 1 as index, second 2 and so on
commandoperator% (std::int64_t p)
 replacement for void command::bind(int idx,std::int64_t); Indexes are given automatically first call uses 1 as index, second 2 and so on
commandoperator% (double p)
 replacement for void command::bind(int idx,double); Indexes are given automatically first call uses 1 as index, second 2 and so on
template<typename Text>
requires std::convertible_to<Text, std::string_view>
commandoperator% (Text &&p)
 replacement for void command::bind(int idx,std::string const&); Indexes are given automatically first call uses 1 as index, second 2 and so on
commandoperator% (std::vector< unsigned char > const &p)
 replacement for void command::bind(int idx,std::vector<unsigned char> const&); Indexes are given automatically first call uses 1 as index, second 2 and so on
commandoperator% (std::span< const unsigned char > p)
commandoperator% (std::span< const std::byte > p)
template<typename T>
commandoperator% (named_parameter< T > param)
template<typename Value>
requires detail::needs_generic_binding_v<detail::decay_t<Value>>
commandoperator% (Value &&value)

Protected Member Functions

void access_check () const
bool step ()
struct sqlite3 * get_handle ()

Protected Attributes

sqlite3_stmt * stmt

Private Member Functions

void prepare ()
void finalize ()
void bind_text_impl (int idx, std::string_view text)

Private Attributes

connectionm_con
std::string m_sql
int last_arg_idx

Detailed Description

command is the base class of all sql command classes An object of this class is not copyable

Definition at line 80 of file command.hpp.

Constructor & Destructor Documentation

◆ command() [1/2]

sqlite::v2::command::command ( connection & con,
std::string const & sql )

command constructor

Parameters
contakes a reference to the database connection type connection
sqlis the SQL string. The sql string can contain placeholder the question mark '?' is used as placeholder the command::bind methods or command::operator% syntax must be used to replace the placeholders

Referenced by command(), operator%(), operator%(), operator%(), operator%(), operator%(), operator%(), operator%(), operator%(), operator%(), operator%(), and operator=().

◆ command() [2/2]

sqlite::v2::command::command ( command const & )
delete

References command().

Here is the call graph for this function:

◆ ~command()

virtual sqlite::v2::command::~command ( )
virtual

command destructor

Member Function Documentation

◆ access_check()

void sqlite::v2::command::access_check ( ) const
protected

◆ bind() [1/11]

void sqlite::v2::command::bind ( int idx)

binds NULL to the given 1 based index

Referenced by bind(), bind_value(), operator%(), and operator%().

◆ bind() [2/11]

void sqlite::v2::command::bind ( int idx,
double v )

binds the double v to the given 1 based index

Parameters
idx1 based index of the placeholder within the sql statement
vdouble value which should replace the placeholder

◆ bind() [3/11]

void sqlite::v2::command::bind ( int idx,
int v )

binds the 32-Bit integer v to the given 1 based index

Parameters
idx1 based index of the placeholder within the sql statement
v32-Bit integer value which should replace the placeholder

◆ bind() [4/11]

void sqlite::v2::command::bind ( int idx,
std::int64_t v )

binds the 64-Bit integer v to the given 1 based index

Parameters
idx1 based index of the placeholder within the sql statement
v64-Bit integer value which should replace the placeholder

◆ bind() [5/11]

void sqlite::v2::command::bind ( int idx,
std::span< const std::byte > v )

◆ bind() [6/11]

void sqlite::v2::command::bind ( int idx,
std::span< const unsigned char > v )

◆ bind() [7/11]

void sqlite::v2::command::bind ( int idx,
std::vector< unsigned char > const & v )

binds the binary/blob v to the given 1 based index

Parameters
idx1 based index of the placeholder within the sql statement
vbinary/blob buffer which should replace the placeholder v is a std::vector<unsigned char> const &

◆ bind() [8/11]

template<typename Text>
requires std::convertible_to<Text, std::string_view>
void sqlite::v2::command::bind ( int idx,
Text && text )
inline

binds the text/string v to the given 1 based index

Parameters
idx1 based index of the placeholder within the sql statement
vtext/string value which should replace the placeholder

Definition at line 160 of file command.hpp.

References bind_text_impl(), and sqlite::v2::text.

Here is the call graph for this function:

◆ bind() [9/11]

template<typename Value>
requires detail::needs_generic_binding_v<Value>
void sqlite::v2::command::bind ( int idx,
Value && value )
inline

Definition at line 190 of file command.hpp.

References bind_value().

Here is the call graph for this function:

◆ bind() [10/11]

void sqlite::v2::command::bind ( int idx,
void const * buf,
size_t buf_size )

binds the binary/blob buf to the given 1 based index

Parameters
idx1 based index of the placeholder within the sql statement
bufbinary/blob buf which should replace the placeholder
buf_sizesize in bytes of the binary buffer

◆ bind() [11/11]

template<typename Value>
void sqlite::v2::command::bind ( std::string_view name,
Value && value )
inline

Definition at line 184 of file command.hpp.

References bind(), and parameter_index().

Here is the call graph for this function:

◆ bind_text_impl()

void sqlite::v2::command::bind_text_impl ( int idx,
std::string_view text )
private

References sqlite::v2::text.

Referenced by bind().

◆ bind_value()

◆ clear()

void sqlite::v2::command::clear ( )

clear is used if you'd like to reuse a command object

◆ finalize()

void sqlite::v2::command::finalize ( )
private

◆ get_handle()

struct sqlite3 * sqlite::v2::command::get_handle ( )
protected

◆ operator%() [1/10]

command & sqlite::v2::command::operator% ( double p)

replacement for void command::bind(int idx,double); Indexes are given automatically first call uses 1 as index, second 2 and so on

Parameters
pa double variable

References command().

Here is the call graph for this function:

◆ operator%() [2/10]

command & sqlite::v2::command::operator% ( int p)

replacement for void command::bind(int idx,int); Indexes are given automatically first call uses 1 as index, second 2 and so on

Parameters
pshould be a 32-Bit integer

References command().

Here is the call graph for this function:

◆ operator%() [3/10]

template<typename T>
command & sqlite::v2::command::operator% ( named_parameter< T > param)
inline

Definition at line 247 of file command.hpp.

References bind(), command(), sqlite::v2::named_parameter< T >::name, and sqlite::v2::named_parameter< T >::value.

Here is the call graph for this function:

◆ operator%() [4/10]

command & sqlite::v2::command::operator% ( null_type const & p)

replacement for void command::bind(int idx); To use this operator% you have to use the global object nil Indexes are given automatically first call uses 1 as index, second 2 and so on

Parameters
pshould be nil

References command().

Here is the call graph for this function:

◆ operator%() [5/10]

command & sqlite::v2::command::operator% ( std::int64_t p)

replacement for void command::bind(int idx,std::int64_t); Indexes are given automatically first call uses 1 as index, second 2 and so on

Parameters
pshould be a 64-Bit integer

References command().

Here is the call graph for this function:

◆ operator%() [6/10]

command & sqlite::v2::command::operator% ( std::span< const std::byte > p)

References command().

Here is the call graph for this function:

◆ operator%() [7/10]

command & sqlite::v2::command::operator% ( std::span< const unsigned char > p)

References command().

Here is the call graph for this function:

◆ operator%() [8/10]

command & sqlite::v2::command::operator% ( std::vector< unsigned char > const & p)

replacement for void command::bind(int idx,std::vector<unsigned char> const&); Indexes are given automatically first call uses 1 as index, second 2 and so on

Parameters
pa constant reference to a std::vector<unsigned char> object (For blob/binary data)

References command().

Here is the call graph for this function:

◆ operator%() [9/10]

template<typename Text>
requires std::convertible_to<Text, std::string_view>
command & sqlite::v2::command::operator% ( Text && p)
inline

replacement for void command::bind(int idx,std::string const&); Indexes are given automatically first call uses 1 as index, second 2 and so on

Parameters
pshould be a Zero Terminated C-style string (char * or char const*), or a std::string object,

Definition at line 232 of file command.hpp.

References bind(), command(), and last_arg_idx.

Here is the call graph for this function:

◆ operator%() [10/10]

template<typename Value>
requires detail::needs_generic_binding_v<detail::decay_t<Value>>
command & sqlite::v2::command::operator% ( Value && value)
inline

Definition at line 254 of file command.hpp.

References bind_value(), command(), and last_arg_idx.

Here is the call graph for this function:

◆ operator()() [1/2]

bool sqlite::v2::command::operator() ( )

works exactly like command::step_once

Referenced by operator()().

◆ operator()() [2/2]

template<typename... Args>
bool sqlite::v2::command::operator() ( Args &&... args)
inline

Binds all supplied arguments (if any) and executes the statement.

Existing bindings (set via operator% or bind) are preserved so you can pre-bind a subset before forwarding the remaining arguments. Once the statement executes, the positional index resets so the next invocation starts from the first placeholder again.

Definition at line 120 of file command.hpp.

References last_arg_idx, operator()(), reset_statement(), and step().

Here is the call graph for this function:

◆ operator=()

command & sqlite::v2::command::operator= ( command const & )
delete

References command().

Here is the call graph for this function:

◆ parameter_index()

int sqlite::v2::command::parameter_index ( std::string_view name) const

Referenced by bind().

◆ prepare()

void sqlite::v2::command::prepare ( )
private

◆ reset_statement()

void sqlite::v2::command::reset_statement ( )

Referenced by operator()().

◆ step()

bool sqlite::v2::command::step ( )
protected

Referenced by operator()().

◆ step_once()

bool sqlite::v2::command::step_once ( )

step_once executes the sql command a single time. If you have used placeholders you must have replaced all placeholders

Member Data Documentation

◆ last_arg_idx

int sqlite::v2::command::last_arg_idx
private

Definition at line 277 of file command.hpp.

Referenced by operator%(), operator%(), and operator()().

◆ m_con

connection& sqlite::v2::command::m_con
private

Definition at line 270 of file command.hpp.

◆ m_sql

std::string sqlite::v2::command::m_sql
private

Definition at line 271 of file command.hpp.

◆ stmt

sqlite3_stmt* sqlite::v2::command::stmt
protected

Definition at line 274 of file command.hpp.


The documentation for this struct was generated from the following file: