1 | #ifndef BOOST_SERIALIZATION_SCOPED_PTR_HPP_VP_2003_10_30
|
---|
2 | #define BOOST_SERIALIZATION_SCOPED_PTR_HPP_VP_2003_10_30
|
---|
3 |
|
---|
4 | #if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
---|
5 | # pragma once
|
---|
6 | #endif
|
---|
7 |
|
---|
8 | // Copyright (c) 2003 Vladimir Prus.
|
---|
9 | // Use, modification and distribution is subject to the Boost Software
|
---|
10 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
11 | // http://www.boost.org/LICENSE_1_0.txt)
|
---|
12 |
|
---|
13 | // Provides non-intrusive serialization for boost::scoped_ptr
|
---|
14 | // Does not allow to serialize scoped_ptr's to builtin types.
|
---|
15 |
|
---|
16 | #include <boost/config.hpp>
|
---|
17 |
|
---|
18 | #include <boost/scoped_ptr.hpp>
|
---|
19 | #include <boost/serialization/nvp.hpp>
|
---|
20 | #include <boost/serialization/split_free.hpp>
|
---|
21 |
|
---|
22 | namespace boost {
|
---|
23 | namespace serialization {
|
---|
24 |
|
---|
25 | template<class Archive, class T>
|
---|
26 | void save(
|
---|
27 | Archive & ar,
|
---|
28 | const boost::scoped_ptr<T> & t,
|
---|
29 | const unsigned int /* version */
|
---|
30 | ){
|
---|
31 | T* r = t.get();
|
---|
32 | ar << boost::serialization::make_nvp("scoped_ptr", r);
|
---|
33 | }
|
---|
34 |
|
---|
35 | template<class Archive, class T>
|
---|
36 | void load(
|
---|
37 | Archive & ar,
|
---|
38 | boost::scoped_ptr<T> & t,
|
---|
39 | const unsigned int /* version */
|
---|
40 | ){
|
---|
41 | T* r;
|
---|
42 | ar >> boost::serialization::make_nvp("scoped_ptr", r);
|
---|
43 | t.reset(r);
|
---|
44 | }
|
---|
45 |
|
---|
46 | template<class Archive, class T>
|
---|
47 | void serialize(
|
---|
48 | Archive& ar,
|
---|
49 | boost::scoped_ptr<T>& t,
|
---|
50 | const unsigned int version
|
---|
51 | ){
|
---|
52 | boost::serialization::split_free(ar, t, version);
|
---|
53 | }
|
---|
54 |
|
---|
55 | } // namespace serialization
|
---|
56 | } // namespace boost
|
---|
57 |
|
---|
58 | #endif // BOOST_SERIALIZATION_SCOPED_PTR_HPP_VP_2003_10_30
|
---|