From 64d0ceffaaf5f57a3d24a5210bf0ad2a8474a618 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 26 Aug 2011 12:13:18 +0200 Subject: Add wrapper support for composite values NULL semantics for composite values is not yet supported. --- odb/relational/sqlite/source.cxx | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'odb/relational/sqlite/source.cxx') diff --git a/odb/relational/sqlite/source.cxx b/odb/relational/sqlite/source.cxx index 6a99fc8..a482184 100644 --- a/odb/relational/sqlite/source.cxx +++ b/odb/relational/sqlite/source.cxx @@ -239,6 +239,18 @@ namespace relational << "//" << endl; } + // If this is a wrapped composite value, then we need to + // "unwrap" it. For simple values this is taken care of + // by the value_traits specializations. + // + if (mi.wrapper != 0 && comp_value (mi.t)) + { + // Here we need the wrapper type, not the wrapped type. + // + member = "wrapper_traits< " + mi.fq_type (false) + " >::" + + "get_ref (" + member + ")"; + } + if (comp_value (mi.t)) traits = "composite_value_traits< " + mi.fq_type () + " >"; else @@ -333,8 +345,9 @@ namespace relational virtual void traverse_composite (member_info& mi) { - os << "if (" << traits << "::init (i." << mi.var << "value, " << - member << "))" + os << "if (" << traits << "::init (" << endl + << "i." << mi.var << "value," << endl + << member << "))" << "{" << "grew = true;" << "}"; @@ -413,6 +426,18 @@ namespace relational << "//" << endl; } + // If this is a wrapped composite value, then we need to + // "unwrap" it. For simple values this is taken care of + // by the value_traits specializations. + // + if (mi.wrapper != 0 && comp_value (mi.t)) + { + // Here we need the wrapper type, not the wrapped type. + // + member = "wrapper_traits< " + mi.fq_type (false) + " >::" + + "set_ref (" + member + ")"; + } + if (comp_value (mi.t)) traits = "composite_value_traits< " + mi.fq_type () + " >"; else @@ -497,8 +522,10 @@ namespace relational virtual void traverse_composite (member_info& mi) { - os << traits << "::init (" << member << ", i." << - mi.var << "value, db);" + os << traits << "::init (" << endl + << member << "," << endl + << "i." << mi.var << "value," << endl + << "db);" << endl; } -- cgit v1.1