common_oarchive.hpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef BOOST_ARCHIVE_DETAIL_COMMON_OARCHIVE_HPP
  2. #define BOOST_ARCHIVE_DETAIL_COMMON_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. // common_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 <boost/config.hpp>
  15. #include <boost/archive/detail/basic_oarchive.hpp>
  16. #include <boost/archive/detail/interface_oarchive.hpp>
  17. #ifdef BOOST_MSVC
  18. # pragma warning(push)
  19. # pragma warning(disable : 4511 4512)
  20. #endif
  21. namespace boost {
  22. namespace archive {
  23. namespace detail {
  24. // note: referred to as Curiously Recurring Template Patter (CRTP)
  25. template<class Archive>
  26. class BOOST_SYMBOL_VISIBLE common_oarchive :
  27. public basic_oarchive,
  28. public interface_oarchive<Archive>
  29. {
  30. friend class interface_oarchive<Archive>;
  31. friend class basic_oarchive;
  32. private:
  33. void vsave(const version_type t) BOOST_OVERRIDE {
  34. * this->This() << t;
  35. }
  36. void vsave(const object_id_type t) BOOST_OVERRIDE {
  37. * this->This() << t;
  38. }
  39. void vsave(const object_reference_type t) BOOST_OVERRIDE {
  40. * this->This() << t;
  41. }
  42. void vsave(const class_id_type t) BOOST_OVERRIDE {
  43. * this->This() << t;
  44. }
  45. void vsave(const class_id_reference_type t) BOOST_OVERRIDE {
  46. * this->This() << t;
  47. }
  48. void vsave(const class_id_optional_type t) BOOST_OVERRIDE {
  49. * this->This() << t;
  50. }
  51. void vsave(const class_name_type & t) BOOST_OVERRIDE {
  52. * this->This() << t;
  53. }
  54. void vsave(const tracking_type t) BOOST_OVERRIDE {
  55. * this->This() << t;
  56. }
  57. protected:
  58. // default processing - invoke serialization library
  59. template<class T>
  60. void save_override(T & t){
  61. archive::save(* this->This(), t);
  62. }
  63. void save_start(const char * /*name*/){}
  64. void save_end(const char * /*name*/){}
  65. common_oarchive(unsigned int flags = 0) :
  66. basic_oarchive(flags),
  67. interface_oarchive<Archive>()
  68. {}
  69. };
  70. } // namespace detail
  71. } // namespace archive
  72. } // namespace boost
  73. #ifdef BOOST_MSVC
  74. #pragma warning(pop)
  75. #endif
  76. #endif // BOOST_ARCHIVE_DETAIL_COMMON_OARCHIVE_HPP