summaryrefslogtreecommitdiff
path: root/src/database/statement.hpp
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2018-02-05 22:53:36 +0100
committerlouiz’ <louiz@louiz.org>2018-02-05 22:53:36 +0100
commit56651cb5c29cc50ddf3c62c37167fa0b9389bfde (patch)
treeca652963cafeb02b0c6c7504b1cfbc27abdafe0b /src/database/statement.hpp
parentad1e0f8d52189e18df2d5a39228e255798a9de70 (diff)
parente0d1a0b44add408504e428d6ce4a8a2121ea7a00 (diff)
downloadbiboumi-56651cb5c29cc50ddf3c62c37167fa0b9389bfde.tar.gz
biboumi-56651cb5c29cc50ddf3c62c37167fa0b9389bfde.tar.bz2
biboumi-56651cb5c29cc50ddf3c62c37167fa0b9389bfde.tar.xz
biboumi-56651cb5c29cc50ddf3c62c37167fa0b9389bfde.zip
Merge branch 'master' into debian
Diffstat (limited to 'src/database/statement.hpp')
-rw-r--r--src/database/statement.hpp46
1 files changed, 20 insertions, 26 deletions
diff --git a/src/database/statement.hpp b/src/database/statement.hpp
index 87cd70f..4a61928 100644
--- a/src/database/statement.hpp
+++ b/src/database/statement.hpp
@@ -1,35 +1,29 @@
#pragma once
-#include <sqlite3.h>
+#include <cstdint>
+#include <string>
+#include <vector>
+
+enum class StepResult
+{
+ Row,
+ Done,
+ Error,
+};
class Statement
{
public:
- Statement(sqlite3_stmt* stmt):
- stmt(stmt) {}
- ~Statement()
- {
- sqlite3_finalize(this->stmt);
- }
+ virtual ~Statement() = default;
+ virtual StepResult step() = 0;
+
+ virtual void bind(std::vector<std::string> params) = 0;
- Statement(const Statement&) = delete;
- Statement& operator=(const Statement&) = delete;
- Statement(Statement&& other):
- stmt(other.stmt)
- {
- other.stmt = nullptr;
- }
- Statement& operator=(Statement&& other)
- {
- this->stmt = other.stmt;
- other.stmt = nullptr;
- return *this;
- }
- sqlite3_stmt* get()
- {
- return this->stmt;
- }
+ virtual std::int64_t get_column_int64(const int col) = 0;
+ virtual std::string get_column_text(const int col) = 0;
+ virtual int get_column_int(const int col) = 0;
- private:
- sqlite3_stmt* stmt;
+ virtual bool bind_text(const int pos, const std::string& data) = 0;
+ virtual bool bind_int64(const int pos, const std::int64_t value) = 0;
+ virtual bool bind_null(const int pos) = 0;
};