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