123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- #ifndef BOOST_SERIALIZATION_SHARED_PTR_HPP
- #define BOOST_SERIALIZATION_SHARED_PTR_HPP
- #if defined(_MSC_VER)
- # pragma once
- #endif
- #include <cstddef>
- #include <memory>
- #include <boost/config.hpp>
- #include <boost/mpl/integral_c.hpp>
- #include <boost/mpl/integral_c_tag.hpp>
- #include <boost/detail/workaround.hpp>
- #include <boost/shared_ptr.hpp>
- #include <boost/serialization/shared_ptr_helper.hpp>
- #include <boost/serialization/split_free.hpp>
- #include <boost/serialization/nvp.hpp>
- #include <boost/serialization/version.hpp>
- #include <boost/serialization/tracking.hpp>
- #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
- namespace boost {
- namespace serialization{
- template<class T>
- struct version< ::boost::shared_ptr< T > > {
- typedef mpl::integral_c_tag tag;
- #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206))
- typedef typename mpl::int_<1> type;
- #else
- typedef mpl::int_<1> type;
- #endif
- BOOST_STATIC_CONSTANT(int, value = type::value);
- };
-
- template<class T>
- struct tracking_level< ::boost::shared_ptr< T > > {
- typedef mpl::integral_c_tag tag;
- #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206))
- typedef typename mpl::int_< ::boost::serialization::track_never> type;
- #else
- typedef mpl::int_< ::boost::serialization::track_never> type;
- #endif
- BOOST_STATIC_CONSTANT(int, value = type::value);
- };
- }}
- #define BOOST_SERIALIZATION_SHARED_PTR(T)
- #else
-
- #define BOOST_SERIALIZATION_SHARED_PTR(T) \
- BOOST_CLASS_VERSION( \
- ::boost::shared_ptr< T >, \
- 1 \
- ) \
- BOOST_CLASS_TRACKING( \
- ::boost::shared_ptr< T >, \
- ::boost::serialization::track_never \
- ) \
-
- #endif
- namespace boost {
- namespace serialization{
- struct null_deleter {
- void operator()(void const *) const {}
- };
- void * const shared_ptr_helper_id = 0;
- template<class Archive, class T>
- inline void save(
- Archive & ar,
- const boost::shared_ptr< T > &t,
- const unsigned int /* file_version */
- ){
-
-
-
- BOOST_STATIC_ASSERT((tracking_level< T >::value != track_never));
- const T * t_ptr = t.get();
- ar << boost::serialization::make_nvp("px", t_ptr);
- }
- #ifdef BOOST_SERIALIZATION_SHARED_PTR_132_HPP
- template<class Archive, class T>
- inline void load(
- Archive & ar,
- boost::shared_ptr< T > &t,
- const unsigned int file_version
- ){
-
-
- BOOST_STATIC_ASSERT((tracking_level< T >::value != track_never));
- T* r;
- if(file_version < 1){
- ar.register_type(static_cast<
- boost_132::detail::sp_counted_base_impl<T *, null_deleter > *
- >(NULL));
- boost_132::shared_ptr< T > sp;
- ar >> boost::serialization::make_nvp("px", sp.px);
- ar >> boost::serialization::make_nvp("pn", sp.pn);
-
- boost::serialization::shared_ptr_helper<boost::shared_ptr> & h =
- ar.template get_helper< shared_ptr_helper<boost::shared_ptr> >(
- shared_ptr_helper_id
- );
- h.append(sp);
- r = sp.get();
- }
- else{
- ar >> boost::serialization::make_nvp("px", r);
- }
- shared_ptr_helper<boost::shared_ptr> & h =
- ar.template get_helper<shared_ptr_helper<boost::shared_ptr> >(
- shared_ptr_helper_id
- );
- h.reset(t,r);
- }
- #else
- template<class Archive, class T>
- inline void load(
- Archive & ar,
- boost::shared_ptr< T > &t,
- const unsigned int /*file_version*/
- ){
-
-
-
- BOOST_STATIC_ASSERT((tracking_level< T >::value != track_never));
- T* r;
- ar >> boost::serialization::make_nvp("px", r);
- boost::serialization::shared_ptr_helper<boost::shared_ptr> & h =
- ar.template get_helper<shared_ptr_helper<boost::shared_ptr> >(
- shared_ptr_helper_id
- );
- h.reset(t,r);
- }
- #endif
- template<class Archive, class T>
- inline void serialize(
- Archive & ar,
- boost::shared_ptr< T > &t,
- const unsigned int file_version
- ){
-
-
- BOOST_STATIC_ASSERT(
- boost::serialization::tracking_level< T >::value
- != boost::serialization::track_never
- );
- boost::serialization::split_free(ar, t, file_version);
- }
- }
- }
- #ifndef BOOST_NO_CXX11_SMART_PTR
- #include <boost/static_assert.hpp>
- #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
- BOOST_STATIC_ASSERT(false);
- #endif
- namespace boost {
- namespace serialization{
- template<class T>
- struct version< ::std::shared_ptr< T > > {
- typedef mpl::integral_c_tag tag;
- typedef mpl::int_<1> type;
- BOOST_STATIC_CONSTANT(int, value = type::value);
- };
-
- template<class T>
- struct tracking_level< ::std::shared_ptr< T > > {
- typedef mpl::integral_c_tag tag;
- typedef mpl::int_< ::boost::serialization::track_never> type;
- BOOST_STATIC_CONSTANT(int, value = type::value);
- };
- }}
- #define BOOST_SERIALIZATION_SHARED_PTR(T)
- namespace boost {
- namespace serialization{
- template<class Archive, class T>
- inline void save(
- Archive & ar,
- const std::shared_ptr< T > &t,
- const unsigned int /* file_version */
- ){
-
-
-
- BOOST_STATIC_ASSERT((tracking_level< T >::value != track_never));
- const T * t_ptr = t.get();
- ar << boost::serialization::make_nvp("px", t_ptr);
- }
- template<class Archive, class T>
- inline void load(
- Archive & ar,
- std::shared_ptr< T > &t,
- const unsigned int /*file_version*/
- ){
-
-
-
- BOOST_STATIC_ASSERT((tracking_level< T >::value != track_never));
- T* r;
- ar >> boost::serialization::make_nvp("px", r);
-
- boost::serialization::shared_ptr_helper<std::shared_ptr> & h =
- ar.template get_helper<
- shared_ptr_helper<std::shared_ptr>
- >(
- shared_ptr_helper_id
- );
- h.reset(t,r);
- }
- template<class Archive, class T>
- inline void serialize(
- Archive & ar,
- std::shared_ptr< T > &t,
- const unsigned int file_version
- ){
-
-
- BOOST_STATIC_ASSERT(
- boost::serialization::tracking_level< T >::value
- != boost::serialization::track_never
- );
- boost::serialization::split_free(ar, t, file_version);
- }
- }
- }
- #endif
- #endif
|