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

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