VSQLite++  0.3
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
sqlite::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::command:
Inheritance graph
Collaboration diagram for sqlite::command:
Collaboration graph

Public Member Functions

 command (connection &con, std::string const &sql)
 command constructor More...
 
virtual ~command ()
 command destructor More...
 
void clear ()
 clear is used if you'd like to reuse a command object More...
 
bool emit ()
 emit executes the sql command If you have used placeholders you must have replaced all placeholders More...
 
bool operator() ()
 works exactly like the method command::emit More...
 
void bind (int idx)
 binds NULL to the given 1 based index More...
 
void bind (int idx, int v)
 binds the 32-Bit integer v to the given 1 based index More...
 
void bind (int idx, boost::int64_t v)
 binds the 64-Bit integer v to the given 1 based index More...
 
void bind (int idx, double v)
 binds the double v to the given 1 based index More...
 
void bind (int idx, std::string const &v)
 binds the text/string v to the given 1 based index More...
 
void bind (int idx, void const *buf, size_t buf_size)
 binds the binary/blob buf to the given 1 based index More...
 
void bind (int idx, std::vector< unsigned char > const &v)
 binds the binary/blob v to the given 1 based index More...
 
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 More...
 
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 More...
 
commandoperator% (boost::int64_t p)
 replacement for void command::bind(int idx,boost::int64_t); Indexes are given automatically first call uses 1 as index, second 2 and so on More...
 
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 More...
 
commandoperator% (std::string const &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 More...
 
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 More...
 

Protected Member Functions

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

Protected Attributes

sqlite3_stmt * stmt
 

Private Member Functions

void prepare ()
 
void finalize ()
 

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 57 of file command.hpp.

Constructor & Destructor Documentation

◆ command()

sqlite::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

◆ ~command()

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

command destructor

Member Function Documentation

◆ access_check()

void sqlite::command::access_check ( )
protected

◆ bind() [1/7]

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

binds NULL to the given 1 based index

◆ bind() [2/7]

void sqlite::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() [3/7]

void sqlite::command::bind ( int  idx,
boost::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() [4/7]

void sqlite::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() [5/7]

void sqlite::command::bind ( int  idx,
std::string const &  v 
)

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

◆ bind() [6/7]

void sqlite::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() [7/7]

void sqlite::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 &

◆ clear()

void sqlite::command::clear ( )

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

◆ emit()

bool sqlite::command::emit ( )

emit executes the sql command If you have used placeholders you must have replaced all placeholders

◆ finalize()

void sqlite::command::finalize ( )
private

◆ get_handle()

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

◆ operator%() [1/6]

command& sqlite::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

◆ operator%() [2/6]

command& sqlite::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

◆ operator%() [3/6]

command& sqlite::command::operator% ( boost::int64_t  p)

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

Parameters
pshould be a 64-Bit integer

◆ operator%() [4/6]

command& sqlite::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

◆ operator%() [5/6]

command& sqlite::command::operator% ( std::string const &  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

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

◆ operator%() [6/6]

command& sqlite::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)

◆ operator()()

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

works exactly like the method command::emit

◆ prepare()

void sqlite::command::prepare ( )
private

◆ step()

bool sqlite::command::step ( )
protected

Member Data Documentation

◆ last_arg_idx

int sqlite::command::last_arg_idx
private

Definition at line 189 of file command.hpp.

◆ m_con

connection& sqlite::command::m_con
private

Definition at line 184 of file command.hpp.

◆ m_sql

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

Definition at line 185 of file command.hpp.

◆ stmt

sqlite3_stmt* sqlite::command::stmt
protected

Definition at line 187 of file command.hpp.


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