xml_woarchive.hpp 3.7 KB

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