text_oarchive.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #ifndef BOOST_ARCHIVE_TEXT_OARCHIVE_HPP
  2. #define BOOST_ARCHIVE_TEXT_OARCHIVE_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_oarchive.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 <ostream>
  15. #include <cstddef> // std::size_t
  16. #include <boost/config.hpp>
  17. #if defined(BOOST_NO_STDC_NAMESPACE)
  18. namespace std{
  19. using ::size_t;
  20. } // namespace std
  21. #endif
  22. #include <boost/archive/detail/auto_link_archive.hpp>
  23. #include <boost/archive/basic_text_oprimitive.hpp>
  24. #include <boost/archive/basic_text_oarchive.hpp>
  25. #include <boost/archive/detail/register_archive.hpp>
  26. #include <boost/serialization/item_version_type.hpp>
  27. #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
  28. #ifdef BOOST_MSVC
  29. # pragma warning(push)
  30. # pragma warning(disable : 4511 4512)
  31. #endif
  32. namespace boost {
  33. namespace archive {
  34. template<class Archive>
  35. class text_oarchive_impl :
  36. /* protected ? */ public basic_text_oprimitive<std::ostream>,
  37. public basic_text_oarchive<Archive>
  38. {
  39. #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
  40. public:
  41. #else
  42. friend class detail::interface_oarchive<Archive>;
  43. friend class basic_text_oarchive<Archive>;
  44. friend class save_access;
  45. protected:
  46. #endif
  47. template<class T>
  48. void save(const T & t){
  49. this->newtoken();
  50. basic_text_oprimitive<std::ostream>::save(t);
  51. }
  52. void save(const version_type & t){
  53. save(static_cast<const unsigned int>(t));
  54. }
  55. void save(const boost::serialization::item_version_type & t){
  56. save(static_cast<const unsigned int>(t));
  57. }
  58. BOOST_ARCHIVE_DECL(void)
  59. save(const char * t);
  60. #ifndef BOOST_NO_INTRINSIC_WCHAR_T
  61. BOOST_ARCHIVE_DECL(void)
  62. save(const wchar_t * t);
  63. #endif
  64. BOOST_ARCHIVE_DECL(void)
  65. save(const std::string &s);
  66. #ifndef BOOST_NO_STD_WSTRING
  67. BOOST_ARCHIVE_DECL(void)
  68. save(const std::wstring &ws);
  69. #endif
  70. BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
  71. text_oarchive_impl(std::ostream & os, unsigned int flags);
  72. // don't import inline definitions! leave this as a reminder.
  73. //BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
  74. ~text_oarchive_impl(){};
  75. public:
  76. BOOST_ARCHIVE_DECL(void)
  77. save_binary(const void *address, std::size_t count);
  78. };
  79. // do not derive from this class. If you want to extend this functionality
  80. // via inhertance, derived from text_oarchive_impl instead. This will
  81. // preserve correct static polymorphism.
  82. class text_oarchive :
  83. public text_oarchive_impl<text_oarchive>
  84. {
  85. public:
  86. text_oarchive(std::ostream & os_, unsigned int flags = 0) :
  87. // note: added _ to suppress useless gcc warning
  88. text_oarchive_impl<text_oarchive>(os_, flags)
  89. {}
  90. ~text_oarchive(){}
  91. };
  92. typedef text_oarchive naked_text_oarchive;
  93. } // namespace archive
  94. } // namespace boost
  95. // required by export
  96. BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_oarchive)
  97. #ifdef BOOST_MSVC
  98. #pragma warning(pop)
  99. #endif
  100. #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
  101. #endif // BOOST_ARCHIVE_TEXT_OARCHIVE_HPP