aboutsummaryrefslogtreecommitdiff
path: root/odb/relational/inline.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-08-15 11:46:00 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-08-15 11:46:00 +0200
commiteacf52a9a4f3832274fdefc909ab23c13413e128 (patch)
treef1f754b6149797315f91d6f872363555201d5a65 /odb/relational/inline.hxx
parent396cad633b6f0559a39e5111827f9b1125c67506 (diff)
Add support for member accessors/modifiers
New pragmas: get, set, access. New test: common/access.
Diffstat (limited to 'odb/relational/inline.hxx')
-rw-r--r--odb/relational/inline.hxx18
1 files changed, 15 insertions, 3 deletions
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 <odb/diagnostics.hxx>
#include <odb/relational/context.hxx>
#include <odb/relational/common.hxx>
@@ -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<member_access> ("get"));
+
+ if (ma.loc != 0)
+ os << "// From " << location_string (ma.loc, true) << endl;
+
+ os << "return " << ma.translate ("o") << ";";
+ }
}
os << "}";