summaryrefslogtreecommitdiff
path: root/odb/option-functions.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/option-functions.cxx')
-rw-r--r--odb/option-functions.cxx70
1 files changed, 66 insertions, 4 deletions
diff --git a/odb/option-functions.cxx b/odb/option-functions.cxx
index 6b7442e..b0b2523 100644
--- a/odb/option-functions.cxx
+++ b/odb/option-functions.cxx
@@ -3,6 +3,7 @@
// license : GNU GPL v3; see accompanying LICENSE file
#include <set>
+#include <utility> // std::make_pair()
#include <odb/option-functions.hxx>
@@ -11,6 +12,8 @@ using namespace std;
void
process_options (options& o)
{
+ database db (o.database ()[0]);
+
// If --generate-schema-only was specified, then set --generate-schema
// as well.
//
@@ -19,12 +22,16 @@ process_options (options& o)
// Set the default schema format depending on the database.
//
- if (o.generate_schema () && o.schema_format ().empty ())
+ if (o.generate_schema () && o.schema_format ()[db].empty ())
{
- set<schema_format> f;
+ set<schema_format>& f (o.schema_format ()[db]);
- switch (o.database ())
+ switch (db)
{
+ case database::common:
+ {
+ break; // No schema for common.
+ }
case database::mssql:
case database::mysql:
case database::oracle:
@@ -39,7 +46,62 @@ process_options (options& o)
break;
}
}
+ }
- o.schema_format (f);
+ // Set default --schema-name value.
+ //
+ if (o.schema_name ().count (db) == 0)
+ o.schema_name ()[db] = "";
+
+ // Set default --*--file-suffix values.
+ //
+ {
+ database cm (database::common);
+
+ o.odb_file_suffix ().insert (make_pair (cm, string ("-odb")));
+ o.sql_file_suffix ().insert (make_pair (cm, string ("")));
+ o.schema_file_suffix ().insert (make_pair (cm, string ("-schema")));
+ }
+
+ if (o.multi_database () == multi_database::disabled)
+ {
+ o.odb_file_suffix ().insert (make_pair (db, string ("-odb")));
+ o.sql_file_suffix ().insert (make_pair (db, string ("")));
+ o.schema_file_suffix ().insert (make_pair (db, string ("-schema")));
+ }
+ else
+ {
+ o.odb_file_suffix ().insert (
+ make_pair (db, string ("-odb-") + db.string ()));
+ o.sql_file_suffix ().insert (
+ make_pair (db, string ("-") + db.string ()));
+ o.schema_file_suffix ().insert (
+ make_pair (db, string ("-schema-") + db.string ()));
+ }
+
+ // Set default --default-database value.
+ //
+ if (!o.default_database_specified ())
+ {
+ switch (o.multi_database ())
+ {
+ case multi_database::disabled:
+ {
+ o.default_database (db);
+ o.default_database_specified (true);
+ break;
+ }
+ case multi_database::dynamic:
+ {
+ o.default_database (database::common);
+ o.default_database_specified (true);
+ break;
+ }
+ case multi_database::static_:
+ {
+ // No default database unless explicitly specified.
+ break;
+ }
+ }
}
}