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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
// file : boost/common/multi-index/test.hxx
// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef TEST_HXX
#define TEST_HXX
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/identity.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index/random_access_index.hpp>
#include <odb/core.hxx>
namespace mi = boost::multi_index;
#pragma db value
struct comp
{
comp () {}
comp (int n, const std::string& s) : num (n), str (s) {}
#pragma db column("number")
int num;
std::string str;
};
inline bool
operator== (const comp& x, const comp& y)
{
return x.num == y.num && x.str == y.str;
}
typedef
mi::multi_index_container<
int,
mi::indexed_by<mi::sequenced<> >
> int_lst;
typedef
mi::multi_index_container<
int,
mi::indexed_by<mi::random_access<> >
> int_vec;
typedef
mi::multi_index_container<
int,
mi::indexed_by<mi::ordered_unique<mi::identity<int> > >
> int_set;
typedef
mi::multi_index_container<
int,
mi::indexed_by<
mi::sequenced<>,
mi::ordered_unique<mi::identity<int> >
>
> int_lst_set;
typedef
mi::multi_index_container<
comp,
mi::indexed_by<
mi::ordered_unique<mi::member<comp, std::string, &comp::str> >,
mi::random_access<>
>
> comp_set_vec;
typedef
mi::multi_index_container<
comp,
mi::indexed_by<
mi::ordered_unique<mi::member<comp, int, &comp::num> >,
mi::ordered_unique<mi::member<comp, std::string, &comp::str> >
>
> comp_set_set;
#pragma db object
struct object
{
object () {}
object (const std::string& id): id (id) {}
#pragma db id
std::string id;
int_lst il;
int_lst iv;
int_set is;
int_lst_set ils;
comp_set_vec csv;
comp_set_set css;
};
inline bool
operator== (const object& x, const object& y)
{
return
x.id == y.id &&
x.il == y.il &&
x.iv == y.iv &&
x.is == y.is &&
x.ils == y.ils &&
x.csv == y.csv &&
x.css == y.css;
}
#endif // TEST_HXX
|