diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-01-08 17:27:40 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-01-08 17:27:40 +0200 |
commit | 24f87489a4d315cc01ca9d49a3f0209522fe6729 (patch) | |
tree | 260a5479af34c9452679d63f9c892288417acac4 /composite/person.hxx | |
parent | 0431bdb607d898c1efb59211568b43ebd6890e25 (diff) |
Add support for defining composite value type as class template instantiations
Diffstat (limited to 'composite/person.hxx')
-rw-r--r-- | composite/person.hxx | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/composite/person.hxx b/composite/person.hxx index dfc44e6..92da60c 100644 --- a/composite/person.hxx +++ b/composite/person.hxx @@ -123,6 +123,12 @@ private: name_extras extras_; }; +// We can also define a composite value type as a class template +// instantiation. Here we use std::pair to store person's phone +// numbers, in the order of preference. +// +typedef std::pair<std::string, std::string> phone_numbers; +#pragma db value(phone_numbers) #pragma db object class person @@ -130,8 +136,9 @@ class person public: person (const std::string& first, const std::string& last, - const std::string& title) - : name_ (first, last, title) + const std::string& title, + const phone_numbers& phone) + : name_ (first, last, title), phone_ (phone) { } @@ -151,6 +158,14 @@ public: return name_; } + // Phone. + // + const phone_numbers& + phone () const + { + return phone_; + } + private: friend class odb::access; @@ -160,6 +175,7 @@ private: unsigned long id_; name_type name_; + phone_numbers phone_; }; #endif // PERSON_HXX |