/Src/Dependencies/Boost/boost/multi_index/detail/serialization_version.hpp

http://hadesmem.googlecode.com/ · C++ Header · 75 lines · 43 code · 20 blank · 12 comment · 0 complexity · 828e97e52f52ac540c1c8a5b9744cfde MD5 · raw file

  1. /* Copyright 2003-2010 Joaquin M Lopez Munoz.
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * See http://www.boost.org/libs/multi_index for library home page.
  7. */
  8. #ifndef BOOST_MULTI_INDEX_DETAIL_SERIALIZATION_VERSION_HPP
  9. #define BOOST_MULTI_INDEX_DETAIL_SERIALIZATION_VERSION_HPP
  10. #if defined(_MSC_VER)&&(_MSC_VER>=1200)
  11. #pragma once
  12. #endif
  13. #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
  14. #include <boost/serialization/split_member.hpp>
  15. #include <boost/serialization/version.hpp>
  16. namespace boost{
  17. namespace multi_index{
  18. namespace detail{
  19. /* Helper class for storing and retrieving a given type serialization class
  20. * version while avoiding saving the number multiple times in the same
  21. * archive.
  22. * Behavior undefined if template partial specialization is not supported.
  23. */
  24. template<typename T>
  25. struct serialization_version
  26. {
  27. serialization_version():
  28. value(boost::serialization::version<serialization_version>::value){}
  29. serialization_version& operator=(unsigned int x){value=x;return *this;};
  30. operator unsigned int()const{return value;}
  31. private:
  32. friend class boost::serialization::access;
  33. BOOST_SERIALIZATION_SPLIT_MEMBER()
  34. template<class Archive>
  35. void save(Archive&,const unsigned int)const{}
  36. template<class Archive>
  37. void load(Archive&,const unsigned int version)
  38. {
  39. this->value=version;
  40. }
  41. unsigned int value;
  42. };
  43. } /* namespace multi_index::detail */
  44. } /* namespace multi_index */
  45. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  46. namespace serialization {
  47. template<typename T>
  48. struct version<boost::multi_index::detail::serialization_version<T> >
  49. {
  50. BOOST_STATIC_CONSTANT(int,value=version<T>::value);
  51. };
  52. } /* namespace serialization */
  53. #endif
  54. } /* namespace boost */
  55. #endif