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