xml_wiarchive.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #ifndef BOOST_ARCHIVE_XML_WIARCHIVE_HPP
  2. #define BOOST_ARCHIVE_XML_WIARCHIVE_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_wiarchive.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 <boost/config.hpp>
  15. #ifdef BOOST_NO_STD_WSTREAMBUF
  16. #error "wide char i/o not supported on this platform"
  17. #else
  18. #include <istream>
  19. #include <boost/smart_ptr/scoped_ptr.hpp>
  20. #include <boost/archive/detail/auto_link_warchive.hpp>
  21. #include <boost/archive/basic_text_iprimitive.hpp>
  22. #include <boost/archive/basic_xml_iarchive.hpp>
  23. #include <boost/archive/detail/register_archive.hpp>
  24. #include <boost/serialization/item_version_type.hpp>
  25. #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
  26. #ifdef BOOST_MSVC
  27. # pragma warning(push)
  28. # pragma warning(disable : 4511 4512)
  29. #endif
  30. namespace boost {
  31. namespace archive {
  32. namespace detail {
  33. template<class Archive> class interface_iarchive;
  34. } // namespace detail
  35. template<class CharType>
  36. class basic_xml_grammar;
  37. typedef basic_xml_grammar<wchar_t> xml_wgrammar;
  38. template<class Archive>
  39. class BOOST_SYMBOL_VISIBLE xml_wiarchive_impl :
  40. public basic_text_iprimitive<std::wistream>,
  41. public basic_xml_iarchive<Archive>
  42. {
  43. #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
  44. public:
  45. #else
  46. protected:
  47. friend class detail::interface_iarchive<Archive>;
  48. friend class basic_xml_iarchive<Archive>;
  49. friend class load_access;
  50. #endif
  51. std::locale archive_locale;
  52. boost::scoped_ptr<xml_wgrammar> gimpl;
  53. std::wistream & get_is(){
  54. return is;
  55. }
  56. template<class T>
  57. void
  58. load(T & t){
  59. basic_text_iprimitive<std::wistream>::load(t);
  60. }
  61. void
  62. load(version_type & t){
  63. unsigned int v;
  64. load(v);
  65. t = version_type(v);
  66. }
  67. void
  68. load(boost::serialization::item_version_type & t){
  69. unsigned int v;
  70. load(v);
  71. t = boost::serialization::item_version_type(v);
  72. }
  73. BOOST_WARCHIVE_DECL void
  74. load(char * t);
  75. #ifndef BOOST_NO_INTRINSIC_WCHAR_T
  76. BOOST_WARCHIVE_DECL void
  77. load(wchar_t * t);
  78. #endif
  79. BOOST_WARCHIVE_DECL void
  80. load(std::string &s);
  81. #ifndef BOOST_NO_STD_WSTRING
  82. BOOST_WARCHIVE_DECL void
  83. load(std::wstring &ws);
  84. #endif
  85. template<class T>
  86. void load_override(T & t){
  87. basic_xml_iarchive<Archive>::load_override(t);
  88. }
  89. BOOST_WARCHIVE_DECL void
  90. load_override(class_name_type & t);
  91. BOOST_WARCHIVE_DECL void
  92. init();
  93. BOOST_WARCHIVE_DECL
  94. xml_wiarchive_impl(std::wistream & is, unsigned int flags);
  95. BOOST_WARCHIVE_DECL
  96. ~xml_wiarchive_impl() BOOST_OVERRIDE;
  97. };
  98. } // namespace archive
  99. } // namespace boost
  100. #ifdef BOOST_MSVC
  101. # pragma warning(pop)
  102. #endif
  103. #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
  104. #ifdef BOOST_MSVC
  105. # pragma warning(push)
  106. # pragma warning(disable : 4511 4512)
  107. #endif
  108. namespace boost {
  109. namespace archive {
  110. class BOOST_SYMBOL_VISIBLE xml_wiarchive :
  111. public xml_wiarchive_impl<xml_wiarchive>{
  112. public:
  113. xml_wiarchive(std::wistream & is, unsigned int flags = 0) :
  114. xml_wiarchive_impl<xml_wiarchive>(is, flags)
  115. {
  116. if(0 == (flags & no_header))
  117. init();
  118. }
  119. ~xml_wiarchive() BOOST_OVERRIDE {}
  120. };
  121. } // namespace archive
  122. } // namespace boost
  123. // required by export
  124. BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_wiarchive)
  125. #ifdef BOOST_MSVC
  126. #pragma warning(pop)
  127. #endif
  128. #endif // BOOST_NO_STD_WSTREAMBUF
  129. #endif // BOOST_ARCHIVE_XML_WIARCHIVE_HPP