summaryrefslogtreecommitdiff
path: root/src/database/postgresql_engine.hpp
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-12-01 14:59:22 +0100
committerlouiz’ <louiz@louiz.org>2017-12-02 20:08:50 +0100
commit414bbca0bc2bf20c4f424c2368997a46129b32cc (patch)
treec9e67c8eedee84963ecc920d8158738770f9238e /src/database/postgresql_engine.hpp
parent923cf31ba62ebfd2369a9594a60020477730b649 (diff)
downloadbiboumi-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/postgresql_engine.hpp')
-rw-r--r--src/database/postgresql_engine.hpp27
1 files changed, 22 insertions, 5 deletions
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