From d1ad30f7a517e69bc87d1347224f1c9ab38493b3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 25 Oct 2012 10:35:36 +0200 Subject: Static multi-database support Add new options (--multi-database, --default-database). Generate common code to -odb.?xx files and database-specific to -odb-.?xx. --- odb/option-types.hxx | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'odb/option-types.hxx') 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 #include +#include #include @@ -40,6 +42,7 @@ struct database { // Keep in alphabetic order. // + common, mssql, mysql, oracle, @@ -65,6 +68,53 @@ operator<< (std::ostream&, database); // // +template +struct database_map: std::map +{ + typedef std::map 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 -- cgit v1.1