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) |
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 <cstddef> // NULL |
19 | #include <boost/cstdint.hpp> |
20 | #include <boost/mpl/bool.hpp> |
21 | #include <boost/detail/workaround.hpp> |
22 | |
23 | #include <boost/archive/detail/auto_link_archive.hpp> |
24 | #include <boost/archive/detail/oserializer.hpp> |
25 | #include <boost/archive/detail/abi_prefix.hpp> // must be the last header |
26 | |
27 | #include <boost/serialization/singleton.hpp> |
28 | |
29 | namespace boost { |
30 | namespace archive { |
31 | namespace detail { |
32 | |
33 | class basic_pointer_oserializer; |
34 | |
35 | template<class Archive> |
36 | class interface_oarchive |
37 | { |
38 | protected: |
39 | interface_oarchive() {} |
40 | public: |
41 | ///////////////////////////////////////////////////////// |
42 | // archive public interface |
43 | typedef mpl::bool_<false> is_loading; |
44 | typedef mpl::bool_<true> 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_oserializer * |
53 | register_type(const T * = NULL){ |
54 | const basic_pointer_oserializer & bpos = |
55 | boost::serialization::singleton< |
56 | pointer_oserializer<Archive, T> |
57 | >::get_const_instance(); |
58 | this->This()->register_basic_serializer(bpos.get_basic_serializer()); |
59 | return & bpos; |
60 | } |
61 | |
62 | template<class Helper> |
63 | Helper & |
64 | get_helper(void * const id = 0){ |
65 | helper_collection & hc = this->This()->get_helper_collection(); |
66 | return hc.template find_helper<Helper>(id); |
67 | } |
68 | |
69 | template<class T> |
70 | Archive & operator<<(const T & t){ |
71 | this->This()->save_override(t); |
72 | return * this->This(); |
73 | } |
74 | |
75 | // the & operator |
76 | template<class T> |
77 | Archive & operator&(const T & t){ |
78 | return * this ->This() << t; |
79 | } |
80 | }; |
81 | |
82 | } // namespace detail |
83 | } // namespace archive |
84 | } // namespace boost |
85 | |
86 | #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas |
87 | |
88 | #endif // BOOST_ARCHIVE_DETAIL_INTERFACE_IARCHIVE_HPP |
89 |