aboutsummaryrefslogtreecommitdiff
path: root/odb/inline.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/inline.cxx')
-rw-r--r--odb/inline.cxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/odb/inline.cxx b/odb/inline.cxx
index 73b50c1..1af84b6 100644
--- a/odb/inline.cxx
+++ b/odb/inline.cxx
@@ -116,6 +116,8 @@ traverse_object (type& c)
bool auto_id (id && auto_ (*id));
bool base_id (id && &id->scope () != &c); // Comes from base.
+ data_member* opt (context::optimistic (c));
+
// Base class that contains the object id.
//
type* base (id != 0 && base_id ? dynamic_cast<type*> (&id->scope ()) : 0);
@@ -166,6 +168,34 @@ traverse_object (type& c)
os << "}";
}
+ if (opt != 0)
+ {
+ os << "inline" << endl
+ << traits << "::version_type" << endl
+ << traits << "::" << endl
+ << "version (const object_type& o)"
+ << "{";
+
+ if (base_id)
+ os << "return object_traits< " << class_fq_name (*base) <<
+ " >::version (o);";
+ else
+ {
+ // 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 (opt->get<member_access> ("get"));
+
+ if (!ma.synthesized)
+ os << "// From " << location_string (ma.loc, true) << endl;
+
+ os << "return " << ma.translate ("o") << ";";
+ }
+
+ os << "}";
+ }
+
// The rest does not apply to reuse-abstract objects.
//
if (reuse_abst)