PageRenderTime 52ms CodeModel.GetById 20ms app.highlight 27ms RepoModel.GetById 1ms app.codeStats 1ms

/Src/Dependencies/Boost/boost/archive/detail/polymorphic_oarchive_route.hpp

http://hadesmem.googlecode.com/
C++ Header | 205 lines | 171 code | 15 blank | 19 comment | 1 complexity | 2a5630cb00e0c79ae4c75b8f8761e199 MD5 | raw file
  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) && (_MSC_VER >= 1020)
  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)
 25namespace 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
 35namespace boost {
 36namespace serialization {
 37    class extended_type_info;
 38} // namespace serialization
 39namespace archive {
 40namespace detail{
 41
 42class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer;
 43class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_oserializer;
 44
 45#ifdef BOOST_MSVC
 46#  pragma warning(push)
 47#  pragma warning(disable : 4511 4512)
 48#endif
 49
 50template<class ArchiveImplementation>
 51class 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{
 57private:
 58    // these are used by the serialization library.
 59    virtual void save_object(
 60        const void *x,
 61        const detail::basic_oserializer & bos
 62    ){
 63        ArchiveImplementation::save_object(x, bos);
 64    }
 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    }
 71    virtual void save_null_pointer(){
 72        ArchiveImplementation::save_null_pointer();
 73    }
 74    // primitive types the only ones permitted by polymorphic archives
 75    virtual void save(const bool t){
 76        ArchiveImplementation::save(t);
 77    }
 78    virtual void save(const char t){
 79        ArchiveImplementation::save(t);
 80    }
 81    virtual void save(const signed char t){
 82        ArchiveImplementation::save(t);
 83    }
 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
 89    virtual void save(const wchar_t t){
 90        ArchiveImplementation::save(t);
 91    }
 92    #endif
 93    #endif
 94    virtual void save(const short t){
 95        ArchiveImplementation::save(t);
 96    }
 97    virtual void save(const unsigned short t){
 98        ArchiveImplementation::save(t);
 99    }
100    virtual void save(const int t){
101        ArchiveImplementation::save(t);
102    }
103    virtual void save(const unsigned int t){
104        ArchiveImplementation::save(t);
105    }
106    virtual void save(const long t){
107        ArchiveImplementation::save(t);
108    }
109    virtual void save(const unsigned long t){
110        ArchiveImplementation::save(t);
111    }
112    #if defined(BOOST_HAS_LONG_LONG)
113    virtual void save(const boost::long_long_type t){
114        ArchiveImplementation::save(t);
115    }
116    virtual void save(const boost::ulong_long_type t){
117        ArchiveImplementation::save(t);
118    }
119    #elif defined(BOOST_HAS_MS_INT64)
120    virtual void save(const boost::int64_t t){
121        ArchiveImplementation::save(t);
122    }
123    virtual void save(const boost::uint64_t t){
124        ArchiveImplementation::save(t);
125    }
126    #endif
127    virtual void save(const float t){
128        ArchiveImplementation::save(t);
129    }
130    virtual void save(const double t){
131        ArchiveImplementation::save(t);
132    }
133    virtual void save(const std::string & t){
134        ArchiveImplementation::save(t);
135    }
136    #ifndef BOOST_NO_STD_WSTRING
137    virtual void save(const std::wstring & t){
138        ArchiveImplementation::save(t);
139    }
140    #endif
141    virtual library_version_type get_library_version() const{
142        return ArchiveImplementation::get_library_version();
143    }
144    virtual unsigned int get_flags() const {
145        return ArchiveImplementation::get_flags();
146    }
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
151    virtual void save_start(const char * name){
152        ArchiveImplementation::save_start(name);
153    }
154    virtual void save_end(const char * name){
155        ArchiveImplementation::save_end(name);
156    }
157    virtual void end_preamble(){
158        ArchiveImplementation::end_preamble();
159    }
160    virtual void register_basic_serializer(const detail::basic_oserializer & bos){
161        ArchiveImplementation::register_basic_serializer(bos);
162    }
163public:
164    // this can't be inheriteded because they appear in mulitple
165    // parents
166    typedef mpl::bool_<false> is_loading;
167    typedef mpl::bool_<true> is_saving;
168    // the << operator
169    template<class T>
170    polymorphic_oarchive & operator<<(T & t){
171        return polymorphic_oarchive::operator<<(t);
172    }
173    // the & operator
174    template<class T>
175    polymorphic_oarchive & operator&(T & t){
176        return polymorphic_oarchive::operator&(t);
177    }
178    // register type function
179    template<class T>
180    const basic_pointer_oserializer * 
181    register_type(T * t = NULL){
182        return ArchiveImplementation::register_type(t);
183    }
184    // all current archives take a stream as constructor argument
185    template <class _Elem, class _Tr>
186    polymorphic_oarchive_route(
187        std::basic_ostream<_Elem, _Tr> & os,
188        unsigned int flags = 0
189    ) :
190        ArchiveImplementation(os, flags)
191    {}
192    virtual ~polymorphic_oarchive_route(){};
193};
194
195} // namespace detail
196} // namespace archive
197} // namespace boost
198
199#ifdef BOOST_MSVC
200#pragma warning(pop)
201#endif
202
203#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
204
205#endif // BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_DISPATCH_HPP