summaryrefslogtreecommitdiff
path: root/src/database/statement.hpp
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-12-16 16:32:32 +0100
committerlouiz’ <louiz@louiz.org>2017-12-16 16:32:32 +0100
commit2c4016a4898a050c7f6ebd1843b265e209da1704 (patch)
treeb6c57d4fa446fe588cac6999c498dc1d7587dd9e /src/database/statement.hpp
parentaaa9de8fe2c67b67310b7ba78c607bddbf4b25bf (diff)
parentb1f850b6395610c738a8e58abcdf2abfca3edd4e (diff)
downloadbiboumi-2c4016a4898a050c7f6ebd1843b265e209da1704.tar.gz
biboumi-2c4016a4898a050c7f6ebd1843b265e209da1704.tar.bz2
biboumi-2c4016a4898a050c7f6ebd1843b265e209da1704.tar.xz
biboumi-2c4016a4898a050c7f6ebd1843b265e209da1704.zip
Merge branch 'postgresql' into 'master'
Add postgresql support Closes #3237 See merge request louiz/biboumi!18
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;
};