Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/serialization/access.hpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 3.7 KB
Line 
1#ifndef BOOST_SERIALIZATION_ACCESS_HPP
2#define BOOST_SERIALIZATION_ACCESS_HPP
3
4// MS compatible compilers support #pragma once
5#if defined(_MSC_VER) && (_MSC_VER >= 1020)
6# pragma once
7#endif
8
9/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10// access.hpp: interface for serialization system.
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
21#include <boost/pfto.hpp>
22
23namespace boost {
24
25namespace archive {
26namespace detail {
27    template<class Archive, class T>
28    class iserializer;
29    template<class Archive, class T>
30    class oserializer;
31} // namespace detail
32} // namespace archive
33
34namespace serialization {
35
36// forward declarations
37template<class Archive, class T>
38inline void serialize_adl(Archive &, T &, const unsigned int);
39namespace detail {
40    template<class Archive, class T>
41    struct member_saver;
42    template<class Archive, class T>
43    struct member_loader;
44} // namespace detail
45
46// use an "accessor class so that we can use:
47// "friend class boost::serialization::access;"
48// in any serialized class to permit clean, safe access to private class members
49// by the serialization system
50
51class access {
52public:
53    // grant access to "real" serialization defaults
54#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
55public:
56#else
57    template<class Archive, class T>
58    friend struct detail::member_saver;
59    template<class Archive, class T>
60    friend struct detail::member_loader;
61    template<class Archive, class T>
62    friend class archive::detail::iserializer;
63    template<class Archive, class T>
64    friend class archive::detail::oserializer;
65    template<class Archive, class T>
66    friend inline void serialize(
67        Archive & ar, 
68        T & t, 
69        const BOOST_PFTO unsigned int file_version
70    );
71    template<class Archive, class T>
72    friend inline void save_construct_data(
73        Archive & ar, 
74        const T * t, 
75        const BOOST_PFTO unsigned int file_version
76    );
77    template<class Archive, class T>
78    friend inline void load_construct_data(
79        Archive & ar, 
80        T * t, 
81        const BOOST_PFTO unsigned int file_version
82    );
83#endif
84
85    // pass calls to users's class implementation
86    template<class Archive, class T>
87    static void member_save(
88        Archive & ar, 
89        //const T & t,
90        T & t,
91        const unsigned int file_version
92    ){
93        t.save(ar, file_version);
94    }
95    template<class Archive, class T>
96    static void member_load(
97        Archive & ar, 
98        T & t,
99        const unsigned int file_version
100    ){
101        t.load(ar, file_version);
102    }
103    template<class Archive, class T>
104    static void serialize(
105        Archive & ar, 
106        T & t, 
107        const unsigned int file_version
108    ){
109        t.serialize(ar, file_version);
110    }
111    template<class T>
112    static void destroy( const T * t) // const appropriate here?
113    {
114        // the const business is an MSVC 6.0 hack that should be
115        // benign on everything else
116        delete const_cast<T *>(t);
117    }
118    template<class Archive, class T>
119    static void construct(Archive & /* ar */, T * t){
120        // default is inplace invocation of default constructor
121        // Note the :: before the placement new. Required if the
122        // class doesn't have a class-specific placement new defined.
123        ::new(t)T;
124    }
125};
126
127} // namespace serialization
128} // namespace boost
129
130#endif // BOOST_SERIALIZATION_ACCESS_HPP
Note: See TracBrowser for help on using the repository browser.