47 #ifndef _MIRA_SQLITEQUERY_H_ 48 #define _MIRA_SQLITEQUERY_H_ 51 #include <serialization/adapters/std/pair> 52 #include <serialization/adapters/std/vector> 81 SQLiteQuery(sqlite3* db, sqlite3_stmt* statement,
bool more);
103 return mStatement != NULL;
112 return mMore ==
false;
129 std::string
getName(std::size_t column);
140 const char* data = getTxtValue(column);
142 MIRA_THROW(XBadCast,
"Value of column '" << column <<
"' is NULL");
143 return fromString<T>(data);
154 T
getValue(std::size_t column,
const T& defaultValue)
156 const char* data = getTxtValue(column);
159 return fromString<T>(data);
180 bool isNull(std::size_t column);
205 const char* getTxtValue(std::size_t column);
208 sqlite3_stmt* mStatement;
226 typedef std::vector<std::vector<std::pair<int, std::string>>>
ValueVector;
270 MIRA_THROW(XAccessViolation,
"Column " << column <<
" does not exist");
285 MIRA_THROW(XBadCast,
"Value of column '" << column <<
"' is NULL");
297 T
getValue(std::size_t column,
const T& defaultValue)
327 bool isNull(std::size_t column);
368 template<
typename Reflector>
371 r.member(
"Header",
mHeader,
"The header of the query");
372 r.member(
"Values",
mCache,
"The values of the query");
380 MIRA_THROW(XAccessViolation,
"Access to invalid query object.");
387 MIRA_THROW(XAccessViolation,
"Column " << column <<
" does not exist");
void next()
Advance to next row.
Definition: SQLiteQuery.h:340
ValueVector mCache
Definition: SQLiteQuery.h:391
void validate()
Definition: SQLiteQuery.h:377
std::size_t mCurrent
Definition: SQLiteQuery.h:392
A cached SQLite query object that supports serialization.
Definition: SQLiteQuery.h:222
SQLiteQuery()
Default-constructed query will be invalid.
std::vector< std::string > HeaderVector
Definition: SQLiteQuery.h:225
std::vector< std::vector< std::pair< int, std::string > > > ValueVector
Definition: SQLiteQuery.h:226
int getColumnCount() const
Return the column count of the query.
Definition: SQLiteQuery.h:257
HeaderVector mHeader
Definition: SQLiteQuery.h:390
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
Contains toString and fromString functions for converting data types to strings and the other way rou...
bool isNull(std::size_t column)
Return if a entry in a given column is NULL.
SQLiteQuery & operator++()
Preincrement operator.
Definition: SQLiteQuery.h:198
T getValue(std::size_t column)
Return a typecasted value for a given column in the current row.
Definition: SQLiteQuery.h:138
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:78
T getValue(std::size_t column)
Returns a typecasted value for a given column in the current row.
Definition: SQLiteQuery.h:282
std::string getName(std::size_t column)
Returns the name of a given column.
Definition: SQLiteQuery.h:267
bool eof() const
Return if the query contains data.
Definition: SQLiteQuery.h:248
void validate(std::size_t column)
Definition: SQLiteQuery.h:383
int getDataType(std::size_t column)
Get the data type of a given column in the current row.
bool eof() const
Return if the query contains data.
Definition: SQLiteQuery.h:110
SQLiteQuery & operator=(const SQLiteQuery &other)=delete
void next()
Advance to next row.
int getColumnCount() const
Return the column count of the query.
Definition: SQLiteQuery.h:119
~SQLiteQuery()
The destructor.
T getValue(std::size_t column, const T &defaultValue)
Returns a typecasted value for a given column in the current row.
Definition: SQLiteQuery.h:297
void reflect(Reflector &r)
Reflect method for serialization.
Definition: SQLiteQuery.h:369
int getDataType(std::size_t column)
Get the data type of a given column in the current row.
T getValue(std::size_t column, const T &defaultValue)
Return a typecasted value for a given column in the current row.
Definition: SQLiteQuery.h:154
ValueVector getValues() const
Return the cached values.
Definition: SQLiteQuery.h:359
SQLiteCachedQuery & operator++()
Preincrement operator.
Definition: SQLiteQuery.h:349
SQLiteCachedQuery()
Default constructor.
bool isNull(std::size_t column)
Return if a entry in a given column is NULL.
Class representing a result of a SQLite database query.
Definition: SQLiteQuery.h:66
std::string getName(std::size_t column)
Return the name of a given column.
bool valid() const
SQLiteQuery is valid if statement is not null.
Definition: SQLiteQuery.h:101