1 #pragma once 2 3 /** 4 * Interface to provide non-portable behaviour, specific to each 5 * database engine we want to support. 6 * 7 * Everything else (all portable stuf) should go outside of this class. 8 */ 9 10 #include <database/statement.hpp> 11 12 #include <memory> 13 #include <string> 14 #include <vector> 15 #include <tuple> 16 #include <set> 17 18 class DatabaseEngine 19 { 20 public: 21 22 DatabaseEngine() = default; 23 virtual ~DatabaseEngine() = default; 24 25 DatabaseEngine(const DatabaseEngine&) = delete; 26 DatabaseEngine& operator=(const DatabaseEngine&) = delete; 27 DatabaseEngine(DatabaseEngine&&) = delete; 28 DatabaseEngine& operator=(DatabaseEngine&&) = delete; 29 30 virtual std::set<std::string> get_all_columns_from_table(const std::string& table_name) = 0; 31 virtual std::tuple<bool, std::string> raw_exec(const std::string& query) = 0; 32 virtual std::unique_ptr<Statement> prepare(const std::string& query) = 0; 33 virtual void extract_last_insert_rowid(Statement& statement) = 0; get_returning_id_sql_string(const std::string &)34 virtual std::string get_returning_id_sql_string(const std::string&) 35 { 36 return {}; 37 } 38 virtual std::string id_column_type() = 0; 39 40 int64_t last_inserted_rowid{-1}; 41 }; 42