binary_oarchive_impl.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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)
  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/archive/basic_binary_oprimitive.hpp>
  17. #include <boost/archive/basic_binary_oarchive.hpp>
  18. #ifdef BOOST_MSVC
  19. # pragma warning(push)
  20. # pragma warning(disable : 4511 4512)
  21. #endif
  22. namespace boost {
  23. namespace archive {
  24. namespace detail {
  25. template<class Archive> class interface_oarchive;
  26. } // namespace detail
  27. template<class Archive, class Elem, class Tr>
  28. class BOOST_SYMBOL_VISIBLE binary_oarchive_impl :
  29. public basic_binary_oprimitive<Archive, Elem, Tr>,
  30. public basic_binary_oarchive<Archive>
  31. {
  32. #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
  33. public:
  34. #else
  35. protected:
  36. #if BOOST_WORKAROUND(BOOST_MSVC, < 1500)
  37. // for some inexplicable reason insertion of "class" generates compile erro
  38. // on msvc 7.1
  39. friend detail::interface_oarchive<Archive>;
  40. friend basic_binary_oarchive<Archive>;
  41. friend save_access;
  42. #else
  43. friend class detail::interface_oarchive<Archive>;
  44. friend class basic_binary_oarchive<Archive>;
  45. friend class save_access;
  46. #endif
  47. #endif
  48. template<class T>
  49. void save_override(T & t){
  50. this->basic_binary_oarchive<Archive>::save_override(t);
  51. }
  52. void init(unsigned int flags) {
  53. if(0 != (flags & no_header)){
  54. return;
  55. }
  56. #if ! defined(__MWERKS__)
  57. this->basic_binary_oarchive<Archive>::init();
  58. this->basic_binary_oprimitive<Archive, Elem, Tr>::init();
  59. #else
  60. basic_binary_oarchive<Archive>::init();
  61. basic_binary_oprimitive<Archive, Elem, Tr>::init();
  62. #endif
  63. }
  64. binary_oarchive_impl(
  65. std::basic_streambuf<Elem, Tr> & bsb,
  66. unsigned int flags
  67. ) :
  68. basic_binary_oprimitive<Archive, Elem, Tr>(
  69. bsb,
  70. 0 != (flags & no_codecvt)
  71. ),
  72. basic_binary_oarchive<Archive>(flags)
  73. {
  74. init(flags);
  75. }
  76. binary_oarchive_impl(
  77. std::basic_ostream<Elem, Tr> & os,
  78. unsigned int flags
  79. ) :
  80. basic_binary_oprimitive<Archive, Elem, Tr>(
  81. * os.rdbuf(),
  82. 0 != (flags & no_codecvt)
  83. ),
  84. basic_binary_oarchive<Archive>(flags)
  85. {
  86. init(flags);
  87. }
  88. };
  89. } // namespace archive
  90. } // namespace boost
  91. #ifdef BOOST_MSVC
  92. #pragma warning(pop)
  93. #endif
  94. #endif // BOOST_ARCHIVE_BINARY_OARCHIVE_IMPL_HPP