diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-08-13 13:46:57 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-08-13 13:46:57 +0200 |
commit | 7b8192c9e9bfa3a228938e12daa222af3bbfa6f1 (patch) | |
tree | 2e8e8890a134086f24cda096a71a805495f9dc73 /common/query/test.hxx | |
parent | 94845b83a38e0fdbc0bee496db058373057093c4 (diff) |
Test language-embedded queries
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 |