Common ODB Runtime Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
std-array-traits.hxx
Go to the documentation of this file.
1 // file : odb/std-array-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_ARRAY_TRAITS_HXX
6 #define ODB_STD_ARRAY_TRAITS_HXX
7 
8 #include <odb/pre.hxx>
9 
10 #include <array>
11 #include <cstddef> // std::size_t
12 #include <cassert>
13 
14 #include <odb/container-traits.hxx>
15 
16 namespace odb
17 {
18  template <typename V, std::size_t N>
19  class access::container_traits<std::array<V, N>>
20  {
21  public:
22  static const container_kind kind = ck_ordered;
23  static const bool smart = false;
24 
25  typedef std::array<V, N> container_type;
26 
27  typedef V value_type;
28  typedef typename container_type::size_type index_type;
29 
31 
32  public:
33  static void
34  persist (const container_type& c, const functions& f)
35  {
36  for (index_type i (0); i < N; ++i)
37  f.insert (i, c[i]);
38  }
39 
40  static void
41  load (container_type& c, bool more, const functions& f)
42  {
43  index_type i (0);
44 
45  for (; more && i < N; ++i)
46  {
47  index_type dummy;
48  more = f.select (dummy, c[i]);
49  }
50 
51  assert (!more && i == N);
52  }
53 
54  static void
55  update (const container_type& c, const functions& f)
56  {
57  f.delete_ ();
58 
59  for (index_type i (0); i < N; ++i)
60  f.insert (i, c[i]);
61  }
62 
63  static void
64  erase (const functions& f)
65  {
66  f.delete_ ();
67  }
68  };
69 }
70 
71 #include <odb/post.hxx>
72 
73 #endif // ODB_STD_ARRAY_TRAITS_HXX
void insert(I index, const V &value) const
Definition: container-traits.hxx:49
static void update(const container_type &c, const functions &f)
Definition: std-array-traits.hxx:55
Definition: forward.hxx:119
bool select(I &next_index, V &next_value) const
Definition: container-traits.hxx:55
std::array< V, N > container_type
Definition: std-array-traits.hxx:25
container_kind
Definition: container-traits.hxx:17
V value_type
Definition: std-array-traits.hxx:27
container_type::size_type index_type
Definition: std-array-traits.hxx:28
static void erase(const functions &f)
Definition: std-array-traits.hxx:64
static void persist(const container_type &c, const functions &f)
Definition: std-array-traits.hxx:34
Definition: container-traits.hxx:19
void delete_() const
Definition: container-traits.hxx:61
ordered_functions< index_type, value_type > functions
Definition: std-array-traits.hxx:30
Definition: container-traits.hxx:33
static void load(container_type &c, bool more, const functions &f)
Definition: std-array-traits.hxx:41