xml_wiarchive.hpp 3.8 KB

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