]> Dogcows Code - chaz/yoink/blob - src/stlplus/persistence/persistent_string.tpp
testing new non-autotools build system
[chaz/yoink] / src / stlplus / persistence / persistent_string.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 // STL strings
16
17 template<typename charT, typename traits, typename allocator, typename D>
18 void dump_basic_string(dump_context& context, const std::basic_string<charT,traits,allocator>& data, D dump_fn)
19 throw(persistent_dump_failed)
20 {
21 unsigned size = data.size();
22 dump_unsigned(context, size);
23 for (unsigned i = 0; i < size; i++)
24 {
25 charT ch = data[i];
26 dump_fn(context,ch);
27 }
28 }
29
30 template<typename charT, typename traits, typename allocator, typename R>
31 void restore_basic_string(restore_context& context, std::basic_string<charT,traits,allocator>& data, R restore_fn)
32 throw(persistent_restore_failed)
33 {
34 data.erase();
35 unsigned size = 0;
36 restore_unsigned(context, size);
37 for (unsigned i = 0; i < size; i++)
38 {
39 charT ch;
40 restore_fn(context,ch);
41 data += ch;
42 }
43 }
44
45 ////////////////////////////////////////////////////////////////////////////////
46
47 } // end namespace stlplus
This page took 0.032569 seconds and 4 git commands to generate.