diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-10-27 17:36:59 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-10-27 17:36:59 +0200 |
commit | d07b467fba9030ddb6940e7c9451f15201faa23d (patch) | |
tree | 8df906c35b173144fa220ff3d79192a2a2ffd837 /common/composite/test.hxx | |
parent | f4c94ca015b123ec01037e521582d3a04f4c4b81 (diff) |
Implement support for composite value types
New test: common/composite.
Diffstat (limited to 'common/composite/test.hxx')
-rw-r--r-- | common/composite/test.hxx | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/common/composite/test.hxx b/common/composite/test.hxx new file mode 100644 index 0000000..d70eefe --- /dev/null +++ b/common/composite/test.hxx @@ -0,0 +1,79 @@ +// file : common/composite/test.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include <string> + +#include <odb/core.hxx> + +#pragma db value +struct name +{ + std::string first; + std::string last; +}; + +#pragma db value +struct title +{ + std::string title; +}; + +#pragma db value +struct name_flags +{ + bool nick; + bool alias; +}; + +#pragma db value +struct name_ex: name, title +{ + name alias; + std::string nick; + + #pragma db column("show_") + name_flags flags; +}; + +#pragma db object +struct person +{ + person (unsigned long id) + : id_ (id) + { + } + + person () + { + } + + #pragma db id + unsigned long id_; + + #pragma db column("") + name_ex name_; + + unsigned short age_; +}; + +inline bool +operator== (person const& x, person const& y) +{ + return x.id_ == y.id_ && + x.name_.first == y.name_.first&& + x.name_.last == y.name_.last && + x.name_.title == y.name_.title && + x.name_.alias.first == y.name_.alias.first && + x.name_.alias.last == y.name_.alias.last && + x.name_.nick == y.name_.nick && + x.name_.flags.nick == y.name_.flags.nick && + x.name_.flags.alias == y.name_.flags.alias && + x.age_ == y.age_; +} + +#endif // TEST_HXX |