Common ODB Runtime Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
std-unordered-set-traits.hxx
Go to the documentation of this file.
1 // file : odb/std-unordered-set-traits.hxx
2 // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
3 // license : GNU GPL v2; see accompanying LICENSE file
4 
5 #ifndef ODB_STD_UNORDERED_SET_TRAITS_HXX
6 #define ODB_STD_UNORDERED_SET_TRAITS_HXX
7 
8 #include <odb/pre.hxx>
9 
10 #include <utility> // std::move
11 #include <unordered_set>
12 
13 #include <odb/container-traits.hxx>
14 
15 namespace odb
16 {
17  template <typename V, typename H, typename P, typename A>
18  class access::container_traits<std::unordered_set<V, H, P, A>>
19  {
20  public:
21  static const container_kind kind = ck_set;
22  static const bool smart = false;
23 
24  typedef std::unordered_set<V, H, P, A> container_type;
25  typedef V value_type;
26 
28 
29  public:
30  static void
31  persist (const container_type& c, const functions& f)
32  {
33  for (typename container_type::const_iterator i (c.begin ()),
34  e (c.end ()); i != e; ++i)
35  f.insert (*i);
36  }
37 
38  static void
39  load (container_type& c, bool more, const functions& f)
40  {
41  c.clear ();
42 
43  while (more)
44  {
45  value_type v;
46  more = f.select (v);
47  c.insert (std::move (v));
48  }
49  }
50 
51  static void
52  update (const container_type& c, const functions& f)
53  {
54  f.delete_ ();
55 
56  for (typename container_type::const_iterator i (c.begin ()),
57  e (c.end ()); i != e; ++i)
58  f.insert (*i);
59  }
60 
61  static void
62  erase (const functions& f)
63  {
64  f.delete_ ();
65  }
66  };
67 
68  // @@ Does multiset preserve insertion order of equal elements? The
69  // current implementation in the generated code does not guarantee
70  // this.
71  //
72  template <typename V, typename H, typename P, typename A>
73  class access::container_traits<std::unordered_multiset<V, H, P, A>>
74  {
75  public:
76  static const container_kind kind = ck_multiset;
77  static const bool smart = false;
78 
79  typedef std::unordered_multiset<V, H, P, A> container_type;
80  typedef V value_type;
81 
83 
84  public:
85  static void
86  persist (const container_type& c, const functions& f)
87  {
88  for (typename container_type::const_iterator i (c.begin ()),
89  e (c.end ()); i != e; ++i)
90  f.insert (*i);
91  }
92 
93  static void
94  load (container_type& c, bool more, const functions& f)
95  {
96  c.clear ();
97 
98  while (more)
99  {
100  value_type v;
101  more = f.select (v);
102  c.insert (std::move (v));
103  }
104  }
105 
106  static void
107  update (const container_type& c, const functions& f)
108  {
109  f.delete_ ();
110 
111  for (typename container_type::const_iterator i (c.begin ()),
112  e (c.end ()); i != e; ++i)
113  f.insert (*i);
114  }
115 
116  static void
117  erase (const functions& f)
118  {
119  f.delete_ ();
120  }
121  };
122 }
123 
124 #include <odb/post.hxx>
125 
126 #endif // ODB_STD_UNORDERED_SET_TRAITS_HXX
V value_type
Definition: std-unordered-set-traits.hxx:25
Definition: container-traits.hxx:130
set_functions< value_type > functions
Definition: std-unordered-set-traits.hxx:82
void delete_() const
Definition: container-traits.hxx:147
Definition: container-traits.hxx:21
static void persist(const container_type &c, const functions &f)
Definition: std-unordered-set-traits.hxx:31
Definition: container-traits.hxx:20
Definition: forward.hxx:119
container_kind
Definition: container-traits.hxx:17
set_functions< value_type > functions
Definition: std-unordered-set-traits.hxx:27
static void update(const container_type &c, const functions &f)
Definition: std-unordered-set-traits.hxx:107
std::unordered_set< V, H, P, A > container_type
Definition: std-unordered-set-traits.hxx:24
static void erase(const functions &f)
Definition: std-unordered-set-traits.hxx:62
static void persist(const container_type &c, const functions &f)
Definition: std-unordered-set-traits.hxx:86
std::unordered_multiset< V, H, P, A > container_type
Definition: std-unordered-set-traits.hxx:79
static void update(const container_type &c, const functions &f)
Definition: std-unordered-set-traits.hxx:52
V value_type
Definition: std-unordered-set-traits.hxx:80
static void load(container_type &c, bool more, const functions &f)
Definition: std-unordered-set-traits.hxx:39
static void erase(const functions &f)
Definition: std-unordered-set-traits.hxx:117
bool select(V &next_value) const
Definition: container-traits.hxx:141
void insert(const V &value) const
Definition: container-traits.hxx:135
static void load(container_type &c, bool more, const functions &f)
Definition: std-unordered-set-traits.hxx:94