Chris@16: #ifndef BOOST_SERIALIZATION_VERSION_HPP Chris@16: #define BOOST_SERIALIZATION_VERSION_HPP Chris@16: Chris@16: // MS compatible compilers support #pragma once Chris@101: #if defined(_MSC_VER) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 Chris@16: // version.hpp: Chris@16: Chris@16: // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . Chris@16: // Use, modification and distribution is subject to the Boost Software Chris@16: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // See http://www.boost.org for updates, documentation, and revision history. Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace serialization { Chris@16: Chris@16: struct basic_traits; Chris@16: Chris@16: // default version number is 0. Override with higher version Chris@16: // when class definition changes. Chris@16: template Chris@16: struct version Chris@16: { Chris@16: template Chris@16: struct traits_class_version { Chris@101: typedef typename U::version type; Chris@16: }; Chris@16: Chris@16: typedef mpl::integral_c_tag tag; Chris@16: // note: at least one compiler complained w/o the full qualification Chris@16: // on basic traits below Chris@16: typedef Chris@101: typename mpl::eval_if< Chris@16: is_base_and_derived, Chris@16: traits_class_version< T >, Chris@16: mpl::int_<0> Chris@16: >::type type; Chris@16: BOOST_STATIC_CONSTANT(int, value = version::type::value); Chris@16: }; Chris@16: Chris@16: #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION Chris@16: template Chris@16: const int version::value; Chris@16: #endif Chris@16: Chris@16: } // namespace serialization Chris@16: } // namespace boost Chris@16: Chris@16: /* note: at first it seemed that this would be a good place to trap Chris@16: * as an error an attempt to set a version # for a class which doesn't Chris@16: * save its class information (including version #) in the archive. Chris@16: * However, this imposes a requirement that the version be set after Chris@16: * the implemention level which would be pretty confusing. If this Chris@16: * is to be done, do this check in the input or output operators when Chris@16: * ALL the serialization traits are available. Included the implementation Chris@16: * here with this comment as a reminder not to do this! Chris@16: */ Chris@16: //#include Chris@16: //#include Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: // specify the current version number for the class Chris@16: // version numbers limited to 8 bits !!! Chris@16: #define BOOST_CLASS_VERSION(T, N) \ Chris@16: namespace boost { \ Chris@16: namespace serialization { \ Chris@16: template<> \ Chris@16: struct version \ Chris@16: { \ Chris@16: typedef mpl::int_ type; \ Chris@16: typedef mpl::integral_c_tag tag; \ Chris@16: BOOST_STATIC_CONSTANT(int, value = version::type::value); \ Chris@16: BOOST_MPL_ASSERT(( \ Chris@16: boost::mpl::less< \ Chris@16: boost::mpl::int_, \ Chris@16: boost::mpl::int_<256> \ Chris@16: > \ Chris@16: )); \ Chris@16: /* \ Chris@16: BOOST_MPL_ASSERT(( \ Chris@16: mpl::equal_to< \ Chris@16: :implementation_level, \ Chris@16: mpl::int_ \ Chris@16: >::value \ Chris@16: )); \ Chris@16: */ \ Chris@16: }; \ Chris@16: } \ Chris@16: } Chris@16: Chris@16: #endif // BOOST_SERIALIZATION_VERSION_HPP