1 #ifndef BOOST_SERIALIZATION_ACCESS_HPP
2 #define BOOST_SERIALIZATION_ACCESS_HPP
4 // MS compatible compilers support #pragma once
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // access.hpp: interface for serialization system.
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)
17 // See http://www.boost.org for updates, documentation, and revision history.
19 #include <boost/config.hpp>
25 template<class Archive, class T>
27 template<class Archive, class T>
30 } // namespace archive
32 namespace serialization {
34 // forward declarations
35 template<class Archive, class T>
36 inline void serialize_adl(Archive &, T &, const unsigned int);
38 template<class Archive, class T>
40 template<class Archive, class T>
44 // use an "accessor class so that we can use:
45 // "friend class boost::serialization::access;"
46 // in any serialized class to permit clean, safe access to private class members
47 // by the serialization system
51 // grant access to "real" serialization defaults
52 #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
55 template<class Archive, class T>
56 friend struct detail::member_saver;
57 template<class Archive, class T>
58 friend struct detail::member_loader;
59 template<class Archive, class T>
60 friend class archive::detail::iserializer;
61 template<class Archive, class T>
62 friend class archive::detail::oserializer;
63 template<class Archive, class T>
64 friend inline void serialize(
67 const unsigned int file_version
69 template<class Archive, class T>
70 friend inline void save_construct_data(
73 const unsigned int file_version
75 template<class Archive, class T>
76 friend inline void load_construct_data(
79 const unsigned int file_version
83 // pass calls to users's class implementation
84 template<class Archive, class T>
85 static void member_save(
89 const unsigned int file_version
91 t.save(ar, file_version);
93 template<class Archive, class T>
94 static void member_load(
97 const unsigned int file_version
99 t.load(ar, file_version);
101 template<class Archive, class T>
102 static void serialize(
105 const unsigned int file_version
107 // note: if you get a compile time error here with a
108 // message something like:
109 // cannot convert parameter 1 from <file type 1> to <file type 2 &>
110 // a likely possible cause is that the class T contains a
111 // serialize function - but that serialize function isn't
112 // a template and corresponds to a file type different than
113 // the class Archive. To resolve this, don't include an
114 // archive type other than that for which the serialization
115 // function is defined!!!
116 t.serialize(ar, file_version);
119 static void destroy( const T * t) // const appropriate here?
121 // the const business is an MSVC 6.0 hack that should be
122 // benign on everything else
123 delete const_cast<T *>(t);
126 static void construct(T * t){
127 // default is inplace invocation of default constructor
128 // Note the :: before the placement new. Required if the
129 // class doesn't have a class-specific placement new defined.
132 template<class T, class U>
133 static T & cast_reference(U & u){
134 return static_cast<T &>(u);
136 template<class T, class U>
137 static T * cast_pointer(U * u){
138 return static_cast<T *>(u);
142 } // namespace serialization
145 #endif // BOOST_SERIALIZATION_ACCESS_HPP