1 #ifndef BOOST_EXTENDED_TYPE_INFO_NO_RTTI_HPP
2 #define BOOST_EXTENDED_TYPE_INFO_NO_RTTI_HPP
4 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
5 // MS compatible compilers support #pragma once
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
10 // extended_type_info_no_rtti.hpp: implementation for version that depends
11 // on runtime typing (rtti - typeid) but uses a user specified string
12 // as the portable class identifier.
14 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
15 // Use, modification and distribution is subject to the Boost Software
16 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
19 // See http://www.boost.org for updates, documentation, and revision history.
22 #include <boost/config.hpp>
23 #include <boost/static_assert.hpp>
25 #include <boost/serialization/singleton.hpp>
26 #include <boost/serialization/extended_type_info.hpp>
27 #include <boost/serialization/factory.hpp>
29 #include <boost/config/abi_prefix.hpp> // must be the last header
31 # pragma warning(push)
32 # pragma warning(disable : 4251 4231 4660 4275)
36 namespace serialization
{
37 ///////////////////////////////////////////////////////////////////////
38 // define a special type_info that doesn't depend on rtti which is not
39 // available in all situations.
43 // common base class to share type_info_key. This is used to
44 // identify the method used to keep track of the extended type
45 class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) extended_type_info_no_rtti_0
:
46 public extended_type_info
49 extended_type_info_no_rtti_0();
50 ~extended_type_info_no_rtti_0();
53 is_less_than(const boost::serialization::extended_type_info
&rhs
) const ;
55 is_equal(const boost::serialization::extended_type_info
&rhs
) const ;
61 class extended_type_info_no_rtti
:
62 public detail::extended_type_info_no_rtti_0
,
63 public singleton
<extended_type_info_no_rtti
<T
> >
66 const extended_type_info
*
67 get_derived_extended_type_info(const T
& t
) const {
68 // find the type that corresponds to the most derived type.
69 // this implementation doesn't depend on typeid() but assumes
70 // that the specified type has a function of the following signature.
71 // A common implemention of such a function is to define as a virtual
73 const char * derived_key
= t
.get_key();
74 assert(NULL
!= derived_key
);
75 return boost::serialization::extended_type_info::find(derived_key
);
77 void * construct(unsigned int count
, ...) const{
78 // count up the arguments
83 return factory
<T
, 0>(ap
);
85 return factory
<T
, 1>(ap
);
87 return factory
<T
, 2>(ap
);
89 return factory
<T
, 3>(ap
);
91 return factory
<T
, 4>(ap
);
93 assert(false); // too many arguments
94 // throw exception here?
98 void destroy(void const * const p
) const{
99 delete static_cast<T
const *>(p
) ;
103 } // namespace serialization
106 ///////////////////////////////////////////////////////////////////////////////
107 // If no other implementation has been designated as default,
108 // use this one. To use this implementation as the default, specify it
109 // before any of the other headers.
111 #ifndef BOOST_SERIALIZATION_DEFAULT_TYPE_INFO
112 #define BOOST_SERIALIZATION_DEFAULT_TYPE_INFO
114 namespace serialization
{
116 struct extended_type_info_impl
{
117 typedef BOOST_DEDUCED_TYPENAME
118 boost::serialization::extended_type_info_no_rtti
<T
> type
;
120 } // namespace serialization
125 # pragma warning(pop)
127 #include <boost/config/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
129 #endif // BOOST_EXTENDED_TYPE_INFO_NO_RTTI_HPP