common_oarchive.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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) && (_MSC_VER >= 1020)
  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 common_oarchive :
  27. public basic_oarchive,
  28. public interface_oarchive<Archive>
  29. {
  30. friend class interface_oarchive<Archive>;
  31. private:
  32. virtual void vsave(const version_type t){
  33. * this->This() << t;
  34. }
  35. virtual void vsave(const object_id_type t){
  36. * this->This() << t;
  37. }
  38. virtual void vsave(const object_reference_type t){
  39. * this->This() << t;
  40. }
  41. virtual void vsave(const class_id_type t){
  42. * this->This() << t;
  43. }
  44. virtual void vsave(const class_id_reference_type t){
  45. * this->This() << t;
  46. }
  47. virtual void vsave(const class_id_optional_type t){
  48. * this->This() << t;
  49. }
  50. virtual void vsave(const class_name_type & t){
  51. * this->This() << t;
  52. }
  53. virtual void vsave(const tracking_type t){
  54. * this->This() << t;
  55. }
  56. protected:
  57. // default processing - invoke serialization library
  58. template<class T>
  59. void save_override(T & t, BOOST_PFTO int){
  60. archive::save(* this->This(), t);
  61. }
  62. void save_start(const char * /*name*/){}
  63. void save_end(const char * /*name*/){}
  64. common_oarchive(unsigned int flags = 0) :
  65. basic_oarchive(flags),
  66. interface_oarchive<Archive>()
  67. {}
  68. };
  69. } // namespace detail
  70. } // namespace archive
  71. } // namespace boost
  72. #ifdef BOOST_MSVC
  73. #pragma warning(pop)
  74. #endif
  75. #endif // BOOST_ARCHIVE_DETAIL_COMMON_OARCHIVE_HPP