text_oarchive.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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)
  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. namespace detail {
  35. template<class Archive> class interface_oarchive;
  36. } // namespace detail
  37. template<class Archive>
  38. class BOOST_SYMBOL_VISIBLE text_oarchive_impl :
  39. /* protected ? */ public basic_text_oprimitive<std::ostream>,
  40. public basic_text_oarchive<Archive>
  41. {
  42. #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
  43. public:
  44. #else
  45. protected:
  46. friend class detail::interface_oarchive<Archive>;
  47. friend class basic_text_oarchive<Archive>;
  48. friend class save_access;
  49. #endif
  50. template<class T>
  51. void save(const T & t){
  52. this->newtoken();
  53. basic_text_oprimitive<std::ostream>::save(t);
  54. }
  55. void save(const version_type & t){
  56. save(static_cast<unsigned int>(t));
  57. }
  58. void save(const boost::serialization::item_version_type & t){
  59. save(static_cast<unsigned int>(t));
  60. }
  61. BOOST_ARCHIVE_DECL void
  62. save(const char * t);
  63. #ifndef BOOST_NO_INTRINSIC_WCHAR_T
  64. BOOST_ARCHIVE_DECL void
  65. save(const wchar_t * t);
  66. #endif
  67. BOOST_ARCHIVE_DECL void
  68. save(const std::string &s);
  69. #ifndef BOOST_NO_STD_WSTRING
  70. BOOST_ARCHIVE_DECL void
  71. save(const std::wstring &ws);
  72. #endif
  73. BOOST_ARCHIVE_DECL
  74. text_oarchive_impl(std::ostream & os, unsigned int flags);
  75. // don't import inline definitions! leave this as a reminder.
  76. //BOOST_ARCHIVE_DECL
  77. ~text_oarchive_impl(){};
  78. public:
  79. BOOST_ARCHIVE_DECL void
  80. save_binary(const void *address, std::size_t count);
  81. };
  82. // do not derive from this class. If you want to extend this functionality
  83. // via inhertance, derived from text_oarchive_impl instead. This will
  84. // preserve correct static polymorphism.
  85. class BOOST_SYMBOL_VISIBLE text_oarchive :
  86. public text_oarchive_impl<text_oarchive>
  87. {
  88. public:
  89. text_oarchive(std::ostream & os_, unsigned int flags = 0) :
  90. // note: added _ to suppress useless gcc warning
  91. text_oarchive_impl<text_oarchive>(os_, flags)
  92. {}
  93. ~text_oarchive(){}
  94. };
  95. } // namespace archive
  96. } // namespace boost
  97. // required by export
  98. BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_oarchive)
  99. #ifdef BOOST_MSVC
  100. #pragma warning(pop)
  101. #endif
  102. #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
  103. #endif // BOOST_ARCHIVE_TEXT_OARCHIVE_HPP