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

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

#include <HFSQtLi.h>

Public Member Functions

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

Protected Member Functions

constexpr CustomFetch (Query *query, bool strict, int base)
 

Protected Attributes

Query * m_query
 
bool m_strict
 
int m_base
 
int m_fetched
 

Friends

class Query
 

Detailed Description

Accessor passed to custom data type fetch An instance of this class will be passed as first parameter to customFetch 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 customFetch(CustomFetch &fetch, MyType &val)
{
fetch.fetch(val.a, val.b);
}
...
MyType x;
db->executeSingleAll<2>("SELECT $1, $2", 3, "Hello, world!", x);
qDebug()<<x.a<<x.b; // Prints 1 "Hello, world"
...
int fetch(T &&...value)
Fetches some values This function is roughly equivalent to calling Query::column. It will fetchone or...
Definition: HFSQtLi.h:345

Member Function Documentation

◆ fetch()

template<class ... T>
int HFSQtLi::CustomFetch::fetch ( T &&...  value)
inline

Fetches some values This function is roughly equivalent to calling Query::column. It will fetchone or more values. Note that the function will start fetch from the column following the last fetched column. E.g. in:

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

◆ fetchIndex()

template<class ... T>
int HFSQtLi::CustomFetch::fetchIndex ( bool  strict,
int  i,
T &&...  value 
)
inline

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

... qry.bind(4, 3, MyCustomType);
void customBindConst(CustomBind &bind, const MyCustomType &val)
{
int x, y;
fetch.fetchIndex(1. y); // This will fetch 4th column
fetch.fetchIndex(0, x); // This will fetch 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

◆ numFetched()

constexpr int HFSQtLi::CustomFetch::numFetched ( )
inlineconstexpr

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

Returns
The number of columns fetched so far, or -1 if any error occoured in a fetch

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