1 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 |
---|
2 | // serializer_map.cpp: |
---|
3 | |
---|
4 | // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . |
---|
5 | // Use, modification and distribution is subject to the Boost Software |
---|
6 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
---|
7 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
8 | |
---|
9 | // See http://www.boost.org for updates, documentation, and revision history. |
---|
10 | |
---|
11 | #if (defined _MSC_VER) && (_MSC_VER == 1200) |
---|
12 | # pragma warning (disable : 4786) // too long name, harmless warning |
---|
13 | #endif |
---|
14 | |
---|
15 | #include <set> |
---|
16 | |
---|
17 | #define BOOST_ARCHIVE_SOURCE |
---|
18 | #include <boost/archive/detail/basic_serializer.hpp> |
---|
19 | #include <boost/archive/detail/basic_serializer_map.hpp> |
---|
20 | |
---|
21 | namespace boost { |
---|
22 | namespace serialization { |
---|
23 | class extended_type_info; |
---|
24 | } |
---|
25 | namespace archive { |
---|
26 | namespace detail { |
---|
27 | |
---|
28 | BOOST_ARCHIVE_DECL(bool) |
---|
29 | type_info_pointer_compare::operator()( |
---|
30 | const basic_serializer * lhs, const basic_serializer * rhs |
---|
31 | ) const { |
---|
32 | return *lhs < *rhs; |
---|
33 | } |
---|
34 | |
---|
35 | BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) |
---|
36 | basic_serializer_map::basic_serializer_map(bool & deleted) : |
---|
37 | m_deleted(deleted) |
---|
38 | { |
---|
39 | m_deleted = false; |
---|
40 | } |
---|
41 | |
---|
42 | BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) |
---|
43 | basic_serializer_map::~basic_serializer_map(){ |
---|
44 | m_deleted = true; |
---|
45 | } |
---|
46 | |
---|
47 | BOOST_ARCHIVE_DECL(bool) |
---|
48 | basic_serializer_map::insert(const basic_serializer * bs){ |
---|
49 | return m_map.insert(bs).second; |
---|
50 | } |
---|
51 | |
---|
52 | BOOST_ARCHIVE_DECL(void) |
---|
53 | basic_serializer_map::erase(basic_serializer * bs){ |
---|
54 | m_map.erase(bs); |
---|
55 | } |
---|
56 | |
---|
57 | class basic_serializer_arg : public basic_serializer { |
---|
58 | public: |
---|
59 | basic_serializer_arg(const serialization::extended_type_info & eti) : |
---|
60 | basic_serializer(eti) |
---|
61 | {} |
---|
62 | }; |
---|
63 | |
---|
64 | BOOST_ARCHIVE_DECL(const basic_serializer *) |
---|
65 | basic_serializer_map::tfind( |
---|
66 | const boost::serialization::extended_type_info & eti |
---|
67 | ) const { |
---|
68 | const basic_serializer_arg bs(eti); |
---|
69 | map_type::const_iterator it; |
---|
70 | it = m_map.find(& bs); |
---|
71 | if(it == m_map.end()) |
---|
72 | return NULL; |
---|
73 | return *it; |
---|
74 | } |
---|
75 | |
---|
76 | } // namespace detail |
---|
77 | } // namespace archive |
---|
78 | } // namespace boost |
---|