diff --git a/sqlite_wrapper.cpp b/sqlite_wrapper.cpp index e8822ad..7133c3a 100644 --- a/sqlite_wrapper.cpp +++ b/sqlite_wrapper.cpp @@ -2,6 +2,12 @@ #include #include +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 diff --git a/sqlite_wrapper.h b/sqlite_wrapper.h index 9364192..9102fa6 100644 --- a/sqlite_wrapper.h +++ b/sqlite_wrapper.h @@ -3,6 +3,12 @@ #include #include +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 _db; + char* _errmsg; }; +}/// End of namespace MiniEngine::SQL +}/// End of namespace MiniEngine