Set Statement move constractor to default; fix #347

This commit is contained in:
Kacperos155 2022-01-25 20:32:40 +01:00
parent 6da299db12
commit 2800b65ac6
3 changed files with 5 additions and 18 deletions

View File

@ -54,7 +54,7 @@ public:
* @param[in] aStmtPtr Shared pointer to the prepared SQLite Statement Object. * @param[in] aStmtPtr Shared pointer to the prepared SQLite Statement Object.
* @param[in] aIndex Index of the column in the row of result, starting at 0 * @param[in] aIndex Index of the column in the row of result, starting at 0
*/ */
Column(Statement::TStatementPtr& aStmtPtr, int aIndex) noexcept; explicit Column(Statement::TStatementPtr& aStmtPtr, int aIndex) noexcept;
// default destructor: the finalization will be done by the destructor of the last shared pointer // default destructor: the finalization will be done by the destructor of the last shared pointer
// default copy constructor and assignment operator are perfectly suited : // default copy constructor and assignment operator are perfectly suited :
@ -246,7 +246,7 @@ public:
* *
* @see getString * @see getString
*/ */
operator std::string() const explicit operator std::string() const
{ {
return getString(); return getString();
} }

View File

@ -79,7 +79,8 @@ public:
* *
* @param[in] aStatement Statement to move * @param[in] aStatement Statement to move
*/ */
Statement(Statement&& aStatement) noexcept; Statement(Statement&& aStatement) noexcept = default;
Statement& operator=(Statement&& aStatement) noexcept = default;
// Statement is non-copyable // Statement is non-copyable
Statement(const Statement&) = delete; Statement(const Statement&) = delete;

View File

@ -28,20 +28,6 @@ Statement::Statement(Database &aDatabase, const char* apQuery) :
mColumnCount = sqlite3_column_count(mpPreparedStatement.get()); mColumnCount = sqlite3_column_count(mpPreparedStatement.get());
} }
Statement::Statement(Statement&& aStatement) noexcept :
mQuery(std::move(aStatement.mQuery)),
mpSQLite(aStatement.mpSQLite),
mpPreparedStatement(std::move(aStatement.mpPreparedStatement)),
mColumnCount(aStatement.mColumnCount),
mbHasRow(aStatement.mbHasRow),
mbDone(aStatement.mbDone)
{
aStatement.mpSQLite = nullptr;
aStatement.mColumnCount = 0;
aStatement.mbHasRow = false;
aStatement.mbDone = false;
}
// Reset the statement to make it ready for a new execution (see also #clearBindings() bellow) // Reset the statement to make it ready for a new execution (see also #clearBindings() bellow)
void Statement::reset() void Statement::reset()
{ {
@ -342,7 +328,7 @@ std::string Statement::getExpandedSQL() {
Statement::TStatementPtr Statement::prepareStatement() Statement::TStatementPtr Statement::prepareStatement()
{ {
sqlite3_stmt* statement; sqlite3_stmt* statement;
const int ret = sqlite3_prepare_v2(mpSQLite, mQuery.c_str(), static_cast<int>(mQuery.size()), &statement, NULL); const int ret = sqlite3_prepare_v2(mpSQLite, mQuery.c_str(), static_cast<int>(mQuery.size()), &statement, nullptr);
if (SQLITE_OK != ret) if (SQLITE_OK != ret)
{ {
throw SQLite::Exception(mpSQLite, ret); throw SQLite::Exception(mpSQLite, ret);