source: NonGTP/Boost/boost/archive/detail/interface_iarchive.hpp @ 857

Revision 857, 2.8 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]1#ifndef BOOST_ARCHIVE_DETAIL_INTERFACE_IARCHIVE_HPP
2#define BOOST_ARCHIVE_DETAIL_INTERFACE_IARCHIVE_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// interface_iarchive.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#include <string>
19#include <boost/cstdint.hpp>
20#include <boost/mpl/bool.hpp>
21#include <boost/archive/detail/auto_link_archive.hpp>
22#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
23
24namespace boost {
25template<class T>
26class shared_ptr;
27namespace serialization {
28    class extended_type_info;
29} // namespace serialization
30namespace archive {
31namespace detail {
32
33class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer;
34
35template<class Archive>
36class interface_iarchive
37{
38protected:
39    interface_iarchive(){};
40public:
41    /////////////////////////////////////////////////////////
42    // archive public interface
43    typedef mpl::bool_<true> is_loading;
44    typedef mpl::bool_<false> is_saving;
45
46    // return a pointer to the most derived class
47    Archive * This(){
48        return static_cast<Archive *>(this);
49    }
50
51    template<class T>
52    const basic_pointer_iserializer * register_type(T * = NULL){
53        const basic_pointer_iserializer & bpis =
54            archive::detail::instantiate_pointer_iserializer(
55                static_cast<Archive *>(NULL),
56                static_cast<T *>(NULL)
57            );
58        this->This()->register_basic_serializer(bpis.get_basic_serializer());
59        return & bpis;
60    }
61    void lookup_helper(
62        const boost::serialization::extended_type_info * const eti,
63        boost::shared_ptr<void> & sph
64    ){
65        this->This()->lookup_basic_helper(eti, sph);
66    }
67
68    void insert_helper(
69        const boost::serialization::extended_type_info * const eti,
70        shared_ptr<void> & sph
71    ){
72        this->This()->insert_basic_helper(eti, sph);
73    }
74    template<class T>
75    Archive & operator>>(T & t){
76        this->This()->load_override(t, 0);
77        return * this->This();
78    }
79
80    // the & operator
81    template<class T>
82    Archive & operator&(T & t){
83        return *(this->This()) >> t;
84    }
85};
86
87} // namespace detail
88} // namespace archive
89} // namespace boost
90
91#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
92
93#endif // BOOST_ARCHIVE_DETAIL_INTERFACE_IARCHIVE_HPP
Note: See TracBrowser for help on using the repository browser.