/Src/Dependencies/Boost/boost/archive/text_woarchive.hpp

http://hadesmem.googlecode.com/ · C++ Header · 145 lines · 109 code · 22 blank · 14 comment · 4 complexity · f68d7dfedac9f37dfc7040faeb9cafbf MD5 · raw file

  1. #ifndef BOOST_ARCHIVE_TEXT_WOARCHIVE_HPP
  2. #define BOOST_ARCHIVE_TEXT_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. // text_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 <ostream>
  19. #include <cstddef> // size_t
  20. #if defined(BOOST_NO_STDC_NAMESPACE)
  21. namespace std{
  22. using ::size_t;
  23. } // namespace std
  24. #endif
  25. #include <boost/archive/detail/auto_link_warchive.hpp>
  26. #include <boost/archive/basic_text_oprimitive.hpp>
  27. #include <boost/archive/basic_text_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 text_woarchive_impl :
  39. public basic_text_oprimitive<std::wostream>,
  40. public basic_text_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_text_oarchive<Archive>;
  47. friend class save_access;
  48. protected:
  49. #endif
  50. template<class T>
  51. void save(const T & t){
  52. this->newtoken();
  53. basic_text_oprimitive<std::wostream>::save(t);
  54. }
  55. void save(const version_type & t){
  56. save(static_cast<const unsigned int>(t));
  57. }
  58. void save(const boost::serialization::item_version_type & t){
  59. save(static_cast<const unsigned int>(t));
  60. }
  61. BOOST_WARCHIVE_DECL(void)
  62. save(const char * t);
  63. #ifndef BOOST_NO_INTRINSIC_WCHAR_T
  64. BOOST_WARCHIVE_DECL(void)
  65. save(const wchar_t * t);
  66. #endif
  67. BOOST_WARCHIVE_DECL(void)
  68. save(const std::string &s);
  69. #ifndef BOOST_NO_STD_WSTRING
  70. BOOST_WARCHIVE_DECL(void)
  71. save(const std::wstring &ws);
  72. #endif
  73. text_woarchive_impl(std::wostream & os, unsigned int flags) :
  74. basic_text_oprimitive<std::wostream>(
  75. os,
  76. 0 != (flags & no_codecvt)
  77. ),
  78. basic_text_oarchive<Archive>(flags)
  79. {
  80. if(0 == (flags & no_header))
  81. basic_text_oarchive<Archive>::init();
  82. }
  83. public:
  84. void save_binary(const void *address, std::size_t count){
  85. put(static_cast<wchar_t>('\n'));
  86. this->end_preamble();
  87. #if ! defined(__MWERKS__)
  88. this->basic_text_oprimitive<std::wostream>::save_binary(
  89. #else
  90. this->basic_text_oprimitive::save_binary(
  91. #endif
  92. address,
  93. count
  94. );
  95. put(static_cast<wchar_t>('\n'));
  96. this->delimiter = this->none;
  97. }
  98. };
  99. // we use the following because we can't use
  100. // typedef text_oarchive_impl<text_oarchive_impl<...> > text_oarchive;
  101. // do not derive from this class. If you want to extend this functionality
  102. // via inhertance, derived from text_oarchive_impl instead. This will
  103. // preserve correct static polymorphism.
  104. class text_woarchive :
  105. public text_woarchive_impl<text_woarchive>
  106. {
  107. public:
  108. text_woarchive(std::wostream & os, unsigned int flags = 0) :
  109. text_woarchive_impl<text_woarchive>(os, flags)
  110. {}
  111. ~text_woarchive(){}
  112. };
  113. typedef text_woarchive naked_text_woarchive;
  114. } // namespace archive
  115. } // namespace boost
  116. // required by export
  117. BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_woarchive)
  118. #ifdef BOOST_MSVC
  119. #pragma warning(pop)
  120. #endif
  121. #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
  122. #endif // BOOST_NO_STD_WSTREAMBUF
  123. #endif // BOOST_ARCHIVE_TEXT_WOARCHIVE_HPP