]> Dogcows Code - chaz/yoink/blob - src/stlplus/persistence/persistent_list.tpp
archiving support for releases
[chaz/yoink] / src / stlplus / persistence / persistent_list.tpp
1 ////////////////////////////////////////////////////////////////////////////////
2
3 // Author: Andy Rushton
4 // Copyright: (c) Southampton University 1999-2004
5 // (c) Andy Rushton 2004-2009
6 // License: BSD License, see ../docs/license.html
7
8 ////////////////////////////////////////////////////////////////////////////////
9 #include "persistent_int.hpp"
10
11 namespace stlplus
12 {
13
14 ////////////////////////////////////////////////////////////////////////////////
15
16 template<typename T, typename D>
17 void dump_list(dump_context& context, const std::list<T>& data, D dump_fn)
18 throw(persistent_dump_failed)
19 {
20 dump_unsigned(context,data.size());
21 for (typename std::list<T>::const_iterator i = data.begin(); i != data.end(); i++)
22 dump_fn(context,*i);
23 }
24
25 template<typename T, typename R>
26 void restore_list(restore_context& context, std::list<T>& data, R restore_fn)
27 throw(persistent_restore_failed)
28 {
29 data.clear();
30 unsigned size = 0;
31 restore_unsigned(context,size);
32 for (unsigned i = 0; i < size; i++)
33 {
34 data.push_back(T());
35 restore_fn(context,data.back());
36 }
37 }
38
39 ////////////////////////////////////////////////////////////////////////////////
40
41 } // end namespace stlplus
This page took 0.036048 seconds and 4 git commands to generate.