diff options
author | louiz’ <louiz@louiz.org> | 2017-12-01 14:59:22 +0100 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2017-12-02 20:08:50 +0100 |
commit | 414bbca0bc2bf20c4f424c2368997a46129b32cc (patch) | |
tree | c9e67c8eedee84963ecc920d8158738770f9238e /src/database/sqlite3_engine.hpp | |
parent | 923cf31ba62ebfd2369a9594a60020477730b649 (diff) | |
download | biboumi-414bbca0bc2bf20c4f424c2368997a46129b32cc.tar.gz biboumi-414bbca0bc2bf20c4f424c2368997a46129b32cc.tar.bz2 biboumi-414bbca0bc2bf20c4f424c2368997a46129b32cc.tar.xz biboumi-414bbca0bc2bf20c4f424c2368997a46129b32cc.zip |
Handle postgresql and sqlite3 libs properly
Do not fail to compile when one of them is missing but the other one is not.
Raise an error when trying to open a database with the missing library.
see #3237
Diffstat (limited to 'src/database/sqlite3_engine.hpp')
-rw-r--r-- | src/database/sqlite3_engine.hpp | 19 |
1 files changed, 18 insertions, 1 deletions
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 |