aboutsummaryrefslogtreecommitdiff
path: root/odb/option-functions.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/option-functions.cxx')
-rw-r--r--odb/option-functions.cxx61
1 files changed, 60 insertions, 1 deletions
diff --git a/odb/option-functions.cxx b/odb/option-functions.cxx
index 6b7442e..aca4943 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.
//
@@ -23,8 +26,12 @@ process_options (options& o)
{
set<schema_format> f;
- switch (o.database ())
+ switch (db)
{
+ case database::common:
+ {
+ break; // No schema for common.
+ }
case database::mssql:
case database::mysql:
case database::oracle:
@@ -42,4 +49,56 @@ process_options (options& o)
o.schema_format (f);
}
+
+ // 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;
+ }
+ }
+ }
}