xml_woarchive.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #ifndef BOOST_ARCHIVE_XML_WOARCHIVE_HPP
  2. #define BOOST_ARCHIVE_XML_WOARCHIVE_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_woarchive.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 <cstddef> // size_t
  19. #if defined(BOOST_NO_STDC_NAMESPACE)
  20. namespace std{
  21. using ::size_t;
  22. } // namespace std
  23. #endif
  24. #include <ostream>
  25. #include <boost/archive/detail/auto_link_warchive.hpp>
  26. #include <boost/archive/basic_text_oprimitive.hpp>
  27. #include <boost/archive/basic_xml_oarchive.hpp>
  28. #include <boost/archive/detail/register_archive.hpp>
  29. #include <boost/serialization/item_version_type.hpp>
  30. #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
  31. #ifdef BOOST_MSVC
  32. # pragma warning(push)
  33. # pragma warning(disable : 4511 4512)
  34. #endif
  35. namespace boost {
  36. namespace archive {
  37. namespace detail {
  38. template<class Archive> class interface_oarchive;
  39. } // namespace detail
  40. template<class Archive>
  41. class BOOST_SYMBOL_VISIBLE xml_woarchive_impl :
  42. public basic_text_oprimitive<std::wostream>,
  43. public basic_xml_oarchive<Archive>
  44. {
  45. #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
  46. public:
  47. #else
  48. protected:
  49. friend class detail::interface_oarchive<Archive>;
  50. friend class basic_xml_oarchive<Archive>;
  51. friend class save_access;
  52. #endif
  53. //void end_preamble(){
  54. // basic_xml_oarchive<Archive>::end_preamble();
  55. //}
  56. template<class T>
  57. void
  58. save(const T & t){
  59. basic_text_oprimitive<std::wostream>::save(t);
  60. }
  61. void
  62. save(const version_type & t){
  63. save(static_cast<unsigned int>(t));
  64. }
  65. void
  66. save(const boost::serialization::item_version_type & t){
  67. save(static_cast<unsigned int>(t));
  68. }
  69. BOOST_WARCHIVE_DECL void
  70. save(const char * t);
  71. #ifndef BOOST_NO_INTRINSIC_WCHAR_T
  72. BOOST_WARCHIVE_DECL void
  73. save(const wchar_t * t);
  74. #endif
  75. BOOST_WARCHIVE_DECL void
  76. save(const std::string &s);
  77. #ifndef BOOST_NO_STD_WSTRING
  78. BOOST_WARCHIVE_DECL void
  79. save(const std::wstring &ws);
  80. #endif
  81. BOOST_WARCHIVE_DECL
  82. xml_woarchive_impl(std::wostream & os, unsigned int flags);
  83. BOOST_WARCHIVE_DECL
  84. ~xml_woarchive_impl() BOOST_OVERRIDE;
  85. public:
  86. BOOST_WARCHIVE_DECL void
  87. save_binary(const void *address, std::size_t count);
  88. };
  89. // we use the following because we can't use
  90. // typedef xml_woarchive_impl<xml_woarchive_impl<...> > xml_woarchive;
  91. // do not derive from this class. If you want to extend this functionality
  92. // via inheritance, derived from xml_woarchive_impl instead. This will
  93. // preserve correct static polymorphism.
  94. class BOOST_SYMBOL_VISIBLE xml_woarchive :
  95. public xml_woarchive_impl<xml_woarchive>
  96. {
  97. public:
  98. xml_woarchive(std::wostream & os, unsigned int flags = 0) :
  99. xml_woarchive_impl<xml_woarchive>(os, flags)
  100. {
  101. if(0 == (flags & no_header))
  102. init();
  103. }
  104. ~xml_woarchive() BOOST_OVERRIDE {}
  105. };
  106. } // namespace archive
  107. } // namespace boost
  108. // required by export
  109. BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_woarchive)
  110. #ifdef BOOST_MSVC
  111. #pragma warning(pop)
  112. #endif
  113. #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
  114. #endif // BOOST_NO_STD_WSTREAMBUF
  115. #endif // BOOST_ARCHIVE_XML_OARCHIVE_HPP