basic_serializer.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef BOOST_ARCHIVE_BASIC_SERIALIZER_HPP
  2. #define BOOST_ARCHIVE_BASIC_SERIALIZER_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. // basic_serializer.hpp: extenstion of type_info required for serialization.
  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/assert.hpp>
  15. #include <cstddef> // NULL
  16. #include <boost/noncopyable.hpp>
  17. #include <boost/config.hpp>
  18. #include <boost/serialization/extended_type_info.hpp>
  19. #ifdef BOOST_MSVC
  20. # pragma warning(push)
  21. # pragma warning(disable : 4511 4512)
  22. #endif
  23. namespace boost {
  24. namespace archive {
  25. namespace detail {
  26. class basic_serializer :
  27. private boost::noncopyable
  28. {
  29. const boost::serialization::extended_type_info * m_eti;
  30. protected:
  31. explicit basic_serializer(
  32. const boost::serialization::extended_type_info & eti
  33. ) :
  34. m_eti(& eti)
  35. {
  36. BOOST_ASSERT(NULL != & eti);
  37. }
  38. public:
  39. inline bool
  40. operator<(const basic_serializer & rhs) const {
  41. // can't compare address since there can be multiple eti records
  42. // for the same type in different execution modules (that is, DLLS)
  43. // leave this here as a reminder not to do this!
  44. // return & lhs.get_eti() < & rhs.get_eti();
  45. return get_eti() < rhs.get_eti();
  46. }
  47. const char * get_debug_info() const {
  48. return m_eti->get_debug_info();
  49. }
  50. const boost::serialization::extended_type_info & get_eti() const {
  51. return * m_eti;
  52. }
  53. };
  54. class basic_serializer_arg : public basic_serializer {
  55. public:
  56. basic_serializer_arg(const serialization::extended_type_info & eti) :
  57. basic_serializer(eti)
  58. {}
  59. };
  60. } // namespace detail
  61. } // namespace archive
  62. } // namespace boost
  63. #ifdef BOOST_MSVC
  64. #pragma warning(pop)
  65. #endif
  66. #endif // BOOST_ARCHIVE_BASIC_SERIALIZER_HPP