From 7b8192c9e9bfa3a228938e12daa222af3bbfa6f1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 13 Aug 2010 13:46:57 +0200 Subject: Test language-embedded queries --- common/query/test.hxx | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'common/query/test.hxx') 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 +#include #include #include +typedef std::auto_ptr 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 -- cgit v1.1