MIRA
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SQLiteCachedQuery Class Reference

A cached SQLite query object that supports serialization. More...

#include <database/SQLiteQuery.h>

Public Types

typedef std::vector< std::string > HeaderVector
 
typedef std::vector< std::vector< std::pair< int, std::string > > > ValueVector
 

Public Member Functions

template<typename Reflector >
void reflect (Reflector &r)
 Reflect method for serialization. More...
 
Constructors and destructor
 SQLiteCachedQuery ()
 Default constructor. More...
 
 SQLiteCachedQuery (SQLiteQuery &query)
 The copy constructor. More...
 
Query operations
bool eof () const
 Return if the query contains data. More...
 
int getColumnCount () const
 Return the column count of the query. More...
 
std::string getName (std::size_t column)
 Returns the name of a given column. More...
 
template<typename T >
getValue (std::size_t column)
 Returns a typecasted value for a given column in the current row. More...
 
template<typename T >
getValue (std::size_t column, const T &defaultValue)
 Returns a typecasted value for a given column in the current row. More...
 
int getDataType (std::size_t column)
 Get the data type of a given column in the current row. More...
 
bool isNull (std::size_t column)
 Return if a entry in a given column is NULL. More...
 
void next ()
 Advance to next row. More...
 
SQLiteCachedQueryoperator++ ()
 Preincrement operator. More...
 
ValueVector getValues () const
 Return the cached values. More...
 

Protected Member Functions

void validate ()
 
void validate (std::size_t column)
 

Protected Attributes

HeaderVector mHeader
 
ValueVector mCache
 
std::size_t mCurrent
 

Detailed Description

A cached SQLite query object that supports serialization.

Can be used to store a database query in a log file or for for RPC database query.

Member Typedef Documentation

◆ HeaderVector

typedef std::vector<std::string> HeaderVector

◆ ValueVector

typedef std::vector<std::vector<std::pair<int, std::string> > > ValueVector

Constructor & Destructor Documentation

◆ SQLiteCachedQuery() [1/2]

Default constructor.

◆ SQLiteCachedQuery() [2/2]

The copy constructor.

Member Function Documentation

◆ eof()

bool eof ( ) const
inline

Return if the query contains data.

Returns
True if there is no data in the query, false otherwise.

◆ getColumnCount()

int getColumnCount ( ) const
inline

Return the column count of the query.

Returns
The number of columns.

◆ getName()

std::string getName ( std::size_t  column)
inline

Returns the name of a given column.

Parameters
[in]columnThe column
Returns
The column name

◆ getValue() [1/2]

T getValue ( std::size_t  column)
inline

Returns a typecasted value for a given column in the current row.

Exceptions
XBadCastif the element in the data field is NULL.
Parameters
[in]columnThe column to be returned.
Returns
The casted value.

◆ getValue() [2/2]

T getValue ( std::size_t  column,
const T &  defaultValue 
)
inline

Returns a typecasted value for a given column in the current row.

If this value is NULL a default value is returned.

Parameters
[in]columnThe column to be returned.
[in]defaultValueThe default value that is returned if the cast fails.
Returns
The casted value.

◆ getDataType()

int getDataType ( std::size_t  column)

Get the data type of a given column in the current row.

Could be one of the following: SQLITE_INTEGER = int SQLITE_FLOAT = float SQLITE_TEXT = string SQLITE_BLOB = string SQLITE_NULL = NULL

Returns
Datatype

◆ isNull()

bool isNull ( std::size_t  column)

Return if a entry in a given column is NULL.

Returns
True if value is NULL, false otherwise.

◆ next()

void next ( )
inline

Advance to next row.

/code while (!query.eof()) { ... query.next(); } /endcode

◆ operator++()

SQLiteCachedQuery& operator++ ( )
inline

Preincrement operator.

Same as next().

◆ getValues()

ValueVector getValues ( ) const
inline

Return the cached values.

Returns
The cached values.

◆ reflect()

void reflect ( Reflector &  r)
inline

Reflect method for serialization.

◆ validate() [1/2]

void validate ( )
inlineprotected

◆ validate() [2/2]

void validate ( std::size_t  column)
inlineprotected

Member Data Documentation

◆ mHeader

HeaderVector mHeader
protected

◆ mCache

ValueVector mCache
protected

◆ mCurrent

std::size_t mCurrent
protected

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