libsl3 1.2.41002
A C++ interface for SQLite
|
A compiled SQL command. More...
#include <sl3/command.hpp>
Public Types | |
using | Callback = std::function< bool(Columns)> |
function object for handling a command result. | |
Public Member Functions | |
Command (Command &&) | |
Move constructor. | |
~Command () | |
Destructor. | |
Dataset | select () |
Run the Command and get the result. | |
Dataset | select (const DbValues ¶meters, const Types &types={}) |
Run the Command and get the result. | |
Dataset | select (const Types &types, const DbValues ¶meters={}) |
Run the Command and get the result. | |
void | execute () |
Execute the command. | |
void | execute (const DbValues ¶meters) |
Execute the command. | |
void | execute (RowCallback &cb, const DbValues ¶meters={}) |
Execute the command applying given callback. | |
void | execute (Callback cb, const DbValues ¶meters={}) |
Execute the command applying given callback. | |
DbValues & | getParameters () |
Parameters of command. | |
const DbValues & | getParameters () const |
Parameters of command. | |
DbValue & | getParameter (int idx) |
get Parameter at given index. | |
const DbValue & | getParameter (int idx) const |
get Parameter at given index. | |
void | setParameters (const DbValues &values) |
Set parameter values. | |
void | resetParameters (DbValues values) |
Set new parameter values. | |
std::vector< std::string > | getParameterNames () const |
get a list of the parameter names | |
A compiled SQL command.
This class holds a compiled SQL statement so that it can be reused.
A command can have parameters.
using sl3::Command::Callback = std::function<bool (Columns)> |
function object for handling a command result.
Functor called for each processed row of Command or a sql statement.
sl3::Command::Command | ( | Command && | ) |
Move constructor.
A command is movable
sl3::Command::~Command | ( | ) |
Destructor.
The destructor calls release.
void sl3::Command::execute | ( | ) |
Execute the command.
Runs the current command. If parameters are set,
Execute the command applying given callback.
Applies given parameters and run the current command.
sl3::ErrTypeMisMatch | given parameters are of the wrong size. |
cb | a callback |
parameters | a list of parameters |
void sl3::Command::execute | ( | const DbValues & | parameters | ) |
Execute the command.
Applies given parameters and run the current command.
sl3::ErrTypeMisMatch | given parameters are of the wrong size. |
parameters | a list of parameters |
void sl3::Command::execute | ( | RowCallback & | cb, |
const DbValues & | parameters = {} |
||
) |
Execute the command applying given callback.
Applies given parameters and run the current command.
sl3::ErrTypeMisMatch | given parameters are of the wrong size. |
cb | a callback |
parameters | a list of parameters |
DbValue & sl3::Command::getParameter | ( | int | idx | ) |
get Parameter at given index.
idx | index |
sl3::ErrOutOfRange | if index is invalid |
const DbValue & sl3::Command::getParameter | ( | int | idx | ) | const |
get Parameter at given index.
idx | index |
sl3::ErrOutOfRange | if index is invalid |
std::vector< std::string > sl3::Command::getParameterNames | ( | ) | const |
get a list of the parameter names
If the command has no parameters, the list will be empty. Parameters with no name will be an empty entry in the list.
DbValues & sl3::Command::getParameters | ( | ) |
Parameters of command.
const DbValues & sl3::Command::getParameters | ( | ) | const |
Parameters of command.
void sl3::Command::resetParameters | ( | DbValues | values | ) |
Set new parameter values.
In contrast to setParameters, where the DbValue types must match, this can be used to set other Types.
values | new parameter values |
sl3::ErrTypeMisMatch | if size of values differs from the actual one |
Dataset sl3::Command::select | ( | ) |
Run the Command and get the result.
Runs the command, applying given parameters and returns the result in a Dataset. It types are given, they are used for the returned Dataset. It no types are given all fields in the returned Dataset will be of Type::Variant
sl3::ErrTypeMisMatch | if types are given which are invalid or given parameters are of the wrong size. |
Run the Command and get the result.
Runs the command, applying possible given parameters and returns the result in a Dataset in which given types are used for the fields.
sl3::ErrTypeMisMatch | if types are given which are invalid or given parameters are of the wrong size. |
void sl3::Command::setParameters | ( | const DbValues & | values | ) |
Set parameter values.
The Types ot the given values must be compatible with the current ones.
values | new paramter values |
sl3::ErrTypeMisMatch | if size of values differs from the actual parameter size or DbValue assignment throws. |