binary_iarchive_impl.hpp 2.8 KB

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