summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-02-09 10:37:07 +0000
committerrandomdan <randomdan@localhost>2011-02-09 10:37:07 +0000
commitcb6198827edbeb869f099e8599eb7a8924c49824 (patch)
tree1f11a2a8937fb64064e1ea4430fa7da446073c92
parentFix the build system to do dependencies properly (diff)
downloadproject2-cb6198827edbeb869f099e8599eb7a8924c49824.tar.bz2
project2-cb6198827edbeb869f099e8599eb7a8924c49824.tar.xz
project2-cb6198827edbeb869f099e8599eb7a8924c49824.zip
Make different DB connectors optional
-rw-r--r--project2/Jamfile.jam22
-rw-r--r--project2/dataSource.h1
-rw-r--r--project2/rdbmsDataSource.cpp15
3 files changed, 32 insertions, 6 deletions
diff --git a/project2/Jamfile.jam b/project2/Jamfile.jam
index 8f4ca6b..53b530f 100644
--- a/project2/Jamfile.jam
+++ b/project2/Jamfile.jam
@@ -35,6 +35,8 @@ alias p2parts : : : :
;
feature uuid : boost ossp : propagated ;
+feature odbc : yes no ;
+feature pq : yes no ;
lib p2uuid :
uuid.cpp
@@ -98,16 +100,26 @@ lib p2xmlSession :
<library>p2uuid
;
+obj rdbmsDataSource :
+ rdbmsDataSource.cpp :
+ <odbc>yes:<define>WITH_ODBC
+ <pq>yes:<define>WITH_PQ
+ <odbc>yes:<library>../libodbcpp//odbcpp
+ <pq>yes:<library>../libpqpp//pqpp
+ <library>libxmlpp
+ <library>../libmisc//misc
+ ;
+
lib p2sql :
- [ glob sql*.cpp tablepatch.cpp rdbmsDataSource.cpp ]
+ [ glob sql*.cpp ] tablepatch.cpp rdbmsDataSource
../libdbpp//dbpp
- ../libodbcpp//odbcpp
- ../libpqpp//pqpp
:
+ <odbc>yes:<library>../libodbcpp//odbcpp
+ <pq>yes:<library>../libpqpp//pqpp
<library>libxmlpp
: :
- <library>../libodbcpp//odbcpp
- <library>../libpqpp//pqpp
+ <odbc>yes:<library>../libodbcpp//odbcpp
+ <pq>yes:<library>../libpqpp//pqpp
;
lib p2url :
diff --git a/project2/dataSource.h b/project2/dataSource.h
index b1147da..478feb6 100644
--- a/project2/dataSource.h
+++ b/project2/dataSource.h
@@ -1,7 +1,6 @@
#ifndef DATASOURCE_H
#define DATASOURCE_H
-#include <libxml/tree.h>
#include <boost/intrusive_ptr.hpp>
#include <map>
#include "sourceObject.h"
diff --git a/project2/rdbmsDataSource.cpp b/project2/rdbmsDataSource.cpp
index 98e2d5a..bd3c0b1 100644
--- a/project2/rdbmsDataSource.cpp
+++ b/project2/rdbmsDataSource.cpp
@@ -6,8 +6,12 @@
#include <errno.h>
#include <sqlext.h>
+#ifdef WITH_PQ
#include "../libpqpp/connection.h"
+#endif
+#ifdef WITH_ODBC
#include "../libodbcpp/connection.h"
+#endif
class UnknownConnectionProvider : public std::exception { };
@@ -200,25 +204,36 @@ RdbmsDataSource::RdbmsConnection::isExpired() const
RdbmsDataSource::ConnectionInfo::ConnectionInfo(const xmlpp::Element * n)
{
+#if WITH_ODBC
BOOST_FOREACH(const xmlpp::Node * node, n->find("odbc")) {
type = "ODBC";
dsn = dynamic_cast<const xmlpp::Element *>(node)->get_child_text()->get_content();
}
+#endif
+#if WITH_PQ
BOOST_FOREACH(const xmlpp::Node * node, n->find("postgresql")) {
type = "PQ";
dsn = dynamic_cast<const xmlpp::Element *>(node)->get_child_text()->get_content();
}
+#endif
+ if (type.empty() || dsn.empty()) {
+ throw UnknownConnectionProvider();
+ }
}
DB::Connection *
RdbmsDataSource::ConnectionInfo::connect() const
{
+#if WITH_ODBC
if (type == "ODBC") {
return new ODBC::Connection(dsn);
}
+#endif
+#if WITH_PQ
if (type == "PQ") {
return new PQ::Connection(dsn);
}
+#endif
throw UnknownConnectionProvider();
}