]> Dogcows Code - chaz/yoink/blob - src/stlplus/persistence/persistent_shortcuts.hpp
archiving support for releases
[chaz/yoink] / src / stlplus / persistence / persistent_shortcuts.hpp
1 #ifndef STLPLUS_PERSISTENT_SHORTCUTS
2 #define STLPLUS_PERSISTENT_SHORTCUTS
3 ////////////////////////////////////////////////////////////////////////////////
4
5 // Author: Andy Rushton
6 // Copyright: (c) Southampton University 1999-2004
7 // (c) Andy Rushton 2004-2009
8 // License: BSD License, see ../docs/license.html
9
10 // Short-cut functions for dumping and restoring to common targets. These do
11 // the whole dump operation in a single function call.
12
13 // They take as their second template argument a dump or restore functor which
14 // is then called to perform the dump/restore operation.
15
16 // They use an installer callback function to install any polymorphic type
17 // handlers required prior to performing the dump/restore. If there are no
18 // polymorphic types used in the data structure, then the callback can be set
19 // to null (i.e. 0).
20
21 ////////////////////////////////////////////////////////////////////////////////
22 #include "persistence_fixes.hpp"
23 #include "persistent_contexts.hpp"
24
25 ////////////////////////////////////////////////////////////////////////////////
26
27 namespace stlplus
28 {
29
30 ////////////////////////////////////////////////////////////////////////////////
31 // arbitrary IOStream device
32 // must be in binary mode
33
34 template<typename T, class D>
35 void dump_to_device(const T& source, std::ostream& result, D dump_fn, dump_context::installer installer)
36 throw(persistent_dump_failed);
37
38 template<typename T, class R>
39 void restore_from_device(std::istream& source, T& result, R restore_fn, restore_context::installer installer)
40 throw(persistent_restore_failed);
41
42 ////////////////////////////////////////////////////////////////////////////////
43 // string IO device
44
45 template<typename T, class D>
46 void dump_to_string(const T& source, std::string& result, D dump_fn, dump_context::installer installer)
47 throw(persistent_dump_failed);
48
49 template<typename T, class R>
50 void restore_from_string(const std::string& source, T& result, R restore_fn, restore_context::installer installer)
51 throw(persistent_restore_failed);
52
53 ////////////////////////////////////////////////////////////////////////////////
54 // file IO device
55
56 template<typename T, class D>
57 void dump_to_file(const T& source, const std::string& filename, D dump_fn, dump_context::installer installer)
58 throw(persistent_dump_failed);
59
60 template<typename T, class R>
61 void restore_from_file(const std::string& filename, T& result, R restore_fn, restore_context::installer installer)
62 throw(persistent_restore_failed);
63
64 ////////////////////////////////////////////////////////////////////////////////
65
66 } // end namespace stlplus
67
68 ////////////////////////////////////////////////////////////////////////////////
69 #include "persistent_shortcuts.tpp"
70 #endif
This page took 0.034123 seconds and 4 git commands to generate.