From 31dbcda9ad7a1151f01e802a470683bb39be7571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rombauts?= Date: Sun, 3 May 2015 20:23:59 +0200 Subject: [PATCH] Minor fixes to comments and an API --- include/SQLiteCpp/Column.h | 2 +- include/SQLiteCpp/Database.h | 10 ++++++++-- src/Database.cpp | 12 +----------- src/Transaction.cpp | 2 +- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/include/SQLiteCpp/Column.h b/include/SQLiteCpp/Column.h index 0364d4f..1679dbc 100644 --- a/include/SQLiteCpp/Column.h +++ b/include/SQLiteCpp/Column.h @@ -62,7 +62,7 @@ public: // they copy the Statement::Ptr which in turn increments the reference counter. /** - * @brief Return a pointer to the named assigned to a result column (potentially aliased) + * @brief Return a pointer to the named assigned to this result column (potentially aliased) * * @see getOriginName() to get original column name (not aliased) */ diff --git a/include/SQLiteCpp/Database.h b/include/SQLiteCpp/Database.h index 39ae312..5eb5154 100644 --- a/include/SQLiteCpp/Database.h +++ b/include/SQLiteCpp/Database.h @@ -102,7 +102,7 @@ public: * * @throw SQLite::Exception in case of error */ - void setBusyTimeout(int aTimeoutMs) noexcept; // nothrow + void setBusyTimeout(const int aTimeoutMs) noexcept; // nothrow /** * @brief Shortcut to execute one or multiple statements without results. @@ -337,7 +337,13 @@ private: /** * @brief Check if aRet equal SQLITE_OK, else throw a SQLite::Exception with the SQLite error message */ - void check(const int aRet) const; + inline void Database::check(const int aRet) const + { + if (SQLITE_OK != aRet) + { + throw SQLite::Exception(sqlite3_errmsg(mpSQLite)); + } + } private: sqlite3* mpSQLite; //!< Pointer to SQLite Database Connection Handle diff --git a/src/Database.cpp b/src/Database.cpp index ba5e355..649d49e 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -74,7 +74,7 @@ Database::~Database() noexcept // nothrow * * @throw SQLite::Exception in case of error */ -void Database::setBusyTimeout(int aTimeoutMs) noexcept // nothrow +void Database::setBusyTimeout(const int aTimeoutMs) noexcept // nothrow { const int ret = sqlite3_busy_timeout(mpSQLite, aTimeoutMs); check(ret); @@ -113,15 +113,6 @@ bool Database::tableExists(const char* apTableName) return (1 == Nb); } -// Check if aRet equal SQLITE_OK, else throw a SQLite::Exception with the SQLite error message -void Database::check(const int aRet) const -{ - if (SQLITE_OK != aRet) - { - throw SQLite::Exception(sqlite3_errmsg(mpSQLite)); - } -} - // Attach a custom function to your sqlite database. Assumes UTF8 text representation. // Parameter details can be found here: http://www.sqlite.org/c3ref/create_function.html void Database::createFunction(const char* apFuncName, @@ -140,7 +131,6 @@ void Database::createFunction(const char* apFuncName, } const int ret = sqlite3_create_function_v2(mpSQLite, apFuncName, aNbArg, TextRep, apApp, apFunc, apStep, apFinal, apDestroy); - check(ret); } diff --git a/src/Transaction.cpp b/src/Transaction.cpp index 5971d97..d486f3b 100644 --- a/src/Transaction.cpp +++ b/src/Transaction.cpp @@ -53,7 +53,7 @@ void Transaction::commit() } else { - throw SQLite::Exception("Transaction already commited"); + throw SQLite::Exception("Transaction already commited."); } }