binary_oarchive_impl.hpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef BOOST_ARCHIVE_BINARY_OARCHIVE_IMPL_HPP
  2. #define BOOST_ARCHIVE_BINARY_OARCHIVE_IMPL_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. // binary_oarchive_impl.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 <ostream>
  15. #include <boost/config.hpp>
  16. #include <boost/serialization/pfto.hpp>
  17. #include <boost/archive/basic_binary_oprimitive.hpp>
  18. #include <boost/archive/basic_binary_oarchive.hpp>
  19. #ifdef BOOST_MSVC
  20. # pragma warning(push)
  21. # pragma warning(disable : 4511 4512)
  22. #endif
  23. namespace boost {
  24. namespace archive {
  25. template<class Archive, class Elem, class Tr>
  26. class binary_oarchive_impl :
  27. public basic_binary_oprimitive<Archive, Elem, Tr>,
  28. public basic_binary_oarchive<Archive>
  29. {
  30. #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
  31. public:
  32. #else
  33. friend class detail::interface_oarchive<Archive>;
  34. friend class basic_binary_oarchive<Archive>;
  35. friend class save_access;
  36. protected:
  37. #endif
  38. // note: the following should not needed - but one compiler (vc 7.1)
  39. // fails to compile one test (test_shared_ptr) without it !!!
  40. // make this protected so it can be called from a derived archive
  41. template<class T>
  42. void save_override(T & t, BOOST_PFTO int){
  43. this->basic_binary_oarchive<Archive>::save_override(t, 0L);
  44. }
  45. void init(unsigned int flags) {
  46. if(0 != (flags & no_header))
  47. return;
  48. #if ! defined(__MWERKS__)
  49. this->basic_binary_oarchive<Archive>::init();
  50. this->basic_binary_oprimitive<Archive, Elem, Tr>::init();
  51. #else
  52. basic_binary_oarchive<Archive>::init();
  53. basic_binary_oprimitive<Archive, Elem, Tr>::init();
  54. #endif
  55. }
  56. binary_oarchive_impl(
  57. std::basic_streambuf<Elem, Tr> & bsb,
  58. unsigned int flags
  59. ) :
  60. basic_binary_oprimitive<Archive, Elem, Tr>(
  61. bsb,
  62. 0 != (flags & no_codecvt)
  63. ),
  64. basic_binary_oarchive<Archive>(flags)
  65. {
  66. init(flags);
  67. }
  68. binary_oarchive_impl(
  69. std::basic_ostream<Elem, Tr> & os,
  70. unsigned int flags
  71. ) :
  72. basic_binary_oprimitive<Archive, Elem, Tr>(
  73. * os.rdbuf(),
  74. 0 != (flags & no_codecvt)
  75. ),
  76. basic_binary_oarchive<Archive>(flags)
  77. {
  78. init(flags);
  79. }
  80. };
  81. } // namespace archive
  82. } // namespace boost
  83. #ifdef BOOST_MSVC
  84. #pragma warning(pop)
  85. #endif
  86. #endif // BOOST_ARCHIVE_BINARY_OARCHIVE_IMPL_HPP