traits.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef BOOST_SERIALIZATION_TRAITS_HPP
  2. #define BOOST_SERIALIZATION_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. // 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 is used to apply serialization traits to templates. The
  15. // standard system can't be used for platforms which don't support
  16. // Partial Template Specialization.
  17. // The motivation for this is the Name-Value Pair (NVP) template.
  18. // it has to work the same on all platforms in order for archives
  19. // to be portable across platforms.
  20. #include <boost/config.hpp>
  21. #include <boost/static_assert.hpp>
  22. #include <boost/mpl/int.hpp>
  23. #include <boost/mpl/bool_fwd.hpp>
  24. #include <boost/serialization/level_enum.hpp>
  25. #include <boost/serialization/tracking_enum.hpp>
  26. namespace boost {
  27. namespace serialization {
  28. // common base class used to detect appended traits class
  29. struct basic_traits {};
  30. template <class T>
  31. struct extended_type_info_impl;
  32. template<
  33. class T,
  34. int Level,
  35. int Tracking,
  36. unsigned int Version = 0,
  37. class ETII = extended_type_info_impl< T >,
  38. class Wrapper = mpl::false_
  39. >
  40. struct traits : public basic_traits {
  41. BOOST_STATIC_ASSERT(Version == 0 || Level >= object_class_info);
  42. BOOST_STATIC_ASSERT(Tracking == track_never || Level >= object_serializable);
  43. typedef typename mpl::int_<Level> level;
  44. typedef typename mpl::int_<Tracking> tracking;
  45. typedef typename mpl::int_<Version> version;
  46. typedef ETII type_info_implementation;
  47. typedef Wrapper is_wrapper;
  48. };
  49. } // namespace serialization
  50. } // namespace boost
  51. #endif // BOOST_SERIALIZATION_TRAITS_HPP