From eacf52a9a4f3832274fdefc909ab23c13413e128 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 15 Aug 2012 11:46:00 +0200 Subject: Add support for member accessors/modifiers New pragmas: get, set, access. New test: common/access. --- odb/relational/inline.hxx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'odb/relational/inline.hxx') diff --git a/odb/relational/inline.hxx b/odb/relational/inline.hxx index 39801cb..2642809 100644 --- a/odb/relational/inline.hxx +++ b/odb/relational/inline.hxx @@ -5,6 +5,7 @@ #ifndef ODB_RELATIONAL_INLINE_HXX #define ODB_RELATIONAL_INLINE_HXX +#include #include #include @@ -258,16 +259,27 @@ namespace relational os << "inline" << endl << traits << "::id_type" << endl << traits << "::" << endl - << "id (const object_type&" << (id != 0 ? " obj" : "") << ")" + << "id (const object_type&" << (id != 0 ? " o" : "") << ")" << "{"; if (id != 0) { if (base_id) os << "return object_traits< " << class_fq_name (*base) << - " >::id (obj);"; + " >::id (o);"; else - os << "return obj." << id->name () << ";"; + { + // Get the id using the accessor expression. If this is not + // a synthesized expression, then output its location for + // easier error tracking. + // + member_access& ma (id->get ("get")); + + if (ma.loc != 0) + os << "// From " << location_string (ma.loc, true) << endl; + + os << "return " << ma.translate ("o") << ";"; + } } os << "}"; -- cgit v1.1