aboutsummaryrefslogtreecommitdiff
path: root/odb/relational/header.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-11-02 12:18:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-11-21 13:13:50 +0200
commit1f777ed4b8cc816817e1ce6cb8d9af970ad9b423 (patch)
treefc6be8482dfa11fa26b387ca4763d9b282b27638 /odb/relational/header.cxx
parent8a637f5697fdee3e7ae2d46f64a64d40cba5954b (diff)
Rework query alias tag system
Now each object pointer or view-associated object with alias gets its own unique tag.
Diffstat (limited to 'odb/relational/header.cxx')
-rw-r--r--odb/relational/header.cxx48
1 files changed, 47 insertions, 1 deletions
diff --git a/odb/relational/header.cxx b/odb/relational/header.cxx
index 1295106..3c9cd5a 100644
--- a/odb/relational/header.cxx
+++ b/odb/relational/header.cxx
@@ -147,6 +147,22 @@ traverse_object (type& c)
}
//
+ // Query (abstract and concrete).
+ //
+
+ if (options.generate_query ())
+ {
+ // Generate object pointer tags.
+ //
+ if (has_a (c, test_pointer | exclude_base))
+ {
+ instance<query_tags> t;
+ t->traverse (c);
+ os << endl;
+ }
+ }
+
+ //
// Functions (abstract and concrete).
//
@@ -630,6 +646,7 @@ void relational::header::class1::
traverse_view (type& c)
{
string const& type (class_fq_name (c));
+ size_t obj_count (c.get<size_t> ("object-count"));
os << "// " << class_name (c) << endl
<< "//" << endl;
@@ -656,12 +673,41 @@ traverse_view (type& c)
// Query.
//
+ // Generate associated object tags.
+ //
+ if (obj_count != 0)
+ {
+ view_objects& objs (c.get<view_objects> ("objects"));
+
+ {
+ instance<query_tags> t;
+
+ bool gen (false);
+ for (view_objects::const_iterator i (objs.begin ());
+ i < objs.end ();
+ ++i)
+ {
+ if (i->kind != view_object::object)
+ continue; // Skip tables.
+
+ if (i->alias.empty ())
+ continue;
+
+ t->generate (i->alias);
+ gen = true;
+ }
+
+ if (gen)
+ os << endl;
+ }
+ }
+
// query_base_type and query_columns (definition generated by class2).
//
os << "typedef " << db << "::query_base query_base_type;"
<< "struct query_columns";
- if (c.get<size_t> ("object-count") == 0)
+ if (obj_count == 0)
os << "{"
<< "};";
else