collection_traits.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef BOOST_SERIALIZATION_COLLECTION_TRAITS_HPP
  2. #define BOOST_SERIALIZATION_COLLECTION_TRAITS_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. // collection_traits.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. // This header assigns a level implemenation trait to a collection type
  15. // for all primitives. It is needed so that archives which are meant to be
  16. // portable don't write class information in the archive. Since, not all
  17. // compiles recognize the same set of primitive types, the possibility
  18. // exists for archives to be non-portable if class information for primitive
  19. // types is included. This is addressed by the following macros.
  20. #include <boost/config.hpp>
  21. #include <boost/mpl/integral_c_tag.hpp>
  22. #include <boost/cstdint.hpp>
  23. #include <boost/integer_traits.hpp>
  24. #include <climits> // ULONG_MAX
  25. #include <boost/serialization/level.hpp>
  26. #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(T, C) \
  27. template<> \
  28. struct implementation_level< C < T > > { \
  29. typedef mpl::integral_c_tag tag; \
  30. typedef mpl::int_<object_serializable> type; \
  31. BOOST_STATIC_CONSTANT(int, value = object_serializable); \
  32. }; \
  33. /**/
  34. #if defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_INTRINSIC_WCHAR_T)
  35. #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_WCHAR(C)
  36. #else
  37. #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_WCHAR(C) \
  38. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(wchar_t, C) \
  39. /**/
  40. #endif
  41. #if defined(BOOST_HAS_LONG_LONG)
  42. #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_INT64(C) \
  43. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(boost::long_long_type, C) \
  44. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(boost::ulong_long_type, C) \
  45. /**/
  46. #else
  47. #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_INT64(C)
  48. #endif
  49. #define BOOST_SERIALIZATION_COLLECTION_TRAITS(C) \
  50. namespace boost { namespace serialization { \
  51. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(bool, C) \
  52. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(char, C) \
  53. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed char, C) \
  54. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned char, C) \
  55. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed int, C) \
  56. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned int, C) \
  57. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed long, C) \
  58. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned long, C) \
  59. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(float, C) \
  60. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(double, C) \
  61. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned short, C) \
  62. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed short, C) \
  63. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_INT64(C) \
  64. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_WCHAR(C) \
  65. } } \
  66. /**/
  67. #endif // BOOST_SERIALIZATION_COLLECTION_TRAITS