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/common.hxx | |
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/common.hxx')
-rw-r--r-- | odb/common.hxx | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/odb/common.hxx b/odb/common.hxx index 104351a..ef85a4b 100644 --- a/odb/common.hxx +++ b/odb/common.hxx @@ -278,10 +278,7 @@ public: // value type, or an object pointer (with a simple or composite id). // virtual void - traverse (semantics::data_member& m) - { - traverse (m, utype (m), string (), string ()); - } + traverse (semantics::data_member&); virtual void traverse (semantics::data_member& m, column_prefix const& cp) @@ -293,6 +290,17 @@ public: } virtual void + traverse (data_member_path& mp) + { + data_member_path op (member_path_); + member_path_ = mp; + traverse (*mp.back (), column_prefix (mp)); + member_path_ = op; + } + + // Should only be used for containers. + // + virtual void traverse (semantics::data_member&, semantics::type&, string const& key_prefix, @@ -333,7 +341,7 @@ protected: } else return context::column_type ( - member_path_, key_prefix_, (root_ != 0 && (root_id_ || root_op_))); + member_path_, key_prefix_, root_ != 0 && (root_id_ || root_op_)); } bool |