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