collection_traits.hpp 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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.hpp>
  22. #include <boost/mpl/integral_c_tag.hpp>
  23. #include <boost/cstdint.hpp>
  24. #include <boost/integer_traits.hpp>
  25. #include <climits> // ULONG_MAX
  26. #include <boost/serialization/level.hpp>
  27. #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(T, C) \
  28. template<> \
  29. struct implementation_level< C < T > > { \
  30. typedef mpl::integral_c_tag tag; \
  31. typedef mpl::int_<object_serializable> type; \
  32. BOOST_STATIC_CONSTANT(int, value = object_serializable); \
  33. }; \
  34. /**/
  35. #if defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_INTRINSIC_WCHAR_T)
  36. #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_WCHAR(C)
  37. #else
  38. #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_WCHAR(C) \
  39. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(wchar_t, C) \
  40. /**/
  41. #endif
  42. #if defined(BOOST_HAS_LONG_LONG)
  43. #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_INT64(C) \
  44. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(boost::long_long_type, C) \
  45. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(boost::ulong_long_type, C) \
  46. /**/
  47. #else
  48. #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_INT64(C)
  49. #endif
  50. #define BOOST_SERIALIZATION_COLLECTION_TRAITS(C) \
  51. namespace boost { namespace serialization { \
  52. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(bool, C) \
  53. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(char, C) \
  54. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed char, C) \
  55. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned char, C) \
  56. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed int, C) \
  57. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned int, C) \
  58. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed long, C) \
  59. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned long, C) \
  60. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(float, C) \
  61. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(double, C) \
  62. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned short, C) \
  63. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed short, C) \
  64. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_INT64(C) \
  65. BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_WCHAR(C) \
  66. } } \
  67. /**/
  68. #endif // BOOST_SERIALIZATION_COLLECTION_TRAITS