diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-03-10 08:44:28 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-03-21 15:39:59 +0200 |
commit | 7ae497743c7b042904fe1f6b4153ab3f4763ff2b (patch) | |
tree | 08ba3f742f20d16d893856ccceb070094bd69225 /odb/common.cxx | |
parent | 2436f20262a41bd1cafa5107ab6d6799c03e0964 (diff) |
Split MySQL code generator into common and db-specific parts
The common part (in relational/) still has some MySQL-specific parts.
Also, add the notion of the current context which is used to avoid
explicitly passing the context object to every generator's c-tor.
Diffstat (limited to 'odb/common.cxx')
-rw-r--r-- | odb/common.cxx | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/odb/common.cxx b/odb/common.cxx index fe722df..342f28b 100644 --- a/odb/common.cxx +++ b/odb/common.cxx @@ -37,14 +37,23 @@ traverse_composite (semantics::data_member& m, semantics::class_& c) void object_members_base:: traverse (semantics::class_& c) { + bool obj (c.count ("object")); + // Ignore transient bases. // - if (!(c.count ("object") || context::comp_value (c))) + if (!(obj || context::comp_value (c))) return; - if (build_table_prefix_ && c.count ("object")) + semantics::class_* prev; + if (obj) + { + prev = object; + object = &c; + } + + if (obj && build_table_prefix_) { - table_prefix_.prefix = ctx_->table_name (c); + table_prefix_.prefix = table_name (c); table_prefix_.prefix += '_'; table_prefix_.level = 1; @@ -59,6 +68,9 @@ traverse (semantics::class_& c) inherits (c); names (c); } + + if (obj) + object = prev; } void object_members_base::member:: @@ -76,7 +88,7 @@ traverse (semantics::data_member& m) if (om_.build_prefix_) { old_prefix = om_.prefix_; - om_.prefix_ += om_.ctx_->public_name (m); + om_.prefix_ += om_.public_name (m); om_.prefix_ += '_'; } @@ -99,7 +111,7 @@ traverse (semantics::data_member& m) // else { - string name (om_.ctx_->public_name_db (m)); + string name (om_.public_name_db (m)); size_t n (name.size ()); om_.table_prefix_.prefix += name; |