Chris@16
|
1 #ifndef BOOST_SERIALIZATION_SPLIT_FREE_HPP
|
Chris@16
|
2 #define BOOST_SERIALIZATION_SPLIT_FREE_HPP
|
Chris@16
|
3
|
Chris@16
|
4 // MS compatible compilers support #pragma once
|
Chris@101
|
5 #if defined(_MSC_VER)
|
Chris@16
|
6 # pragma once
|
Chris@16
|
7 #endif
|
Chris@16
|
8
|
Chris@16
|
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
Chris@16
|
10 // split_free.hpp:
|
Chris@16
|
11
|
Chris@16
|
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
Chris@16
|
13 // Use, modification and distribution is subject to the Boost Software
|
Chris@16
|
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
15 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
16
|
Chris@16
|
17 // See http://www.boost.org for updates, documentation, and revision history.
|
Chris@16
|
18
|
Chris@16
|
19 #include <boost/config.hpp>
|
Chris@16
|
20 #include <boost/mpl/eval_if.hpp>
|
Chris@16
|
21 #include <boost/mpl/identity.hpp>
|
Chris@16
|
22 #include <boost/serialization/serialization.hpp>
|
Chris@16
|
23
|
Chris@16
|
24 namespace boost {
|
Chris@16
|
25 namespace archive {
|
Chris@16
|
26 namespace detail {
|
Chris@16
|
27 template<class Archive> class interface_oarchive;
|
Chris@16
|
28 template<class Archive> class interface_iarchive;
|
Chris@16
|
29 } // namespace detail
|
Chris@16
|
30 } // namespace archive
|
Chris@16
|
31
|
Chris@16
|
32 namespace serialization {
|
Chris@16
|
33
|
Chris@16
|
34 //namespace detail {
|
Chris@16
|
35 template<class Archive, class T>
|
Chris@16
|
36 struct free_saver {
|
Chris@16
|
37 static void invoke(
|
Chris@16
|
38 Archive & ar,
|
Chris@16
|
39 const T & t,
|
Chris@16
|
40 const unsigned int file_version
|
Chris@16
|
41 ){
|
Chris@16
|
42 // use function overload (version_type) to workaround
|
Chris@16
|
43 // two-phase lookup issue
|
Chris@16
|
44 const version_type v(file_version);
|
Chris@16
|
45 save(ar, t, v);
|
Chris@16
|
46 }
|
Chris@16
|
47 };
|
Chris@16
|
48 template<class Archive, class T>
|
Chris@16
|
49 struct free_loader {
|
Chris@16
|
50 static void invoke(
|
Chris@16
|
51 Archive & ar,
|
Chris@16
|
52 T & t,
|
Chris@16
|
53 const unsigned int file_version
|
Chris@16
|
54 ){
|
Chris@16
|
55 // use function overload (version_type) to workaround
|
Chris@16
|
56 // two-phase lookup issue
|
Chris@16
|
57 const version_type v(file_version);
|
Chris@16
|
58 load(ar, t, v);
|
Chris@16
|
59 }
|
Chris@16
|
60 };
|
Chris@16
|
61 //} // namespace detail
|
Chris@16
|
62
|
Chris@16
|
63 template<class Archive, class T>
|
Chris@16
|
64 inline void split_free(
|
Chris@16
|
65 Archive & ar,
|
Chris@16
|
66 T & t,
|
Chris@16
|
67 const unsigned int file_version
|
Chris@16
|
68 ){
|
Chris@101
|
69 typedef typename mpl::eval_if<
|
Chris@101
|
70 typename Archive::is_saving,
|
Chris@16
|
71 mpl::identity</* detail:: */ free_saver<Archive, T> >,
|
Chris@16
|
72 mpl::identity</* detail:: */ free_loader<Archive, T> >
|
Chris@16
|
73 >::type typex;
|
Chris@16
|
74 typex::invoke(ar, t, file_version);
|
Chris@16
|
75 }
|
Chris@16
|
76
|
Chris@16
|
77 } // namespace serialization
|
Chris@16
|
78 } // namespace boost
|
Chris@16
|
79
|
Chris@16
|
80 #define BOOST_SERIALIZATION_SPLIT_FREE(T) \
|
Chris@16
|
81 namespace boost { namespace serialization { \
|
Chris@16
|
82 template<class Archive> \
|
Chris@16
|
83 inline void serialize( \
|
Chris@16
|
84 Archive & ar, \
|
Chris@16
|
85 T & t, \
|
Chris@16
|
86 const unsigned int file_version \
|
Chris@16
|
87 ){ \
|
Chris@16
|
88 split_free(ar, t, file_version); \
|
Chris@16
|
89 } \
|
Chris@16
|
90 }}
|
Chris@16
|
91 /**/
|
Chris@16
|
92
|
Chris@16
|
93 #endif // BOOST_SERIALIZATION_SPLIT_FREE_HPP
|