summaryrefslogtreecommitdiff
path: root/src/database/statement.hpp
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-10-04 21:28:18 +0200
committerlouiz’ <louiz@louiz.org>2017-12-02 20:08:47 +0100
commit0168b96b79db2627fdba77a8712956408aa081d1 (patch)
tree5591527ed8a04be8ea04c49521d9e9c868677bd1 /src/database/statement.hpp
parent5b27cee97272d4ae6ff30f03dc57221fa3e3183f (diff)
downloadbiboumi-0168b96b79db2627fdba77a8712956408aa081d1.tar.gz
biboumi-0168b96b79db2627fdba77a8712956408aa081d1.tar.bz2
biboumi-0168b96b79db2627fdba77a8712956408aa081d1.tar.xz
biboumi-0168b96b79db2627fdba77a8712956408aa081d1.zip
Add postgresql support
Diffstat (limited to 'src/database/statement.hpp')
-rw-r--r--src/database/statement.hpp45
1 files changed, 19 insertions, 26 deletions
diff --git a/src/database/statement.hpp b/src/database/statement.hpp
index 87cd70f..db5f31b 100644
--- a/src/database/statement.hpp
+++ b/src/database/statement.hpp
@@ -1,35 +1,28 @@
#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 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;
};