summaryrefslogtreecommitdiff
path: root/odb/common.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-10-27 17:36:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-10-27 17:36:59 +0200
commit7f6c64f2211d37db76a97fbc79a4b5492302ef2f (patch)
treef2e386644fcaab5c51e3f5ad0ac737ea5b4d5bd2 /odb/common.cxx
parent5259b98c75f3754a0f713bcee4bddd0ed7ce35ef (diff)
Implement support for composite value types
New test: common/composite.
Diffstat (limited to 'odb/common.cxx')
-rw-r--r--odb/common.cxx64
1 files changed, 64 insertions, 0 deletions
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 <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+// license : GNU GPL v3; see accompanying LICENSE file
+
+#include <odb/common.hxx>
+
+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;
+ }
+}