From 1f777ed4b8cc816817e1ce6cb8d9af970ad9b423 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 2 Nov 2012 12:18:43 +0200 Subject: Rework query alias tag system Now each object pointer or view-associated object with alias gets its own unique tag. --- odb/relational/header.cxx | 48 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'odb/relational/header.cxx') 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 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 ("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 ("objects")); + + { + instance 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 ("object-count") == 0) + if (obj_count == 0) os << "{" << "};"; else -- cgit v1.1