HFSQtLi 0.0.1
A Qt/C++ wrapper for SQLite3.
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
HFSQtLi::CustomBind Class Reference

Accessor passed to custom data type bind An instance of this class will be passed as first parameter to customBind and customBindConst functions (See Custom data types). More...

#include <HFSQtLi.h>

Public Member Functions

template<class ... T>
int bind (T &&...value)
 Binds some values This function is roughly equivalent to calling Query::bind. It will bind one or more values. Note that the function will start binding from the column following the last bound column. E.g. in: More...
 
template<class ... T>
int bindIndex (int i, T &&...value)
 Binds some values This function is roughly equivalent to calling Query::bind. It will bind one or more values. Note that the function will start binding from the column following the last column bind by the query. E.g. in: More...
 
constexpr int numBound ()
 Gets the number of bound columns so far by this custom accessor. Number of bound column is defined as the maximum column index bound minus the first column index associated with the accessor plus one. If no column has yet be bound returns 0. More...
 

Protected Member Functions

constexpr CustomBind (Query *query, int base)
 

Protected Attributes

Query * m_query
 
int m_base
 
int m_bound
 

Friends

class Query
 

Detailed Description

Accessor passed to custom data type bind An instance of this class will be passed as first parameter to customBind and customBindConst functions (See Custom data types).

The function will be able to use it to bind the columns with value from the object given as second parameter.

Example usage:

struct MyType
{
int a;
QString b;
};
void customBindConst(CustomBind &bind, const MyType &val)
{
bind.bind(val.a, val.b);
}
...
int x;
QString y;
db->executeSingleAll<1>("SELECT $1, $2", MyType{1, "Hello, world"}, x, y);
qDebug()<<x<<y; // Prints 1 "Hello, world"
...
int bind(T &&...value)
Binds some values This function is roughly equivalent to calling Query::bind. It will bind one or mor...
Definition: HFSQtLi.h:262

Member Function Documentation

◆ bind()

template<class ... T>
int HFSQtLi::CustomBind::bind ( T &&...  value)
inline

Binds some values This function is roughly equivalent to calling Query::bind. It will bind one or more values. Note that the function will start binding from the column following the last bound column. E.g. in:

... qry.bind(4, 3, MyCustomType);
void customBindConst(CustomBind &bind, const MyCustomType &val)
{
bind.bind(12); // This will bind 3rd column
bind.bind("Hello"); // This will bind 4th column
}
Parameters
valueIs a list of objects to bind
Returns
0 on error, 1+number of bounded columns on failure

◆ bindIndex()

template<class ... T>
int HFSQtLi::CustomBind::bindIndex ( int  i,
T &&...  value 
)
inline

Binds some values This function is roughly equivalent to calling Query::bind. It will bind one or more values. Note that the function will start binding from the column following the last column bind by the query. E.g. in:

... qry.bind(4, 3, MyCustomType);
void customBindConst(CustomBind &bind, const MyCustomType &val)
{
bind.bindIndex(2. "Hello"); // This will bind 4th column
bind.bindIndex(1, 12); // This will bind 3rd column
}
Parameters
i1-based index of first column to bind. Note that the 0 column is the one currently binding
valueIs a list of objects to bind
Returns
0 on error, 1+number of bounded columns on failure

◆ numBound()

constexpr int HFSQtLi::CustomBind::numBound ( )
inlineconstexpr

Gets the number of bound columns so far by this custom accessor. Number of bound column is defined as the maximum column index bound minus the first column index associated with the accessor plus one. If no column has yet be bound returns 0.

Returns
The number of columns bound so far, or -1 if any error occoured in one of the binds

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