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