From f2955b7052e571eb4af0ad8194970f29e4b4ff9b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 4 Aug 2011 13:29:43 +0200 Subject: Add support for value wrappers Wrapper is a class that wraps another type. Examples of wrappers are various smart pointers, holders, etc. A wrapper can be transparent or it can handle the NULL semantics. The new odb::nullable class template is a NULL wrapper that helps to add the NULL semantics to a value type. New test: common/wrapper. --- query/person.hxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'query/person.hxx') diff --git a/query/person.hxx b/query/person.hxx index 72da079..db312f2 100644 --- a/query/person.hxx +++ b/query/person.hxx @@ -8,6 +8,7 @@ #include #include +#include #pragma db object class person @@ -20,12 +21,26 @@ public: { } + person (const std::string& first, + const std::string& middle, + const std::string& last, + unsigned short age) + : first_ (first), middle_ (middle), last_ (last), age_ (age) + { + } + const std::string& first () const { return first_; } + const odb::nullable& + middle () const + { + return middle_; + } + const std::string& last () const { @@ -47,6 +62,7 @@ private: unsigned long id_; std::string first_; + odb::nullable middle_; std::string last_; unsigned short age_; }; -- cgit v1.1