develop #15
@ -23,7 +23,7 @@ obelisk::KnowledgeBase::KnowledgeBase(const char* filename, int flags)
|
|||||||
auto result = sqlite3_open_v2(filename, &dbConnection_, flags, NULL);
|
auto result = sqlite3_open_v2(filename, &dbConnection_, flags, NULL);
|
||||||
if (result != SQLITE_OK)
|
if (result != SQLITE_OK)
|
||||||
{
|
{
|
||||||
logSqliteError(result);
|
throw new KnowledgeBaseException("database could not be opened");
|
||||||
}
|
}
|
||||||
|
|
||||||
enableForeignKeys();
|
enableForeignKeys();
|
||||||
@ -63,7 +63,6 @@ void obelisk::KnowledgeBase::enableForeignKeys()
|
|||||||
&errmsg);
|
&errmsg);
|
||||||
if (result != SQLITE_OK)
|
if (result != SQLITE_OK)
|
||||||
{
|
{
|
||||||
logSqliteError(result);
|
|
||||||
if (errmsg)
|
if (errmsg)
|
||||||
{
|
{
|
||||||
throw obelisk::KnowledgeBaseException(errmsg);
|
throw obelisk::KnowledgeBaseException(errmsg);
|
||||||
@ -81,7 +80,6 @@ void obelisk::KnowledgeBase::createTable(std::function<const char*()> function)
|
|||||||
int result = sqlite3_exec(dbConnection_, function(), NULL, NULL, &errmsg);
|
int result = sqlite3_exec(dbConnection_, function(), NULL, NULL, &errmsg);
|
||||||
if (result != SQLITE_OK)
|
if (result != SQLITE_OK)
|
||||||
{
|
{
|
||||||
logSqliteError(result);
|
|
||||||
if (errmsg)
|
if (errmsg)
|
||||||
{
|
{
|
||||||
throw obelisk::KnowledgeBaseException(errmsg);
|
throw obelisk::KnowledgeBaseException(errmsg);
|
||||||
@ -171,12 +169,6 @@ void obelisk::KnowledgeBase::getFact(obelisk::Fact& fact)
|
|||||||
fact.selectFact(dbConnection_);
|
fact.selectFact(dbConnection_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: log files? or just throw an error?
|
|
||||||
void obelisk::KnowledgeBase::logSqliteError(int result)
|
|
||||||
{
|
|
||||||
std::cout << sqlite3_errstr(result) << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void obelisk::KnowledgeBase::getFloat(float& result1,
|
void obelisk::KnowledgeBase::getFloat(float& result1,
|
||||||
float& result2,
|
float& result2,
|
||||||
double var)
|
double var)
|
||||||
|
@ -22,7 +22,6 @@ namespace obelisk
|
|||||||
const char* filename_;
|
const char* filename_;
|
||||||
sqlite3* dbConnection_ = nullptr;
|
sqlite3* dbConnection_ = nullptr;
|
||||||
int flags_;
|
int flags_;
|
||||||
void logSqliteError(int result);
|
|
||||||
|
|
||||||
void enableForeignKeys();
|
void enableForeignKeys();
|
||||||
void createTable(std::function<const char*()> function);
|
void createTable(std::function<const char*()> function);
|
||||||
|
Loading…
Reference in New Issue
Block a user