aboutsummaryrefslogtreecommitdiff
path: root/odb/common.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-11-21 13:11:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-11-21 13:13:50 +0200
commit9ad0acf37561de9bf359a561faed53de17c2ca3b (patch)
tree4b38b866a4917992a6e22cde9f22539e08d4ed9e /odb/common.hxx
parentd01c8e22abea35477f21488613f2474a2e4e8fc7 (diff)
Add dynamic multi-database query support
Diffstat (limited to 'odb/common.hxx')
-rw-r--r--odb/common.hxx97
1 files changed, 5 insertions, 92 deletions
diff --git a/odb/common.hxx b/odb/common.hxx
index b351d3d..7ce59a5 100644
--- a/odb/common.hxx
+++ b/odb/common.hxx
@@ -11,6 +11,7 @@
#include <cassert>
#include <odb/context.hxx>
+#include <odb/instance.hxx>
// Traverse object members recursively by going into bases and
// composite members.
@@ -357,6 +358,8 @@ private:
struct object_columns_list: object_columns_base
{
+ typedef object_columns_list base;
+
object_columns_list (bool ignore_inverse = true)
: ignore_inverse_ (ignore_inverse)
{
@@ -426,98 +429,8 @@ private:
bool included_;
};
-// Generate query tags for object pointers.
+// Other common parts.
//
-struct query_tags: object_columns_base, virtual context
-{
- typedef query_tags base;
-
- query_tags (): nl_ (false) {}
-
- virtual void
- traverse (semantics::class_& c)
- {
- if (object (c))
- {
- object_columns_base::traverse (c);
- }
- else if (c.get<size_t> ("object-count") != 0) // View.
- {
- view_objects& objs (c.get<view_objects> ("objects"));
-
- 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;
-
- generate (i->alias);
- }
- }
-
- if (nl_)
- os << endl;
- }
-
- virtual void
- traverse_object (semantics::class_& c)
- {
- names (c); // We don't want to traverse bases.
- }
-
- virtual void
- traverse_composite (semantics::data_member* m, semantics::class_& c)
- {
- // Base type.
- //
- if (m == 0)
- {
- object_columns_base::traverse_composite (m, c);
- return;
- }
-
- // Don't generate an empty struct if we don't have any pointers.
- //
- if (!has_a (c, test_pointer))
- return;
-
- if (nl_)
- os << endl;
-
- os << "struct " << public_name (*m) << "_tag"
- << "{";
-
- object_columns_base::traverse_composite (m, c);
-
- os << "};";
-
- nl_ = false;
- }
-
- virtual void
- traverse_pointer (semantics::data_member& m, semantics::class_&)
- {
- // Ignore polymorphic id references.
- //
- if (m.count ("polymorphic-ref"))
- return;
-
- generate (public_name (m));
- }
-
- virtual void
- generate (string const& name)
- {
- os << "struct " << name << "_tag;";
- nl_ = true;
- }
-
-private:
- bool nl_;
-};
+#include <odb/common-query.hxx>
#endif // ODB_COMMON_HXX