Revision 258a530e
Added by David Sorber over 9 years ago
| software/sqlite_poc/DBManager.cc | ||
|---|---|---|
|
{
|
||
|
assert(false);
|
||
|
}
|
||
|
|
||
|
|
||
|
val = sqlite3_column_int64(stmt, idx);
|
||
|
}
|
||
|
|
||
| ... | ... | |
|
{
|
||
|
if (sqlite3_column_type(stmt, idx) != SQLITE_FLOAT)
|
||
|
{
|
||
|
assert(false);
|
||
|
assert(false);
|
||
|
}
|
||
|
|
||
|
val = sqlite3_column_double(stmt, idx);
|
||
|
|
||
|
val = sqlite3_column_double(stmt, idx);
|
||
|
}
|
||
|
|
||
|
// Helper function for string type
|
||
| ... | ... | |
|
}
|
||
|
}
|
||
|
|
||
|
DBManager::DBManager(const std::string& db_path)
|
||
|
// Helper function for bool type
|
||
|
void get_value(bool& val, int idx, sqlite3_stmt* stmt)
|
||
|
{
|
||
|
if (sqlite3_column_type(stmt, idx) == SQLITE_INTEGER)
|
||
|
{
|
||
|
val = (sqlite3_column_int(stmt, idx) == 1 ? true : false);
|
||
|
}
|
||
|
else if (sqlite3_column_type(stmt, idx) == SQLITE_NULL)
|
||
|
{
|
||
|
val = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
assert(false);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
DBManager::DBManager(const std::string& db_path)
|
||
|
{
|
||
|
|
||
|
int rc = sqlite3_open(db_path.c_str(), &this->db);
|
||
|
if (rc)
|
||
|
{
|
||
Adding a boolean helper function to my proof-of-concept.