From 7f6c64f2211d37db76a97fbc79a4b5492302ef2f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 27 Oct 2010 17:36:59 +0200 Subject: Implement support for composite value types New test: common/composite. --- odb/common.cxx | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 odb/common.cxx (limited to 'odb/common.cxx') diff --git a/odb/common.cxx b/odb/common.cxx new file mode 100644 index 0000000..f398b6e --- /dev/null +++ b/odb/common.cxx @@ -0,0 +1,64 @@ +// file : odb/common.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : GNU GPL v3; see accompanying LICENSE file + +#include + +using namespace std; + +// +// object_columns_base +// + +void object_columns_base:: +composite (semantics::data_member& m) +{ + dispatch (m.type ()); +} + +void object_columns_base:: +traverse (semantics::class_& c) +{ + inherits (c); + names (c); +} + +void object_columns_base::member:: +traverse (semantics::data_member& m) +{ + if (m.count ("transient")) + return; + + if (comp_value (m.type ())) + { + string old_prefix (prefix_); + + bool custom (m.count ("column")); + string name (column_name (m)); + + // If the user provided the column prefix, then use it verbatime. + // Otherwise, append the underscore, unless it is already there. + // + prefix_ += name; + + if (!custom) + { + size_t n (name.size ()); + + if (n != 0 && name[n - 1] != '_') + prefix_ += '_'; + } + + oc_.composite (m); + + prefix_ = old_prefix; + } + else + { + oc_.column (m, prefix_ + column_name (m), first_); + + if (first_) + first_ = false; + } +} -- cgit v1.1