diff options
author | louiz’ <louiz@louiz.org> | 2017-10-04 21:28:18 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2017-12-02 20:08:47 +0100 |
commit | 0168b96b79db2627fdba77a8712956408aa081d1 (patch) | |
tree | 5591527ed8a04be8ea04c49521d9e9c868677bd1 /src/database/statement.hpp | |
parent | 5b27cee97272d4ae6ff30f03dc57221fa3e3183f (diff) | |
download | biboumi-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.hpp | 45 |
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; }; |