MIRA
List of all members
SQLiteQuery Class Reference

Class representing a result of a SQLite database query. More...

#include <database/SQLiteQuery.h>

Public Member Functions

Constructors and destructor
 SQLiteQuery ()
 Default-constructed query will be invalid. More...
 
 SQLiteQuery (sqlite3 *db, sqlite3_stmt *statement, bool more)
 Constructs a query object given a database and a statement. More...
 
 SQLiteQuery (const SQLiteQuery &other)=delete
 
SQLiteQueryoperator= (const SQLiteQuery &other)=delete
 
 SQLiteQuery (SQLiteQuery &&other) noexcept
 
SQLiteQueryoperator= (SQLiteQuery &&other) noexcept
 
 ~SQLiteQuery ()
 The destructor. More...
 

Query operations

bool valid () const
 SQLiteQuery is valid if statement is not null. More...
 
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)
 Return the name of a given column. More...
 
template<typename T >
getValue (std::size_t column)
 Return a typecasted value for a given column in the current row. More...
 
template<typename T >
getValue (std::size_t column, const T &defaultValue)
 Return 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...
 
SQLiteQueryoperator++ ()
 Preincrement operator. More...
 

Detailed Description

Class representing a result of a SQLite database query.

Constructor & Destructor Documentation

◆ SQLiteQuery() [1/4]

Default-constructed query will be invalid.

◆ SQLiteQuery() [2/4]

SQLiteQuery ( sqlite3 *  db,
sqlite3_stmt *  statement,
bool  more 
)

Constructs a query object given a database and a statement.

Parameters
[in]dbThe database pointer
[in]statementThe statement pointer
[in]moreDoes the query contain data

◆ SQLiteQuery() [3/4]

SQLiteQuery ( const SQLiteQuery other)
delete

◆ SQLiteQuery() [4/4]

SQLiteQuery ( SQLiteQuery &&  other)
noexcept

◆ ~SQLiteQuery()

The destructor.

Member Function Documentation

◆ operator=() [1/2]

SQLiteQuery& operator= ( const SQLiteQuery other)
delete

◆ operator=() [2/2]

SQLiteQuery& operator= ( SQLiteQuery &&  other)
noexcept

◆ valid()

bool valid ( ) const
inline

SQLiteQuery is valid if statement is not null.

◆ 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)

Return the name of a given column.

Parameters
[in]columnThe column.
Returns
The column name.

◆ getValue() [1/2]

T getValue ( std::size_t  column)
inline

Return 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

Return 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

Parameters
[in]columnThe column to get the datatype from
Returns
Datatype.

◆ isNull()

bool isNull ( std::size_t  column)

Return if a entry in a given column is NULL.

Parameters
[in]columnThe column to check for NULL type
Returns
True if value is NULL, false otherwise.

◆ next()

void next ( )

Advance to next row.

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

◆ operator++()

SQLiteQuery& operator++ ( )
inline

Preincrement operator.

Same as next().


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