xml_iarchive.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef BOOST_ARCHIVE_XML_IARCHIVE_HPP
  2. #define BOOST_ARCHIVE_XML_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. // xml_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/scoped_ptr.hpp>
  16. #include <boost/archive/detail/auto_link_archive.hpp>
  17. #include <boost/archive/basic_text_iprimitive.hpp>
  18. #include <boost/archive/basic_xml_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 CharType>
  32. class basic_xml_grammar;
  33. typedef basic_xml_grammar<char> xml_grammar;
  34. template<class Archive>
  35. class BOOST_SYMBOL_VISIBLE xml_iarchive_impl :
  36. public basic_text_iprimitive<std::istream>,
  37. public basic_xml_iarchive<Archive>
  38. {
  39. #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
  40. public:
  41. #else
  42. protected:
  43. friend class detail::interface_iarchive<Archive>;
  44. friend class basic_xml_iarchive<Archive>;
  45. friend class load_access;
  46. #endif
  47. // use boost:scoped_ptr to implement automatic deletion;
  48. boost::scoped_ptr<xml_grammar> gimpl;
  49. std::istream & get_is(){
  50. return is;
  51. }
  52. template<class T>
  53. void load(T & t){
  54. basic_text_iprimitive<std::istream>::load(t);
  55. }
  56. void
  57. load(version_type & t){
  58. unsigned int v;
  59. load(v);
  60. t = version_type(v);
  61. }
  62. void
  63. load(boost::serialization::item_version_type & t){
  64. unsigned int v;
  65. load(v);
  66. t = boost::serialization::item_version_type(v);
  67. }
  68. BOOST_ARCHIVE_DECL void
  69. load(char * t);
  70. #ifndef BOOST_NO_INTRINSIC_WCHAR_T
  71. BOOST_ARCHIVE_DECL void
  72. load(wchar_t * t);
  73. #endif
  74. BOOST_ARCHIVE_DECL void
  75. load(std::string &s);
  76. #ifndef BOOST_NO_STD_WSTRING
  77. BOOST_ARCHIVE_DECL void
  78. load(std::wstring &ws);
  79. #endif
  80. template<class T>
  81. void load_override(T & t){
  82. basic_xml_iarchive<Archive>::load_override(t);
  83. }
  84. BOOST_ARCHIVE_DECL void
  85. load_override(class_name_type & t);
  86. BOOST_ARCHIVE_DECL void
  87. init();
  88. BOOST_ARCHIVE_DECL
  89. xml_iarchive_impl(std::istream & is, unsigned int flags);
  90. BOOST_ARCHIVE_DECL
  91. ~xml_iarchive_impl();
  92. };
  93. } // namespace archive
  94. } // namespace boost
  95. #ifdef BOOST_MSVC
  96. #pragma warning(pop)
  97. #endif
  98. #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
  99. #ifdef BOOST_MSVC
  100. # pragma warning(push)
  101. # pragma warning(disable : 4511 4512)
  102. #endif
  103. namespace boost {
  104. namespace archive {
  105. class BOOST_SYMBOL_VISIBLE xml_iarchive :
  106. public xml_iarchive_impl<xml_iarchive>{
  107. public:
  108. xml_iarchive(std::istream & is, unsigned int flags = 0) :
  109. xml_iarchive_impl<xml_iarchive>(is, flags)
  110. {}
  111. ~xml_iarchive(){};
  112. };
  113. } // namespace archive
  114. } // namespace boost
  115. // required by export
  116. BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_iarchive)
  117. #ifdef BOOST_MSVC
  118. #pragma warning(pop)
  119. #endif
  120. #endif // BOOST_ARCHIVE_XML_IARCHIVE_HPP