diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2024-01-25 20:35:31 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2024-01-25 20:35:31 +0300 |
commit | 3fe9378674c484750e36f01a353ec17977a6f1a3 (patch) | |
tree | f83e61172c9b0877295284f6fd9e67cddb954ee6 /odb-tests/common/view/olv/test6.hxx | |
parent | 451173da3c76fcb9b3aea5c6d97f48b492558392 (diff) | |
parent | 0d49ea1fe08cf1eab41a00149393a291c65a59d7 (diff) |
Merge branch 'odb-tests' into multi-package
Diffstat (limited to 'odb-tests/common/view/olv/test6.hxx')
-rw-r--r-- | odb-tests/common/view/olv/test6.hxx | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/odb-tests/common/view/olv/test6.hxx b/odb-tests/common/view/olv/test6.hxx new file mode 100644 index 0000000..5336fa6 --- /dev/null +++ b/odb-tests/common/view/olv/test6.hxx @@ -0,0 +1,57 @@ +// file : common/view/olv/test6.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST6_HXX +#define TEST6_HXX + +#include <string> +#include <memory> // shared_ptr + +#include <odb/core.hxx> +#include <odb/section.hxx> + +// Test interaction with sections. +// +#pragma db namespace table("t6_") pointer(std::shared_ptr) +namespace test6 +{ + using std::shared_ptr; + + #pragma db object + struct object1 + { + object1 (int n_ = 0): n (n_) {} + + #pragma db id auto + int id; + + int n; + }; + + #pragma db object + struct object2 + { + object2 () {} + object2 (const char* s_, shared_ptr<object1> o1_): s (s_), o1 (o1_) {} + + #pragma db id auto + int id; + + std::string s; + + #pragma db load(lazy) + odb::section r; + + #pragma db section(r) + shared_ptr<object1> o1; + }; + + #pragma db view object(object1) object(object2) + struct view1 + { + shared_ptr<object1> o1; + shared_ptr<object2> o2; + }; +} + +#endif // TEST6_HXX |