diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-07-03 18:23:51 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-07-03 18:23:51 +0200 |
commit | 80b868be1e7c249daa714b0c7a5f87694edb8664 (patch) | |
tree | d8e0dd6eca09d33d70224f7289ae096a0976cd6b /odb/relational/header.cxx | |
parent | 89ba09f073b103953c53e63bd78f644973d9154e (diff) |
Implement nested id support
Now the 'id' specifier can optionally include the data member path
to the id inside the composite value. For example:
#pragma db id(first)
std::pair<int, int> p;
Note that one somewhat counter-intuitive aspect of this new feature
is that the whole member marked with id ('p' in the above example)
and not just the actual id member ('p.first' in the above example)
is treated as readonly.
Such nested id also cannot be automatically assigned (auto specifier).
Diffstat (limited to 'odb/relational/header.cxx')
-rw-r--r-- | odb/relational/header.cxx | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/odb/relational/header.cxx b/odb/relational/header.cxx index 4b8b193..b64ab2a 100644 --- a/odb/relational/header.cxx +++ b/odb/relational/header.cxx @@ -12,9 +12,11 @@ traverse_object (type& c) { using semantics::data_member; - data_member* id (id_member (c)); + data_member_path* id (id_member (c)); + data_member* idf (id ? id->front () : 0); + data_member* idb (id ? id->back () : 0); bool auto_id (id && auto_ (*id)); - bool base_id (id && &id->scope () != &c); // Comes from base. + bool base_id (id && &idf->scope () != &c); // Comes from base. data_member* opt (context::optimistic (c)); @@ -120,7 +122,7 @@ traverse_object (type& c) else { semantics::class_& b ( - dynamic_cast<semantics::class_&> (id->scope ())); + dynamic_cast<semantics::class_&> (idf->scope ())); os << "typedef object_traits_impl< " << class_fq_name (b) << ", " << "id_" << db << " >::id_image_type id_image_type;" @@ -132,7 +134,7 @@ traverse_object (type& c) os << "struct id_image_type" << "{"; - id_image_member_->traverse (*id); + id_image_member_->traverse (*idb); if (opt != 0) version_image_member_->traverse (*opt); |