aboutsummaryrefslogtreecommitdiff
path: root/odb/option-types.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-10-25 10:35:36 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-10-25 10:35:36 +0200
commitd1ad30f7a517e69bc87d1347224f1c9ab38493b3 (patch)
tree95189ae91fcce6366f0a121f67b483f3c1b962e7 /odb/option-types.hxx
parent7fc555e53f0a03c93fe31ad9850b1e5d885c44f6 (diff)
Static multi-database support
Add new options (--multi-database, --default-database). Generate common code to -odb.?xx files and database-specific to -odb-<db>.?xx.
Diffstat (limited to 'odb/option-types.hxx')
-rw-r--r--odb/option-types.hxx50
1 files changed, 50 insertions, 0 deletions
diff --git a/odb/option-types.hxx b/odb/option-types.hxx
index 66e2f28..732cd5a 100644
--- a/odb/option-types.hxx
+++ b/odb/option-types.hxx
@@ -5,7 +5,9 @@
#ifndef ODB_OPTION_TYPES_HXX
#define ODB_OPTION_TYPES_HXX
+#include <map>
#include <iosfwd>
+#include <cassert>
#include <odb/semantics/relational/name.hxx>
@@ -40,6 +42,7 @@ struct database
{
// Keep in alphabetic order.
//
+ common,
mssql,
mysql,
oracle,
@@ -65,6 +68,53 @@ operator<< (std::ostream&, database);
//
//
+template <typename V>
+struct database_map: std::map<database, V>
+{
+ typedef std::map<database, V> base_type;
+
+ using base_type::operator[];
+
+ V const&
+ operator[] (database const& k) const
+ {
+ typename base_type::const_iterator i (this->find (k));
+ assert (i != this->end ());
+ return i->second;
+ }
+};
+
+//
+//
+struct multi_database
+{
+ enum value
+ {
+ // Keep in alphabetic order.
+ //
+ dynamic,
+ static_,
+ disabled // Special value.
+ };
+
+ multi_database (value v = disabled) : v_ (v) {}
+ operator value () const {return v_;}
+
+ const char*
+ string () const;
+
+private:
+ value v_;
+};
+
+std::istream&
+operator>> (std::istream&, multi_database&);
+
+std::ostream&
+operator<< (std::ostream&, multi_database);
+
+//
+//
struct schema_format
{
enum value