Add a Statement class to manage the sqlite3_stmt objects and avoid leaks

This commit is contained in:
louiz’
2017-06-14 00:19:15 +02:00
parent 41c23aab37
commit 9defd0ccb7
5 changed files with 61 additions and 22 deletions
+4 -2
View File
@@ -1,5 +1,7 @@
#pragma once
#include <database/statement.hpp>
#include <logger/logger.hpp>
#include <vector>
@@ -16,7 +18,7 @@ struct Query
body(std::move(str))
{}
sqlite3_stmt* prepare(sqlite3* db)
Statement prepare(sqlite3* db)
{
sqlite3_stmt* statement;
log_debug(this->body);
@@ -27,7 +29,7 @@ struct Query
log_error("Error preparing statement: ", sqlite3_errmsg(db));
return nullptr;
}
return statement;
return {statement};
}
};