common_iarchive.hpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef BOOST_ARCHIVE_DETAIL_COMMON_IARCHIVE_HPP
  2. #define BOOST_ARCHIVE_DETAIL_COMMON_IARCHIVE_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_iarchive.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_iarchive.hpp>
  16. #include <boost/archive/detail/basic_pointer_iserializer.hpp>
  17. #include <boost/archive/detail/interface_iarchive.hpp>
  18. #ifdef BOOST_MSVC
  19. # pragma warning(push)
  20. # pragma warning(disable : 4511 4512)
  21. #endif
  22. namespace boost {
  23. namespace archive {
  24. namespace detail {
  25. class extended_type_info;
  26. // note: referred to as Curiously Recurring Template Patter (CRTP)
  27. template<class Archive>
  28. class BOOST_SYMBOL_VISIBLE common_iarchive :
  29. public basic_iarchive,
  30. public interface_iarchive<Archive>
  31. {
  32. friend class interface_iarchive<Archive>;
  33. friend class basic_iarchive;
  34. private:
  35. virtual void vload(version_type & t){
  36. * this->This() >> t;
  37. }
  38. virtual void vload(object_id_type & t){
  39. * this->This() >> t;
  40. }
  41. virtual void vload(class_id_type & t){
  42. * this->This() >> t;
  43. }
  44. virtual void vload(class_id_optional_type & t){
  45. * this->This() >> t;
  46. }
  47. virtual void vload(tracking_type & t){
  48. * this->This() >> t;
  49. }
  50. virtual void vload(class_name_type &s){
  51. * this->This() >> s;
  52. }
  53. protected:
  54. // default processing - invoke serialization library
  55. template<class T>
  56. void load_override(T & t){
  57. archive::load(* this->This(), t);
  58. }
  59. // default implementations of functions which emit start/end tags for
  60. // archive types that require them.
  61. void load_start(const char * /*name*/){}
  62. void load_end(const char * /*name*/){}
  63. // default archive initialization
  64. common_iarchive(unsigned int flags = 0) :
  65. basic_iarchive(flags),
  66. interface_iarchive<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_IARCHIVE_HPP