xml_woarchive.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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) && (_MSC_VER >= 1020)
  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. template<class Archive>
  38. class xml_woarchive_impl :
  39. public basic_text_oprimitive<std::wostream>,
  40. public basic_xml_oarchive<Archive>
  41. {
  42. #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
  43. public:
  44. #else
  45. friend class detail::interface_oarchive<Archive>;
  46. friend class basic_xml_oarchive<Archive>;
  47. friend class save_access;
  48. protected:
  49. #endif
  50. //void end_preamble(){
  51. // basic_xml_oarchive<Archive>::end_preamble();
  52. //}
  53. template<class T>
  54. void
  55. save(const T & t){
  56. basic_text_oprimitive<std::wostream>::save(t);
  57. }
  58. void
  59. save(const version_type & t){
  60. save(static_cast<const unsigned int>(t));
  61. }
  62. void
  63. save(const boost::serialization::item_version_type & t){
  64. save(static_cast<const unsigned int>(t));
  65. }
  66. BOOST_WARCHIVE_DECL(void)
  67. save(const char * t);
  68. #ifndef BOOST_NO_INTRINSIC_WCHAR_T
  69. BOOST_WARCHIVE_DECL(void)
  70. save(const wchar_t * t);
  71. #endif
  72. BOOST_WARCHIVE_DECL(void)
  73. save(const std::string &s);
  74. #ifndef BOOST_NO_STD_WSTRING
  75. BOOST_WARCHIVE_DECL(void)
  76. save(const std::wstring &ws);
  77. #endif
  78. BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY())
  79. xml_woarchive_impl(std::wostream & os, unsigned int flags);
  80. ~xml_woarchive_impl(){}
  81. public:
  82. void
  83. save_binary(const void *address, std::size_t count){
  84. this->end_preamble();
  85. #if ! defined(__MWERKS__)
  86. this->basic_text_oprimitive<std::wostream>::save_binary(
  87. #else
  88. this->basic_text_oprimitive::save_binary(
  89. #endif
  90. address,
  91. count
  92. );
  93. this->indent_next = true;
  94. }
  95. };
  96. // we use the following because we can't use
  97. // typedef xml_woarchive_impl<xml_woarchive_impl<...> > xml_woarchive;
  98. // do not derive from this class. If you want to extend this functionality
  99. // via inhertance, derived from xml_woarchive_impl instead. This will
  100. // preserve correct static polymorphism.
  101. class xml_woarchive :
  102. public xml_woarchive_impl<xml_woarchive>
  103. {
  104. public:
  105. xml_woarchive(std::wostream & os, unsigned int flags = 0) :
  106. xml_woarchive_impl<xml_woarchive>(os, flags)
  107. {}
  108. ~xml_woarchive(){}
  109. };
  110. typedef xml_woarchive naked_xml_woarchive;
  111. } // namespace archive
  112. } // namespace boost
  113. // required by export
  114. BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_woarchive)
  115. #ifdef BOOST_MSVC
  116. #pragma warning(pop)
  117. #endif
  118. #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
  119. #endif // BOOST_NO_STD_WSTREAMBUF
  120. #endif // BOOST_ARCHIVE_XML_OARCHIVE_HPP