Cleanup on PR #142 : remove whitespaces and mutualize some code

This commit is contained in:
Sébastien Rombauts 2017-08-28 16:00:50 +02:00
parent f4947e7a03
commit 94c7897d1b
2 changed files with 9 additions and 12 deletions

View File

@ -75,11 +75,10 @@ public:
/// Finalize and unregister the SQL query from the SQLite Database Connection.
~Statement();
/// Reset the statement to make it ready for a new execution.
/// Reset the statement to make it ready for a new execution. Throws an exception on error.
void reset();
/// Reset the statement to make it ready for a new execution. Returns the sqlite result code
/// instead of throwing an exception on error.
/// Reset the statement. Returns the sqlite result code instead of throwing an exception on error.
int tryReset() noexcept;
/**

View File

@ -52,9 +52,7 @@ Statement::~Statement()
// Reset the statement to make it ready for a new execution (see also #clearBindings() bellow)
void Statement::reset()
{
mbOk = false;
mbDone = false;
const int ret = sqlite3_reset(mStmtPtr);
const int ret = tryReset();
check(ret);
}
@ -62,8 +60,7 @@ int Statement::tryReset() noexcept
{
mbOk = false;
mbDone = false;
const int ret = sqlite3_reset(mStmtPtr);
return ret;
return sqlite3_reset(mStmtPtr);
}
// Clears away all the bindings of a prepared statement (can be associated with #reset() above).
@ -274,7 +271,8 @@ bool Statement::executeStep()
return mbOk; // true only if one row is accessible by getColumn(N)
}
int Statement::tryExecuteStep() noexcept {
int Statement::tryExecuteStep() noexcept
{
const int ret = sqlite3_step(mStmtPtr);
if (SQLITE_ROW == ret) // one row is ready : call getColumn(N) to access it
{