summaryrefslogtreecommitdiff
path: root/odb/common-query.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/common-query.cxx')
-rw-r--r--odb/common-query.cxx66
1 files changed, 40 insertions, 26 deletions
diff --git a/odb/common-query.cxx b/odb/common-query.cxx
index ade621a..22407fc 100644
--- a/odb/common-query.cxx
+++ b/odb/common-query.cxx
@@ -11,6 +11,19 @@ using namespace std;
// query_utils
//
+string query_utils::
+depth_suffix (size_t d)
+{
+ if (d != 0)
+ {
+ ostringstream os;
+ os << d;
+ return '_' + os.str ();
+ }
+
+ return string ();
+}
+
// Collect nested (composite) types as generated by query_columns.
//
struct query_nested_types: object_columns_base, virtual context
@@ -31,8 +44,9 @@ struct query_nested_types: object_columns_base, virtual context
if (m != 0)
{
string name (prefix_ + public_name (*m));
- name += in_ptr_ ? "_column_class_" : "_class_";
- name += query_columns::depth_suffix (depth_);
+ name += in_ptr_ ? "_column_class" : "_class";
+ name += query_utils::depth_suffix (depth_);
+ name += '_';
types.push_back (name);
depth_++;
@@ -174,10 +188,13 @@ traverse_composite (semantics::data_member* m, semantics::class_& c)
if (nl_)
os << endl;
- os << "struct " << public_name (*m) << "_tag"
+ os << "struct " << public_name (*m) << "_tag" <<
+ query_utils::depth_suffix (depth_)
<< "{";
+ depth_++;
object_columns_base::traverse_composite (m, c);
+ depth_--;
os << "};";
@@ -207,7 +224,7 @@ generate (string const& name)
query_alias_traits::
query_alias_traits (semantics::class_& c, bool decl)
- : decl_ (decl)
+ : decl_ (decl), depth_ (0)
{
scope_ = "access::";
scope_ += (object (c) ? "object_traits_impl" : "view_traits_impl");
@@ -234,9 +251,12 @@ traverse_composite (semantics::data_member* m, semantics::class_& c)
}
string old_scope (scope_);
- scope_ += "::" + public_name (*m) + "_tag";
+ scope_ += "::" + public_name (*m) + "_tag" +
+ query_utils::depth_suffix (depth_);
+ depth_++;
object_columns_base::traverse_composite (m, c);
+ depth_--;
scope_ = old_scope;
}
@@ -319,7 +339,7 @@ generate_def (string const&, semantics::class_&, string const&)
query_columns_base::
query_columns_base (semantics::class_& c, bool decl, bool inst)
- : decl_ (decl), inst_ (inst)
+ : decl_ (decl), inst_ (inst), depth_ (0)
{
string const& n (class_fq_name (c));
@@ -355,18 +375,21 @@ traverse_composite (semantics::data_member* m, semantics::class_& c)
return;
string name (public_name (*m));
+ string dsuffix (query_utils::depth_suffix (depth_));
if (decl_)
{
os << "// " << name << endl
<< "//" << endl
- << "struct " << name << "_base_"
+ << "struct " << name << "_base" << dsuffix << '_'
<< "{";
string old_scope (scope_);
- scope_ += "::" + name + "_tag";
+ scope_ += "::" + name + "_tag" + dsuffix;
+ depth_++;
object_columns_base::traverse_composite (m, c);
+ depth_--;
scope_ = old_scope;
@@ -375,9 +398,11 @@ traverse_composite (semantics::data_member* m, semantics::class_& c)
else
{
string old_scope (scope_);
- scope_ += "::" + name + "_base_";
+ scope_ += "::" + name + "_base" + dsuffix + '_';
+ depth_++;
object_columns_base::traverse_composite (m, c);
+ depth_--;
scope_ = old_scope;
}
@@ -480,19 +505,6 @@ query_columns (bool decl, bool ptr, semantics::class_& c)
{
}
-string query_columns::
-depth_suffix (size_t d)
-{
- if (d != 0)
- {
- ostringstream os;
- os << d;
- return os.str () + '_';
- }
-
- return string ();
-}
-
void query_columns::
traverse_object (semantics::class_& c)
{
@@ -516,7 +528,7 @@ traverse_composite (semantics::data_member* m, semantics::class_& c)
// the class and member names.
//
string name (public_name (*m));
- string suffix (in_ptr_ ? "_column_class_" : "_class_");
+ string suffix (in_ptr_ ? "_column_class" : "_class");
// Add depth to the nested composite to avoid potential name conflicts
// in situations like these:
@@ -525,7 +537,9 @@ traverse_composite (semantics::data_member* m, semantics::class_& c)
// struct outer { inner value; };
// struct object { outer value; }
//
- suffix += depth_suffix (depth_);
+ string dsuffix (query_utils::depth_suffix (depth_));
+ suffix += dsuffix;
+ suffix += '_';
depth_++;
@@ -551,7 +565,7 @@ traverse_composite (semantics::data_member* m, semantics::class_& c)
// data for the pointer members.
//
if (!ptr_ && !poly_ref_ && has_a (c, test_pointer))
- os << ": " << name << "_base_";
+ os << ": " << name << "_base" << dsuffix << '_';
os << "{";
@@ -717,7 +731,7 @@ traverse_pointer (semantics::data_member& m, semantics::class_& c)
os << "struct " << name << "_type_: " <<
name << "_pointer_type_, " <<
- name << "_column_class_" << depth_suffix (depth_)
+ name << "_column_class" << query_utils::depth_suffix (depth_) << '_'
<< "{";
if (!const_.empty ())