diff options
Diffstat (limited to 'odb/relational')
-rw-r--r-- | odb/relational/schema.cxx | 63 | ||||
-rw-r--r-- | odb/relational/type-processor.cxx | 37 |
2 files changed, 35 insertions, 65 deletions
diff --git a/odb/relational/schema.cxx b/odb/relational/schema.cxx index c55837e..df871e7 100644 --- a/odb/relational/schema.cxx +++ b/odb/relational/schema.cxx @@ -25,56 +25,38 @@ namespace relational void object_columns:: default_ (semantics::data_member& m) { - string s; - tree n (0); + default_value* dv (0); semantics::type& t (m.type ()); if (m.count ("default")) - { - s = m.get<string> ("default"); - - // Empty string is a default value override which means - // there is no default value. - // - if (s.empty ()) - return; - - if (m.count ("default-node")) - n = m.get<tree> ("default-node"); - } + dv = &m.get<default_value> ("default"); else if (t.count ("default")) - { - s = t.get<string> ("default"); - - if (s.empty ()) - return; - - if (t.count ("default-node")) - n = t.get<tree> ("default-node"); - } + dv = &t.get<default_value> ("default"); else return; // No default value for this column. - // The first letter in the default value string identifies - // the type of the value. See pragma.cxx for details. - // - switch (s[0]) + switch (dv->kind) { - case 'n': + case default_value::reset: + { + // No default value. + break; + } + case default_value::null: { default_null (m); break; } - case 't': - case 'f': + case default_value::boolean: { - default_bool (m, s[0] == 't'); + default_bool (m, dv->value == "true"); break; } - case '+': - case '-': + case default_value::number: { + tree n (dv->node); + switch (TREE_CODE (n)) { case INTEGER_CST: @@ -88,7 +70,7 @@ namespace relational unsigned long long v ((h << width) + l); - default_integer (m, v, s[0] == '-'); + default_integer (m, v, dv->value == "-"); break; } case REAL_CST: @@ -109,7 +91,7 @@ namespace relational is >> v; } - if (s[0] == '-') + if (dv->value == "-") v = -v; default_float (m, v); @@ -120,19 +102,16 @@ namespace relational } break; } - - case 's': + case default_value::string: { - default_string (m, string (s, 1, string::npos)); + default_string (m, dv->value); break; } - case 'e': + case default_value::enumerator: { - default_enum (m, n, string (s, 1, string::npos)); + default_enum (m, dv->node, dv->value); break; } - default: - assert (false); } } diff --git a/odb/relational/type-processor.cxx b/odb/relational/type-processor.cxx index 14b546e..a74af9b 100644 --- a/odb/relational/type-processor.cxx +++ b/odb/relational/type-processor.cxx @@ -411,7 +411,7 @@ namespace relational // Mark id column as not null. // - t.set ("id-not-null", string ()); + t.set ("id-not-null", true); // Get the value type. // @@ -465,7 +465,7 @@ namespace relational throw generation_failed (); } else - t.set ("value-not-null", string ()); + t.set ("value-not-null", true); } // Issue a warning if we are relaxing null-ness in the @@ -517,7 +517,7 @@ namespace relational t.set ("index-tree-type", it); t.set ("index-tree-hint", ih); - t.set ("index-not-null", string ()); + t.set ("index-not-null", true); } // Get the key type for maps. @@ -559,7 +559,7 @@ namespace relational t.set ("key-tree-type", kt); t.set ("key-tree-hint", kh); - t.set ("key-not-null", string ()); + t.set ("key-not-null", true); } } @@ -581,7 +581,7 @@ namespace relational // no concept of order in this construct. // if (ck == ck_ordered && m.count ("value-inverse")) - m.set ("unordered", string ()); // Keep compatible with pragma. + m.set ("unordered", true); // Issue an error if we have a null column in a set container. // This can only happen if the value is declared as null in @@ -1110,33 +1110,24 @@ namespace relational virtual void traverse_view (type& c) { - // Convert referenced objects from tree nodes to semantic graph + // Resolve referenced objects from tree nodes to semantic graph // nodes. // if (c.count ("objects")) { using semantics::class_; + typedef vector<view_object> objects; - typedef vector<tree> tree_nodes; - typedef vector<class_*> class_nodes; + objects& objs (c.get<objects> ("objects")); - strings names (c.get<strings> ("objects")); - tree_nodes tnodes (c.get<tree_nodes> ("objects-node")); - - c.remove ("objects"); - c.remove ("objects-node"); - - c.set ("objects", class_nodes ()); - class_nodes& nodes (c.get<class_nodes> ("objects")); - - for (size_t i (0); i < names.size (); ++i) + for (objects::iterator i (objs.begin ()); i < objs.end (); ++i) { - tree n (TYPE_MAIN_VARIANT (tnodes[i])); + tree n (TYPE_MAIN_VARIANT (i->node)); if (TREE_CODE (n) != RECORD_TYPE) { os << c.file () << ":" << c.line () << ":" << c.column () << ":" - << " error: name '" << names[i] << "' in db pragma object " + << " error: name '" << i->name << "' in db pragma object " << " does not name a class" << endl; throw generation_failed (); @@ -1147,17 +1138,17 @@ namespace relational if (!object (o)) { os << c.file () << ":" << c.line () << ":" << c.column () << ":" - << " error: name '" << names[i] << "' in db pragma object " + << " error: name '" << i->name << "' in db pragma object " << "does not name a persistent class" << endl; os << o.file () << ":" << o.line () << ":" << o.column () << ":" - << " info: class '" << names[i] << "' is defined here" + << " info: class '" << i->name << "' is defined here" << endl; throw generation_failed (); } - nodes.push_back (&o); + i->object = &o; } } } |