From 4c893bdef4b57193438e57b09627560e53f3e6d8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 17 Sep 2013 11:11:43 +0200 Subject: Add support for defining composite values inside persistent classes, etc --- common/composite/test.hxx | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'common/composite/test.hxx') diff --git a/common/composite/test.hxx b/common/composite/test.hxx index 040d39c..8bf4b97 100644 --- a/common/composite/test.hxx +++ b/common/composite/test.hxx @@ -170,5 +170,53 @@ namespace test3 } } +// Test composite definition inside object. +// +#pragma db namespace table("t4_") +namespace test4 +{ + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + unsigned long id () const {return id_;} + + void str (const std::string& s) {c_.str = s;} + const std::string& str () const {return c_.str;} + + void x (int i) {p_.first = i;} + int x () const {return p_.first;} + + void y (int i) {p_.second = i;} + int y () const {return p_.second;} + + private: + friend class odb::access; + + #pragma db id + unsigned long id_; + + #pragma db value + struct comp + { + std::string str; + }; + + comp c_; + + typedef std::pair int_pair; + #pragma db value(int_pair) + + int_pair p_; + }; + + inline bool + operator== (const object& x, const object& y) + { + return x.id () == y.id () && x.str () == y.str () && + x.x () == y.x () && x.y () == y.y (); + } +} #endif // TEST_HXX -- cgit v1.1