Class representing a result of a SQLite database query.
More...
#include <database/SQLiteQuery.h>
|
| 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 > |
| T | getValue (std::size_t column) |
| | Return a typecasted value for a given column in the current row. More...
|
| |
| template<typename T > |
| 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...
|
| |
| SQLiteQuery & | operator++ () |
| | Preincrement operator. More...
|
| |
Class representing a result of a SQLite database query.
◆ 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] | db | The database pointer |
| [in] | statement | The statement pointer |
| [in] | more | Does the query contain data |
◆ SQLiteQuery() [3/4]
◆ SQLiteQuery() [4/4]
◆ ~SQLiteQuery()
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ valid()
◆ eof()
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
-
- 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
-
| XBadCast | if the element in the data field is NULL. |
- Parameters
-
| [in] | column | The 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] | column | The column to be returned. |
| [in] | defaultValue | The 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] | column | The 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] | column | The column to check for NULL type |
- Returns
- True if value is NULL, false otherwise.
◆ next()
Advance to next row.
/code while (!query.eof()) { ... query.next(); } /endcode
◆ operator++()
Preincrement operator.
Same as next().
The documentation for this class was generated from the following file: