diff options
Diffstat (limited to 'src/database')
-rw-r--r-- | src/database/count_query.hpp | 2 | ||||
-rw-r--r-- | src/database/database.cpp | 2 | ||||
-rw-r--r-- | src/database/insert_query.hpp | 2 | ||||
-rw-r--r-- | src/database/postgresql_engine.cpp | 5 | ||||
-rw-r--r-- | src/database/postgresql_engine.hpp | 27 | ||||
-rw-r--r-- | src/database/query.hpp | 2 | ||||
-rw-r--r-- | src/database/row.hpp | 2 | ||||
-rw-r--r-- | src/database/select_query.hpp | 4 | ||||
-rw-r--r-- | src/database/sqlite3_engine.cpp | 6 | ||||
-rw-r--r-- | src/database/sqlite3_engine.hpp | 19 |
10 files changed, 52 insertions, 19 deletions
diff --git a/src/database/count_query.hpp b/src/database/count_query.hpp index b462e0f..e8d24ef 100644 --- a/src/database/count_query.hpp +++ b/src/database/count_query.hpp @@ -6,8 +6,6 @@ #include <string> -#include <sqlite3.h> - struct CountQuery: public Query { CountQuery(std::string name): diff --git a/src/database/database.cpp b/src/database/database.cpp index f9a365d..ae5654c 100644 --- a/src/database/database.cpp +++ b/src/database/database.cpp @@ -15,8 +15,6 @@ #include <memory> -#include <sqlite3.h> - std::unique_ptr<DatabaseEngine> Database::db; Database::MucLogLineTable Database::muc_log_lines("muclogline_"); Database::GlobalOptionsTable Database::global_options("globaloptions_"); diff --git a/src/database/insert_query.hpp b/src/database/insert_query.hpp index 2fc0512..853b7f1 100644 --- a/src/database/insert_query.hpp +++ b/src/database/insert_query.hpp @@ -10,8 +10,6 @@ #include <string> #include <tuple> -#include <sqlite3.h> - template <std::size_t N=0, typename... T> typename std::enable_if<N < sizeof...(T), void>::type update_autoincrement_id(std::tuple<T...>& columns, Statement& statement) diff --git a/src/database/postgresql_engine.cpp b/src/database/postgresql_engine.cpp index 9f603ab..1c01ed5 100644 --- a/src/database/postgresql_engine.cpp +++ b/src/database/postgresql_engine.cpp @@ -1,3 +1,6 @@ +#include <biboumi.h> +#ifdef PQ_FOUND + #include <database/postgresql_engine.hpp> #include <database/postgresql_statement.hpp> @@ -75,3 +78,5 @@ std::string PostgresqlEngine::id_column_type() { return "SERIAL"; } + +#endif diff --git a/src/database/postgresql_engine.hpp b/src/database/postgresql_engine.hpp index e6444d4..fe4fb53 100644 --- a/src/database/postgresql_engine.hpp +++ b/src/database/postgresql_engine.hpp @@ -1,16 +1,20 @@ #pragma once -#include <database/engine.hpp> +#include <biboumi.h> +#include <string> +#include <stdexcept> +#include <memory> #include <database/statement.hpp> +#include <database/engine.hpp> -#include <libpq-fe.h> - -#include <memory> -#include <string> #include <tuple> #include <set> +#ifdef PQ_FOUND + +#include <libpq-fe.h> + class PostgresqlEngine: public DatabaseEngine { public: @@ -29,3 +33,16 @@ class PostgresqlEngine: public DatabaseEngine private: PGconn* const conn; }; + +#else + +class PostgresqlEngine +{ +public: + static std::unique_ptr<DatabaseEngine> open(const std::string& string) + { + throw std::runtime_error("Cannot open postgresql database "s + string + ": biboumi is not compiled with libpq."); + } +}; + +#endif diff --git a/src/database/query.hpp b/src/database/query.hpp index 2467749..7f8aecb 100644 --- a/src/database/query.hpp +++ b/src/database/query.hpp @@ -9,8 +9,6 @@ #include <vector> #include <string> -#include <sqlite3.h> - void actual_bind(Statement& statement, const std::string& value, int index); void actual_bind(Statement& statement, const std::size_t value, int index); void actual_bind(Statement& statement, const OptionalBool& value, int index); diff --git a/src/database/row.hpp b/src/database/row.hpp index b69fac5..1b50ff9 100644 --- a/src/database/row.hpp +++ b/src/database/row.hpp @@ -8,8 +8,6 @@ #include <type_traits> -#include <sqlite3.h> - template <typename... T> struct Row { diff --git a/src/database/select_query.hpp b/src/database/select_query.hpp index 22b342e..837a866 100644 --- a/src/database/select_query.hpp +++ b/src/database/select_query.hpp @@ -12,12 +12,10 @@ #include <vector> #include <string> -#include <sqlite3.h> - using namespace std::string_literals; template <typename T> -typename std::enable_if<std::is_integral<T>::value, sqlite3_int64>::type +typename std::enable_if<std::is_integral<T>::value, std::int64_t>::type extract_row_value(Statement& statement, const int i) { return statement.get_column_int64(i); diff --git a/src/database/sqlite3_engine.cpp b/src/database/sqlite3_engine.cpp index 7e34f89..a94a892 100644 --- a/src/database/sqlite3_engine.cpp +++ b/src/database/sqlite3_engine.cpp @@ -1,3 +1,7 @@ +#include <biboumi.h> + +#ifdef SQLITE3_FOUND + #include <database/sqlite3_engine.hpp> #include <database/sqlite3_statement.hpp> @@ -91,3 +95,5 @@ std::string Sqlite3Engine::id_column_type() { return "INTEGER PRIMARY KEY AUTOINCREMENT"; } + +#endif diff --git a/src/database/sqlite3_engine.hpp b/src/database/sqlite3_engine.hpp index eb18d0c..5b8176c 100644 --- a/src/database/sqlite3_engine.hpp +++ b/src/database/sqlite3_engine.hpp @@ -4,12 +4,17 @@ #include <database/statement.hpp> -#include <sqlite3.h> #include <memory> #include <string> #include <tuple> #include <set> +#include <biboumi.h> + +#ifdef SQLITE3_FOUND + +#include <sqlite3.h> + class Sqlite3Engine: public DatabaseEngine { public: @@ -28,3 +33,15 @@ private: sqlite3* const db; }; +#else + +class Sqlite3Engine +{ +public: + static std::unique_ptr<DatabaseEngine> open(const std::string& string) + { + throw std::runtime_error("Cannot open sqlite3 database "s + string + ": biboumi is not compiled with sqlite3 lib."); + } +}; + +#endif |