Update SQLite Wrapper

Remove debug outputs.
Add Error Message handling interfaces.
Add namespace (MiniEngine::SQL).
This commit is contained in:
Kirigaya Kazuto 2017-04-16 18:15:17 +08:00
parent 92f2d9b4af
commit 9ac5f9833a
2 changed files with 32 additions and 4 deletions

View File

@ -2,6 +2,12 @@
#include <cstring>
#include <cstdio>
namespace MiniEngine
{
namespace SQL
{
// private
void SQLStatement::_set(sqlite3_stmt* p)
{
@ -65,8 +71,19 @@ int SQLDB::step(const SQLStatement& Statement)
int SQLDB::exec(const std::string& SQLCommand,SQLCallback callback,void* param)
{
char* errmsg=nullptr;
int ret=sqlite3_exec(_get(),SQLCommand.c_str(),callback,param,&errmsg);
printf("ErrMsg: %s\n",errmsg);
return ret;
return sqlite3_exec(_get(),SQLCommand.c_str(),callback,param,&_errmsg);
}
const char* SQLDB::getErrorMsg()
{
return _errmsg;
}
void SQLDB::clearError()
{
_errmsg=nullptr;
}
}/// End of namespace MiniEngine::SQL
}/// End of namespace MiniEngine

View File

@ -3,6 +3,12 @@
#include <string>
#include <memory>
namespace MiniEngine
{
namespace SQL
{
class SQLStatement
{
public:
@ -32,10 +38,15 @@ public:
SQLStatement prepare(const std::string& SQLCommand);
int step(const SQLStatement& Statement);
int exec(const std::string& SQLCommand,SQLCallback callback,void* param);
const char* getErrorMsg();
void clearError();
private:
sqlite3* _get();
void _set(sqlite3*);
std::shared_ptr<sqlite3> _db;
char* _errmsg;
};
}/// End of namespace MiniEngine::SQL
}/// End of namespace MiniEngine