basic_oarchive.hpp 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef BOOST_ARCHIVE_BASIC_OARCHIVE_HPP
  2. #define BOOST_ARCHIVE_BASIC_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. // basic_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 <cstddef> // NULL
  15. #include <boost/config.hpp>
  16. #include <boost/noncopyable.hpp>
  17. #include <boost/scoped_ptr.hpp>
  18. #include <boost/archive/basic_archive.hpp>
  19. #include <boost/serialization/tracking_enum.hpp>
  20. #include <boost/archive/detail/helper_collection.hpp>
  21. #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
  22. namespace boost {
  23. namespace serialization {
  24. class extended_type_info;
  25. } // namespace serialization
  26. namespace archive {
  27. namespace detail {
  28. class basic_oarchive_impl;
  29. class basic_oserializer;
  30. class basic_pointer_oserializer;
  31. //////////////////////////////////////////////////////////////////////
  32. // class basic_oarchive - write serialized objects to an output stream
  33. class BOOST_SYMBOL_VISIBLE basic_oarchive :
  34. private boost::noncopyable,
  35. public boost::archive::detail::helper_collection
  36. {
  37. friend class basic_oarchive_impl;
  38. // hide implementation of this class to minimize header conclusion
  39. boost::scoped_ptr<basic_oarchive_impl> pimpl;
  40. // overload these to bracket object attributes. Used to implement
  41. // xml archives
  42. virtual void vsave(const version_type t) = 0;
  43. virtual void vsave(const object_id_type t) = 0;
  44. virtual void vsave(const object_reference_type t) = 0;
  45. virtual void vsave(const class_id_type t) = 0;
  46. virtual void vsave(const class_id_optional_type t) = 0;
  47. virtual void vsave(const class_id_reference_type t) = 0;
  48. virtual void vsave(const class_name_type & t) = 0;
  49. virtual void vsave(const tracking_type t) = 0;
  50. protected:
  51. BOOST_ARCHIVE_DECL basic_oarchive(unsigned int flags = 0);
  52. BOOST_ARCHIVE_DECL boost::archive::detail::helper_collection &
  53. get_helper_collection();
  54. virtual BOOST_ARCHIVE_DECL ~basic_oarchive();
  55. public:
  56. // note: NOT part of the public interface
  57. BOOST_ARCHIVE_DECL void register_basic_serializer(
  58. const basic_oserializer & bos
  59. );
  60. BOOST_ARCHIVE_DECL void save_object(
  61. const void *x,
  62. const basic_oserializer & bos
  63. );
  64. BOOST_ARCHIVE_DECL void save_pointer(
  65. const void * t,
  66. const basic_pointer_oserializer * bpos_ptr
  67. );
  68. void save_null_pointer(){
  69. vsave(NULL_POINTER_TAG);
  70. }
  71. // real public interface starts here
  72. BOOST_ARCHIVE_DECL void end_preamble(); // default implementation does nothing
  73. BOOST_ARCHIVE_DECL library_version_type get_library_version() const;
  74. BOOST_ARCHIVE_DECL unsigned int get_flags() const;
  75. };
  76. } // namespace detail
  77. } // namespace archive
  78. } // namespace boost
  79. #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
  80. #endif //BOOST_ARCHIVE_BASIC_OARCHIVE_HPP