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