]> Dogcows Code - chaz/yoink/blob - src/stlplus/persistence/persistent_hash.tpp
testing new non-autotools build system
[chaz/yoink] / src / stlplus / persistence / persistent_hash.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 K, typename T, typename H, typename E, typename DK, typename DT>
17 void dump_hash(dump_context& context, const hash<K,T,H,E>& data, DK key_fn, DT val_fn)
18 throw(persistent_dump_failed)
19 {
20 dump_unsigned(context,data.size());
21 for (typename hash<K,T,H,E>::const_iterator i = data.begin(); i != data.end(); i++)
22 {
23 key_fn(context,i->first);
24 val_fn(context,i->second);
25 }
26 }
27
28 template<typename K, typename T, typename H, typename E, typename RK, typename RT>
29 void restore_hash(restore_context& context, hash<K,T,H,E>& data, RK key_fn, RT val_fn)
30 throw(persistent_restore_failed)
31 {
32 data.erase();
33 unsigned size = 0;
34 restore_unsigned(context,size);
35 for (unsigned j = 0; j < size; j++)
36 {
37 K key;
38 key_fn(context,key);
39 val_fn(context,data[key]);
40 }
41 }
42
43 ////////////////////////////////////////////////////////////////////////////////
44
45 } // end namespace stlplus
This page took 0.034291 seconds and 4 git commands to generate.