From 0d61aca198f1a5a71a791b892ef55fe2947d7aa0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 21 Jul 2011 11:02:40 +0200 Subject: Add support for specifying extra column options New pragmas: options, id_options, index_options, key_options, and value_options. --- odb/context.cxx | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'odb/context.cxx') 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 ("options", string ())); + string to (t.get ("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 ("options", string ())); + + string o (c.get (k, string ())); + if (!o.empty ()) + { + if (!r.empty ()) + r += ' '; + + r += o; + } + + o = m.get (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); -- cgit v1.1