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

query should be used to execute SQL queries An object of this class is not copyable More...

#include <query.hpp>

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

Classes

class  result_range

Public Member Functions

 query (connection &con, std::string const &sql)
 constructor
virtual ~query ()
 destructor
VSQLITE_DEPRECATED result_type emit_result ()
 executes the sql command (deprecated, prefer each())
result_type get_result ()
 returns the results (needs a previous step_once() call)
result_range each ()
 Returns a range view for range-based for loops.
template<typename... Args, typename = std::enable_if_t<(sizeof...(Args) > 0)>>
result_range each (Args &&...args)
 Binds any supplied parameters and returns a range view.
Public Member Functions inherited from sqlite::v2::command
 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)

Private Member Functions

void access_check ()
bool step ()

Friends

struct result

Additional Inherited Members

Protected Member Functions inherited from sqlite::v2::command
void access_check () const
bool step ()
struct sqlite3 * get_handle ()
Protected Attributes inherited from sqlite::v2::command
sqlite3_stmt * stmt

Detailed Description

query should be used to execute SQL queries An object of this class is not copyable

Definition at line 61 of file query.hpp.

Constructor & Destructor Documentation

◆ query()

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

constructor

Parameters
conreference to the connection which should be used
sqlis the SQL query statement

◆ ~query()

virtual sqlite::v2::query::~query ( )
virtual

destructor

Member Function Documentation

◆ access_check()

void sqlite::v2::query::access_check ( )
private

◆ each() [1/2]

result_range sqlite::v2::query::each ( )

Returns a range view for range-based for loops.

Referenced by each().

◆ each() [2/2]

template<typename... Args, typename = std::enable_if_t<(sizeof...(Args) > 0)>>
result_range sqlite::v2::query::each ( Args &&... args)
inline

Binds any supplied parameters and returns a range view.

Mirrors the variadic command::operator(): arguments are bound via the streaming operator and the query remains otherwise untouched, so callers can mix manual % binding with this overload.

Definition at line 175 of file query.hpp.

References each().

Here is the call graph for this function:

◆ emit_result()

VSQLITE_DEPRECATED result_type sqlite::v2::query::emit_result ( )

executes the sql command (deprecated, prefer each())

Returns
result_type which is std::shared_ptr<result>

◆ get_result()

result_type sqlite::v2::query::get_result ( )

returns the results (needs a previous step_once() call)

Returns
result_type which is std::shared_ptr<result>

◆ step()

bool sqlite::v2::query::step ( )
private

◆ result

friend struct result
friend

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