diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-10-25 10:35:36 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-10-25 10:35:36 +0200 |
commit | d1ad30f7a517e69bc87d1347224f1c9ab38493b3 (patch) | |
tree | 95189ae91fcce6366f0a121f67b483f3c1b962e7 /odb/option-types.cxx | |
parent | 7fc555e53f0a03c93fe31ad9850b1e5d885c44f6 (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.cxx')
-rw-r--r-- | odb/option-types.cxx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/odb/option-types.cxx b/odb/option-types.cxx index ceb71db..c52935e 100644 --- a/odb/option-types.cxx +++ b/odb/option-types.cxx @@ -52,6 +52,7 @@ operator>> (istream& is, cxx_version& v) static const char* database_[] = { + "common", "mssql", "mysql", "oracle", @@ -92,6 +93,50 @@ operator<< (ostream& os, database db) } // +// multi_database +// + +static const char* multi_database_[] = +{ + "dynamic", + "static", + "disabled" +}; + +const char* multi_database:: +string () const +{ + return multi_database_[v_]; +} + +istream& +operator>> (istream& is, multi_database& db) +{ + string s; + is >> s; + + if (!is.fail ()) + { + const char** e ( + multi_database_ + sizeof (multi_database_) / sizeof (char*) - 1); + const char** i (lower_bound (multi_database_, e, s)); + + if (i != e && *i == s) + db = multi_database::value (i - multi_database_); + else + is.setstate (istream::failbit); + } + + return is; +} + +ostream& +operator<< (ostream& os, multi_database db) +{ + return os << db.string (); +} + +// // schema_format // |