Data Structures | Public Member Functions | Static Public Attributes | Friends
sqlite::Statement Class Reference

Sqlite statement wrapper. More...

#include <Statement.h>

Data Structures

class  BindWrap
class  BindWrap< double >
class  BindWrap< int >
class  BindWrap< int64_t >
class  BindWrap< std::string >
class  ColType
class  ColType< double >
class  ColType< int >
class  ColType< int64_t >
class  ColType< std::string >

Public Member Functions

 Statement ()
 Constructs empty statement calling anything on it will cause InvalidUseException.
 Statement (std::string const &sql, Database &db)
 Constructs statement.
virtual ~Statement ()
 Statement (Statement const &)
Statementoperator= (Statement const &)
 Statement (Statement &&other)
Statementoperator= (Statement &&other)
bool done ()
bool has_row ()
void step ()
 Step the statement as in get next row or execute insert, update etc.
void reset ()
 Reset the statement.
void finalize ()
 Finalizes the statement before destruction.
double val_double (int col_index)
int val_int (int col_index)
int64_t val_int64 (int col_index)
std::string val_string (int col_index)
void bind_double (int param_index, double value)
 Binds a value to prepared statement parameter.
void bind_int (int param_index, int value)
 Binds a value to prepared statement parameter.
void bind_int64 (int param_index, int64_t value)
 Binds a value to prepared statement parameter.
void bind_string (int param_index, std::string const &value)
 Binds a value to prepared statement parameter.
template<typename... Args>
std::tuple< Args...> get_row (ColType< Args >...types)
template<typename... Args>
std::vector< std::tuple< Args...> > get_remaining_rows (ColType< Args >...types)
template<typename... Args>
void bind (Args...values)
 Binds more values to parameters Starts with index 1.

Static Public Attributes

static ColType< int > colint
 Column type int.
static ColType< double > coldouble
 Column type double.
static ColType< int64_t > colint64
 Column type int64.
static ColType< std::string > colstring
 Column type string.

Friends

Statement::ColType< double > coldouble ()
Statement::ColType< int > colint ()
Statement::ColType< int64_t > colint64 ()
Statement::ColType< std::string > colstr ()

Detailed Description

Sqlite statement wrapper.

Finalizes statement on destruction.

Definition at line 26 of file Statement.h.


Constructor & Destructor Documentation

sqlite::Statement::Statement ( )

Constructs empty statement calling anything on it will cause InvalidUseException.

Definition at line 17 of file Statement.cpp.

sqlite::Statement::Statement ( std::string const &  sql,
Database db 
)

Constructs statement.

Also registers the constructed statement with the database connection.

Parameters:
sqlsql statement
dbdatabase connection

Definition at line 26 of file Statement.cpp.

sqlite::Statement::~Statement ( ) [virtual]

Definition at line 45 of file Statement.cpp.

sqlite::Statement::Statement ( Statement const &  )
sqlite::Statement::Statement ( Statement &&  other)

Definition at line 65 of file Statement.cpp.


Member Function Documentation

template<typename... Args>
void sqlite::Statement::bind ( Args...  values) [inline]

Binds more values to parameters Starts with index 1.

Parameters:
valuesvalues to bind

Definition at line 174 of file Statement.h.

void sqlite::Statement::bind_double ( int  param_index,
double  value 
)

Binds a value to prepared statement parameter.

Parameters:
param_index
value

Definition at line 173 of file Statement.cpp.

void sqlite::Statement::bind_int ( int  param_index,
int  value 
)

Binds a value to prepared statement parameter.

Parameters:
param_index
value

Definition at line 178 of file Statement.cpp.

void sqlite::Statement::bind_int64 ( int  param_index,
int64_t  value 
)

Binds a value to prepared statement parameter.

Parameters:
param_index
value

Definition at line 183 of file Statement.cpp.

void sqlite::Statement::bind_string ( int  param_index,
std::string const &  value 
)

Binds a value to prepared statement parameter.

Parameters:
param_index
value

Definition at line 188 of file Statement.cpp.

bool sqlite::Statement::done ( )
Returns:
whether the statement is done, as in all of it has been executed

Definition at line 72 of file Statement.cpp.

void sqlite::Statement::finalize ( )

Finalizes the statement before destruction.

No other function than finalize can be called on it after this.

Definition at line 223 of file Statement.cpp.

template<typename... Args>
std::vector<std::tuple<Args...> > sqlite::Statement::get_remaining_rows ( ColType< Args >...  types) [inline]
Parameters:
typesthe same as in get_row
Returns:
all remaining rows as tuples

Definition at line 157 of file Statement.h.

template<typename... Args>
std::tuple<Args...> sqlite::Statement::get_row ( ColType< Args >...  types) [inline]
Parameters:
typestypes of returned columns (see colint, coldouble, colint64, colstring)
Returns:
current row as tuple

Definition at line 147 of file Statement.h.

bool sqlite::Statement::has_row ( )
Returns:
whether row data can be queried using val_* functions

Definition at line 79 of file Statement.cpp.

Statement& sqlite::Statement::operator= ( Statement const &  )
Statement & sqlite::Statement::operator= ( Statement &&  other)

Definition at line 50 of file Statement.cpp.

void sqlite::Statement::reset ( )

Reset the statement.

Resets done and has_row flags. If it is a query stepping will result in rows being returned from beginning again. Otherwise it has no apparent reason to call this since step can be called again even without reset.

Definition at line 120 of file Statement.cpp.

void sqlite::Statement::step ( )

Step the statement as in get next row or execute insert, update etc.

Definition at line 86 of file Statement.cpp.

double sqlite::Statement::val_double ( int  col_index)
Parameters:
col_indexindex of retrieved column
Returns:
value of a column in current row as double

Definition at line 147 of file Statement.cpp.

int sqlite::Statement::val_int ( int  col_index)
Parameters:
col_indexindex of retrieved column
Returns:
value of a column in current row as int

Definition at line 159 of file Statement.cpp.

int64_t sqlite::Statement::val_int64 ( int  col_index)
Parameters:
col_indexindex of retrieved column
Returns:
value of a column in current row as 64 bit integer

Definition at line 153 of file Statement.cpp.

std::string sqlite::Statement::val_string ( int  col_index)
Parameters:
col_indexindex of retrieved column
Returns:
value of a column in current row as string

Definition at line 165 of file Statement.cpp.


Friends And Related Function Documentation

Statement::ColType<double> coldouble ( ) [friend]

Definition at line 193 of file Statement.cpp.

Statement::ColType<int> colint ( ) [friend]

Definition at line 198 of file Statement.cpp.

Statement::ColType<int64_t> colint64 ( ) [friend]

Definition at line 203 of file Statement.cpp.

Statement::ColType<std::string> colstr ( ) [friend]

Definition at line 208 of file Statement.cpp.


Field Documentation

ColType<double> sqlite::Statement::coldouble [static]

Column type double.

Definition at line 186 of file Statement.h.

ColType<int> sqlite::Statement::colint [static]

Column type int.

Definition at line 182 of file Statement.h.

ColType<int64_t> sqlite::Statement::colint64 [static]

Column type int64.

Definition at line 190 of file Statement.h.

ColType<std::string> sqlite::Statement::colstring [static]

Column type string.

Definition at line 194 of file Statement.h.


The documentation for this class was generated from the following files:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines