text_iarchive.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #ifndef BOOST_ARCHIVE_TEXT_IARCHIVE_HPP
  2. #define BOOST_ARCHIVE_TEXT_IARCHIVE_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. // text_iarchive.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/config.hpp>
  16. #include <boost/archive/detail/auto_link_archive.hpp>
  17. #include <boost/archive/basic_text_iprimitive.hpp>
  18. #include <boost/archive/basic_text_iarchive.hpp>
  19. #include <boost/archive/detail/register_archive.hpp>
  20. #include <boost/serialization/item_version_type.hpp>
  21. #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
  22. #ifdef BOOST_MSVC
  23. # pragma warning(push)
  24. # pragma warning(disable : 4511 4512)
  25. #endif
  26. namespace boost {
  27. namespace archive {
  28. namespace detail {
  29. template<class Archive> class interface_iarchive;
  30. } // namespace detail
  31. template<class Archive>
  32. class BOOST_SYMBOL_VISIBLE text_iarchive_impl :
  33. public basic_text_iprimitive<std::istream>,
  34. public basic_text_iarchive<Archive>
  35. {
  36. #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
  37. public:
  38. #else
  39. protected:
  40. friend class detail::interface_iarchive<Archive>;
  41. friend class load_access;
  42. #endif
  43. template<class T>
  44. void load(T & t){
  45. basic_text_iprimitive<std::istream>::load(t);
  46. }
  47. void load(version_type & t){
  48. unsigned int v;
  49. load(v);
  50. t = version_type(v);
  51. }
  52. void load(boost::serialization::item_version_type & t){
  53. unsigned int v;
  54. load(v);
  55. t = boost::serialization::item_version_type(v);
  56. }
  57. BOOST_ARCHIVE_DECL void
  58. load(char * t);
  59. #ifndef BOOST_NO_INTRINSIC_WCHAR_T
  60. BOOST_ARCHIVE_DECL void
  61. load(wchar_t * t);
  62. #endif
  63. BOOST_ARCHIVE_DECL void
  64. load(std::string &s);
  65. #ifndef BOOST_NO_STD_WSTRING
  66. BOOST_ARCHIVE_DECL void
  67. load(std::wstring &ws);
  68. #endif
  69. template<class T>
  70. void load_override(T & t){
  71. basic_text_iarchive<Archive>::load_override(t);
  72. }
  73. BOOST_ARCHIVE_DECL void
  74. load_override(class_name_type & t);
  75. BOOST_ARCHIVE_DECL void
  76. init();
  77. BOOST_ARCHIVE_DECL
  78. text_iarchive_impl(std::istream & is, unsigned int flags);
  79. // don't import inline definitions! leave this as a reminder.
  80. //BOOST_ARCHIVE_DECL
  81. ~text_iarchive_impl() BOOST_OVERRIDE {}
  82. };
  83. } // namespace archive
  84. } // namespace boost
  85. #ifdef BOOST_MSVC
  86. #pragma warning(pop)
  87. #endif
  88. #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
  89. #ifdef BOOST_MSVC
  90. # pragma warning(push)
  91. # pragma warning(disable : 4511 4512)
  92. #endif
  93. namespace boost {
  94. namespace archive {
  95. class BOOST_SYMBOL_VISIBLE text_iarchive :
  96. public text_iarchive_impl<text_iarchive>{
  97. public:
  98. text_iarchive(std::istream & is_, unsigned int flags = 0) :
  99. // note: added _ to suppress useless gcc warning
  100. text_iarchive_impl<text_iarchive>(is_, flags)
  101. {
  102. if(0 == (flags & no_header))
  103. init();
  104. }
  105. ~text_iarchive() BOOST_OVERRIDE {}
  106. };
  107. } // namespace archive
  108. } // namespace boost
  109. // required by export
  110. BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_iarchive)
  111. #ifdef BOOST_MSVC
  112. #pragma warning(pop)
  113. #endif
  114. #endif // BOOST_ARCHIVE_TEXT_IARCHIVE_HPP