From 6bd95f51beb26d87fd5d5db22391c73f333eee6e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 19 Oct 2011 10:47:41 +0200 Subject: Add support for const data members Const data members are automatically treated as readonly. New test: const-member. --- odb/relational/mysql/common.hxx | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'odb/relational/mysql/common.hxx') diff --git a/odb/relational/mysql/common.hxx b/odb/relational/mysql/common.hxx index a85a75e..66269c6 100644 --- a/odb/relational/mysql/common.hxx +++ b/odb/relational/mysql/common.hxx @@ -29,9 +29,13 @@ namespace relational struct member_info { semantics::data_member& m; // Member. - semantics::type& t; // Member C++ type (m.type () may != t). - semantics::type* wrapper; // Wrapper type if member is a wrapper. + semantics::type& t; // Cvr-unqualified member C++ type, note + // that m.type () may not be the same as t. + semantics::type* wrapper; // Wrapper type if member is a composite or + // container wrapper, also cvr-unqualified. // In this case t is the wrapped type. + bool cq; // True if the original (wrapper) type + // is const-qualified. sql_type const* st; // Member SQL type (only simple values). string& var; // Member variable name with trailing '_'. @@ -40,21 +44,29 @@ namespace relational string fq_type (bool unwrap = true) const { + semantics::names* hint; + if (wrapper != 0 && unwrap) { - // Use the hint from the wrapper. + // Use the hint from the wrapper unless the wrapped type + // is qualified. // - return t.fq_name ( - wrapper->get ("wrapper-hint")); + hint = wrapper->get ("wrapper-hint"); + utype (*context::wrapper (*wrapper), hint); + return t.fq_name (hint); } // Use the original type from 'm' instead of 't' since the hint // may be invalid for a different type. Plus, if a type is // overriden, then the fq_type must be as well. // - return fq_type_.empty () - ? m.type ().fq_name (m.belongs ().hint ()) - : fq_type_; + if (fq_type_.empty ()) + { + semantics::type& t (utype (m, hint)); + return t.fq_name (hint); + } + else + return fq_type_; } string const& fq_type_; @@ -62,11 +74,13 @@ namespace relational member_info (semantics::data_member& m_, semantics::type& t_, semantics::type* wrapper_, + bool cq_, string& var_, string const& fq_type) : m (m_), t (t_), wrapper (wrapper_), + cq (cq_), st (0), var (var_), fq_type_ (fq_type) -- cgit v1.1