aboutsummaryrefslogtreecommitdiff
path: root/common/virtual/test.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-08-31 15:47:55 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-08-31 15:47:55 +0200
commit3e6bb9e10626e192c5d56f806c3262c8ab489bad (patch)
tree64046ad3b8ba38fba604e3439f7f9abea0990cc5 /common/virtual/test.hxx
parentc225be5dea36eaaa3df7f24d33a9644a9158b6a7 (diff)
Test handling multi-member composite object id using virtual data member
Diffstat (limited to 'common/virtual/test.hxx')
-rw-r--r--common/virtual/test.hxx35
1 files changed, 34 insertions, 1 deletions
diff --git a/common/virtual/test.hxx b/common/virtual/test.hxx
index 3c0b0f1..a6caf2c 100644
--- a/common/virtual/test.hxx
+++ b/common/virtual/test.hxx
@@ -22,7 +22,7 @@ namespace test1
#pragma db transient
std::string s;
- #pragma db member(s_) virtual(std::string) access (s)
+ #pragma db member(s_) virtual(std::string) access(s)
bool operator== (const comp& v) const
{
@@ -136,4 +136,37 @@ namespace test2
};
}
+// Use virtual data members to implement multi-member composite object id.
+//
+#pragma db namespace table("t3_")
+namespace test3
+{
+ #pragma db value
+ struct name
+ {
+ name () {}
+ name (std::string const& f, std::string const& l)
+ : first (f), last(l) {}
+
+ std::string first;
+ std::string last;
+
+ bool operator< (const name& x) const
+ {
+ return first < x.first || (first == x.first && last < x.last);
+ }
+ };
+
+ #pragma db object transient
+ struct person
+ {
+ std::string first_;
+ std::string last_;
+
+ #pragma db member(name) virtual(name) id \
+ get(::test3::name (this.first_, this.last_)) \
+ set(this.first_ = (?).first; this.last_ = (?).last)
+ };
+}
+
#endif // TEST_HXX