diff options
Diffstat (limited to 'common/query/test.hxx')
-rw-r--r-- | common/query/test.hxx | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/common/query/test.hxx b/common/query/test.hxx index a923458..34c489d 100644 --- a/common/query/test.hxx +++ b/common/query/test.hxx @@ -7,18 +7,26 @@ #define TEST_HXX #include <string> +#include <memory> #include <iostream> #include <odb/core.hxx> +typedef std::auto_ptr<std::string> string_ptr; // @@ tmp + #pragma odb object struct person { person (unsigned long id, const std::string& fn, const std::string& ln, - unsigned short age) - : id_ (id), first_name_ (fn), last_name_ (ln), age_ (age) + unsigned short age, + bool married) + : id_ (id), + first_name_ (fn), + last_name_ (ln), + age_ (age), + married_ (married) { } @@ -29,15 +37,31 @@ struct person #pragma odb id unsigned long id_; + #pragma odb column ("first") std::string first_name_; + + #pragma odb column ("middle") type ("TEXT") + string_ptr middle_name_; + + #pragma odb column ("last") std::string last_name_; + unsigned short age_; + bool married_; }; inline std::ostream& operator<< (std::ostream& os, const person& p) { - return os << p.first_name_ << ' ' << p.last_name_ << ' ' << p.age_; + os << p.first_name_; + + if (p.middle_name_.get () != 0) + os << ' ' << *p.middle_name_; + + os << ' ' << p.last_name_ << ' ' << p.age_ << + (p.married_ ? " married" : " single"); + + return os; } #endif // TEST_HXX |