aboutsummaryrefslogtreecommitdiff
path: root/common/composite/test.hxx
blob: 08497c8fa6106bc93347ca29838dff0625fcc9d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// file      : common/composite/test.hxx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2011 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