From 6e2325337ff31a3b3c5b2ab2e74352e1765d2daa Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 21 Aug 2014 09:26:29 +0200 Subject: Use different suffix for composite values in query columns This avoids potential name clash between the class name and its members (both of which, before this fix, had the _type_ suffix). --- odb/common-query.cxx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/odb/common-query.cxx b/odb/common-query.cxx index 14d438c..26b4c8c 100644 --- a/odb/common-query.cxx +++ b/odb/common-query.cxx @@ -29,7 +29,7 @@ struct query_nested_types: object_columns_base, virtual context if (m != 0) { string name (prefix_ + public_name (*m)); - name += in_ptr_ ? "_column_type_" : "_type_"; + name += in_ptr_ ? "_column_class_" : "_class_"; types.push_back (name); string p (prefix_); @@ -486,8 +486,11 @@ traverse_composite (semantics::data_member* m, semantics::class_& c) return; } + // Use _class_ instead of _type_ to avoid potential clashes between + // the class and member names. + // string name (public_name (*m)); - string suffix (in_ptr_ ? "_column_type_" : "_type_"); + string suffix (in_ptr_ ? "_column_class_" : "_class_"); if (decl_) { @@ -525,7 +528,7 @@ traverse_composite (semantics::data_member* m, semantics::class_& c) os << "};"; if (!in_ptr_) - os << "static " << const_ << name << "_type_ " << name << ";" + os << "static " << const_ << name << "_class_ " << name << ";" << endl; } else @@ -545,7 +548,8 @@ traverse_composite (semantics::data_member* m, semantics::class_& c) tmpl += "< " + fq_name_ + ", id_" + db.string () + ", A >" + scope_; os << "template " << endl - << const_ << "typename " << tmpl << "::" << name << "_type_" << endl + << const_ << "typename " << tmpl << "::" << name << + (in_ptr_ ? "_type_" : "_class_") << endl << tmpl << "::" << name << ";" << endl; } @@ -667,7 +671,7 @@ traverse_pointer (semantics::data_member& m, semantics::class_& c) << endl; os << "struct " << name << "_type_: " << - name << "_pointer_type_, " << name << "_column_type_" + name << "_pointer_type_, " << name << "_column_class_" << "{"; if (!const_.empty ()) -- cgit v1.1