diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-07-21 11:02:40 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-07-22 17:56:59 +0200 |
commit | 0d61aca198f1a5a71a791b892ef55fe2947d7aa0 (patch) | |
tree | 3e7edb0df78928e619860540651d8d36b0443986 /odb/context.cxx | |
parent | 5d8f5cc0e6d658ae1f74bdf977988bbe995701bb (diff) |
Add support for specifying extra column options
New pragmas: options, id_options, index_options, key_options, and
value_options.
Diffstat (limited to 'odb/context.cxx')
-rw-r--r-- | odb/context.cxx | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/odb/context.cxx b/odb/context.cxx index 520caea..0227763 100644 --- a/odb/context.cxx +++ b/odb/context.cxx @@ -247,6 +247,11 @@ comp_value_ (semantics::class_& c) r = r && !c.count ("index-column"); r = r && !c.count ("key-column"); r = r && !c.count ("id-column"); + r = r && !c.count ("options"); + r = r && !c.count ("value-options"); + r = r && !c.count ("index-options"); + r = r && !c.count ("key-options"); + r = r && !c.count ("id-options"); r = r && !c.count ("null"); r = r && !c.count ("not-null"); r = r && !c.count ("value-null"); @@ -313,6 +318,55 @@ column_type (semantics::data_member& m, string const& kp) } string context:: +column_options (semantics::data_member& m) +{ + // Accumulate options from both type and member. + // + semantics::type& t (m.type ()); + + string mo (m.get<string> ("options", string ())); + string to (t.get<string> ("options", string ())); + + return to + (mo.empty () || to.empty () ? "" : " ") + mo; +} + +string context:: +column_options (semantics::data_member& m, string const& kp) +{ + if (kp.empty ()) + return column_options (m); + + string k (kp + "-options"); + + // Accumulate options from type, container, and member. + // + semantics::type& c (m.type ()); + semantics::type& t (member_type (m, kp)); + + string r (t.get<string> ("options", string ())); + + string o (c.get<string> (k, string ())); + if (!o.empty ()) + { + if (!r.empty ()) + r += ' '; + + r += o; + } + + o = m.get<string> (k, string ()); + if (!o.empty ()) + { + if (!r.empty ()) + r += ' '; + + r += o; + } + + return r; +} + +string context:: database_type_impl (semantics::type& t, semantics::names* hint, bool id) { type_map_type::const_iterator end (data_->type_map_.end ()), i (end); |