From 475a7c89e1c858ae8fec466670af4628129a42d4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 28 Aug 2011 11:39:17 +0200 Subject: Add wrapper support for containers --- odb/relational/pgsql/common.cxx | 11 ++++++----- odb/relational/pgsql/common.hxx | 9 ++++++--- odb/relational/pgsql/schema.cxx | 3 +-- odb/relational/pgsql/source.cxx | 11 +++++------ 4 files changed, 18 insertions(+), 16 deletions(-) (limited to 'odb/relational/pgsql') diff --git a/odb/relational/pgsql/common.cxx b/odb/relational/pgsql/common.cxx index d6ef9c3..e4d97cc 100644 --- a/odb/relational/pgsql/common.cxx +++ b/odb/relational/pgsql/common.cxx @@ -35,22 +35,23 @@ namespace relational semantics::type& t (type_override_ != 0 ? *type_override_ : m.type ()); - if (semantics::class_* comp = comp_value_wrapper (t)) + if (semantics::class_* c = comp_value_wrapper (t)) { // If t is a wrapper, pass the wrapped type. Also pass the // original, wrapper type. // - member_info mi ( - m, *comp, (wrapper (t) ? &t : 0), var, fq_type_override_); + member_info mi (m, *c, (wrapper (t) ? &t : 0), var, fq_type_override_); if (pre (mi)) { traverse_composite (mi); post (mi); } } - else if (container (t)) + else if (semantics::type* c = container_wrapper (t)) { - member_info mi (m, t, 0, var, fq_type_override_); + // The same unwrapping logic as for composite values. + // + member_info mi (m, *c, (wrapper (t) ? &t : 0), var, fq_type_override_); if (pre (mi)) { traverse_container (mi); diff --git a/odb/relational/pgsql/common.hxx b/odb/relational/pgsql/common.hxx index f41ca8c..a91c40a 100644 --- a/odb/relational/pgsql/common.hxx +++ b/odb/relational/pgsql/common.hxx @@ -40,10 +40,13 @@ namespace relational string fq_type (bool unwrap = true) const { - // At the moment a wrapped type can only be a composite value. - // if (wrapper != 0 && unwrap) - return t.fq_name (); + { + // Use the hint from the wrapper. + // + return t.fq_name ( + wrapper->get ("wrapper-hint")); + } // Use the original type from 'm' instead of 't' since the hint // may be invalid for a different type. Plus, if a type is diff --git a/odb/relational/pgsql/schema.cxx b/odb/relational/pgsql/schema.cxx index 5bfbc71..0e66e79 100644 --- a/odb/relational/pgsql/schema.cxx +++ b/odb/relational/pgsql/schema.cxx @@ -186,7 +186,7 @@ namespace relational } virtual void - container (semantics::data_member& m) + container (semantics::data_member& m, semantics::type& t) { using semantics::type; using semantics::data_member; @@ -201,7 +201,6 @@ namespace relational if (tables_.count (name)) return; - type& t (m.type ()); type& vt (container_vt (t)); // object_id diff --git a/odb/relational/pgsql/source.cxx b/odb/relational/pgsql/source.cxx index 1bba68a..331463d 100644 --- a/odb/relational/pgsql/source.cxx +++ b/odb/relational/pgsql/source.cxx @@ -1003,7 +1003,7 @@ namespace relational container_traits (base const& x): base (x) {} virtual void - container_extra (semantics::data_member& m) + container_extra (semantics::data_member& m, semantics::type& t) { if (!c_.count ("object") || abstract (c_)) return; @@ -1039,8 +1039,7 @@ namespace relational semantics::data_member* inv_m (inverse (m, "value")); bool inv (inv_m != 0); - semantics::type& mt (m.type ()); - semantics::type& vt (container_vt (mt)); + semantics::type& vt (container_vt (t)); string id_oid (oids[column_sql_type (m, "id").type]); @@ -1055,7 +1054,7 @@ namespace relational { // many(i)-to-many // - if (context::container (inv_m->type ())) + if (container_wrapper (inv_m->type ())) os << oids[column_sql_type (*inv_m, "value").type]; // many(i)-to-one @@ -1080,7 +1079,7 @@ namespace relational { os << id_oid << ","; - switch (container_kind (mt)) + switch (container_kind (t)) { case ck_ordered: { @@ -1093,7 +1092,7 @@ namespace relational case ck_multimap: { if (semantics::class_* ktc = - comp_value_wrapper (container_kt (mt))) + comp_value_wrapper (container_kt (t))) { instance st; st->traverse_composite (m, *ktc, "key", "key"); -- cgit v1.1