1 #ifndef BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_ROUTE_HPP
2 #define BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_ROUTE_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 // polymorphic_oarchive_route.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 
19 #include <string>
20 #include <ostream>
21 #include <cstddef> // size_t
22 
23 #include <boost/config.hpp>
24 #if defined(BOOST_NO_STDC_NAMESPACE)
25 namespace std{
26     using ::size_t;
27 } // namespace std
28 #endif
29 
30 #include <boost/cstdint.hpp>
31 #include <boost/integer_traits.hpp>
32 #include <boost/archive/polymorphic_oarchive.hpp>
33 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
34 
35 namespace boost {
36 namespace serialization {
37     class extended_type_info;
38 } // namespace serialization
39 namespace archive {
40 namespace detail{
41 
42 class basic_oserializer;
43 class basic_pointer_oserializer;
44 
45 #ifdef BOOST_MSVC
46 #  pragma warning(push)
47 #  pragma warning(disable : 4511 4512)
48 #endif
49 
50 template<class ArchiveImplementation>
51 class polymorphic_oarchive_route :
52     public polymorphic_oarchive,
53     // note: gcc dynamic cross cast fails if the the derivation below is
54     // not public.  I think this is a mistake.
55     public /*protected*/ ArchiveImplementation
56 {
57 private:
58     // these are used by the serialization library.
save_object(const void * x,const detail::basic_oserializer & bos)59     virtual void save_object(
60         const void *x,
61         const detail::basic_oserializer & bos
62     ){
63         ArchiveImplementation::save_object(x, bos);
64     }
save_pointer(const void * t,const detail::basic_pointer_oserializer * bpos_ptr)65     virtual void save_pointer(
66         const void * t,
67         const detail::basic_pointer_oserializer * bpos_ptr
68     ){
69         ArchiveImplementation::save_pointer(t, bpos_ptr);
70     }
save_null_pointer()71     virtual void save_null_pointer(){
72         ArchiveImplementation::save_null_pointer();
73     }
74     // primitive types the only ones permitted by polymorphic archives
save(const bool t)75     virtual void save(const bool t){
76         ArchiveImplementation::save(t);
77     }
save(const char t)78     virtual void save(const char t){
79         ArchiveImplementation::save(t);
80     }
save(const signed char t)81     virtual void save(const signed char t){
82         ArchiveImplementation::save(t);
83     }
save(const unsigned char t)84     virtual void save(const unsigned char t){
85         ArchiveImplementation::save(t);
86     }
87     #ifndef BOOST_NO_CWCHAR
88     #ifndef BOOST_NO_INTRINSIC_WCHAR_T
save(const wchar_t t)89     virtual void save(const wchar_t t){
90         ArchiveImplementation::save(t);
91     }
92     #endif
93     #endif
save(const short t)94     virtual void save(const short t){
95         ArchiveImplementation::save(t);
96     }
save(const unsigned short t)97     virtual void save(const unsigned short t){
98         ArchiveImplementation::save(t);
99     }
save(const int t)100     virtual void save(const int t){
101         ArchiveImplementation::save(t);
102     }
save(const unsigned int t)103     virtual void save(const unsigned int t){
104         ArchiveImplementation::save(t);
105     }
save(const long t)106     virtual void save(const long t){
107         ArchiveImplementation::save(t);
108     }
save(const unsigned long t)109     virtual void save(const unsigned long t){
110         ArchiveImplementation::save(t);
111     }
112     #if defined(BOOST_HAS_LONG_LONG)
save(const boost::long_long_type t)113     virtual void save(const boost::long_long_type t){
114         ArchiveImplementation::save(t);
115     }
save(const boost::ulong_long_type t)116     virtual void save(const boost::ulong_long_type t){
117         ArchiveImplementation::save(t);
118     }
119     #elif defined(BOOST_HAS_MS_INT64)
save(const boost::int64_t t)120     virtual void save(const boost::int64_t t){
121         ArchiveImplementation::save(t);
122     }
save(const boost::uint64_t t)123     virtual void save(const boost::uint64_t t){
124         ArchiveImplementation::save(t);
125     }
126     #endif
save(const float t)127     virtual void save(const float t){
128         ArchiveImplementation::save(t);
129     }
save(const double t)130     virtual void save(const double t){
131         ArchiveImplementation::save(t);
132     }
save(const std::string & t)133     virtual void save(const std::string & t){
134         ArchiveImplementation::save(t);
135     }
136     #ifndef BOOST_NO_STD_WSTRING
save(const std::wstring & t)137     virtual void save(const std::wstring & t){
138         ArchiveImplementation::save(t);
139     }
140     #endif
get_library_version() const141     virtual library_version_type get_library_version() const{
142         return ArchiveImplementation::get_library_version();
143     }
get_flags() const144     virtual unsigned int get_flags() const {
145         return ArchiveImplementation::get_flags();
146     }
save_binary(const void * t,std::size_t size)147     virtual void save_binary(const void * t, std::size_t size){
148         ArchiveImplementation::save_binary(t, size);
149     }
150     // used for xml and other tagged formats default does nothing
save_start(const char * name)151     virtual void save_start(const char * name){
152         ArchiveImplementation::save_start(name);
153     }
save_end(const char * name)154     virtual void save_end(const char * name){
155         ArchiveImplementation::save_end(name);
156     }
end_preamble()157     virtual void end_preamble(){
158         ArchiveImplementation::end_preamble();
159     }
register_basic_serializer(const detail::basic_oserializer & bos)160     virtual void register_basic_serializer(const detail::basic_oserializer & bos){
161         ArchiveImplementation::register_basic_serializer(bos);
162     }
163     virtual helper_collection &
get_helper_collection()164     get_helper_collection(){
165         return ArchiveImplementation::get_helper_collection();
166     }
167 public:
168     // this can't be inheriteded because they appear in mulitple
169     // parents
170     typedef mpl::bool_<false> is_loading;
171     typedef mpl::bool_<true> is_saving;
172     // the << operator
173     template<class T>
operator <<(T & t)174     polymorphic_oarchive & operator<<(T & t){
175         return polymorphic_oarchive::operator<<(t);
176     }
177     // the & operator
178     template<class T>
operator &(T & t)179     polymorphic_oarchive & operator&(T & t){
180         return polymorphic_oarchive::operator&(t);
181     }
182     // register type function
183     template<class T>
184     const basic_pointer_oserializer *
register_type(T * t=NULL)185     register_type(T * t = NULL){
186         return ArchiveImplementation::register_type(t);
187     }
188     // all current archives take a stream as constructor argument
189     template <class _Elem, class _Tr>
polymorphic_oarchive_route(std::basic_ostream<_Elem,_Tr> & os,unsigned int flags=0)190     polymorphic_oarchive_route(
191         std::basic_ostream<_Elem, _Tr> & os,
192         unsigned int flags = 0
193     ) :
194         ArchiveImplementation(os, flags)
195     {}
~polymorphic_oarchive_route()196     virtual ~polymorphic_oarchive_route(){};
197 };
198 
199 } // namespace detail
200 } // namespace archive
201 } // namespace boost
202 
203 #ifdef BOOST_MSVC
204 #pragma warning(pop)
205 #endif
206 
207 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
208 
209 #endif // BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_DISPATCH_HPP
210