| 1 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 |
|---|---|
| 2 | // extended_type_info_no_rtti.cpp: specific implementation of type info |
| 3 | // that is NOT based on typeid |
| 4 | |
| 5 | // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . |
| 6 | // Use, modification and distribution is subject to the Boost Software |
| 7 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 8 | // http://www.boost.org/LICENSE_1_0.txt) |
| 9 | |
| 10 | // See http://www.boost.org for updates, documentation, and revision history. |
| 11 | |
| 12 | #include <cstring> |
| 13 | #include <cstddef> // NULL |
| 14 | #include <boost/assert.hpp> |
| 15 | |
| 16 | #include <boost/config.hpp> |
| 17 | #if defined(BOOST_NO_STDC_NAMESPACE) |
| 18 | namespace std{ using ::strcmp; } |
| 19 | #endif |
| 20 | |
| 21 | // it marks our code with proper attributes as being exported when |
| 22 | // we're compiling it while marking it import when just the headers |
| 23 | // is being included. |
| 24 | #define BOOST_SERIALIZATION_SOURCE |
| 25 | #include <boost/serialization/config.hpp> |
| 26 | #include <boost/serialization/extended_type_info_no_rtti.hpp> |
| 27 | |
| 28 | #define EXTENDED_TYPE_INFO_NO_RTTI_KEY 2 |
| 29 | |
| 30 | namespace boost { |
| 31 | namespace serialization { |
| 32 | namespace no_rtti_system { |
| 33 | |
| 34 | BOOST_SERIALIZATION_DECL |
| 35 | extended_type_info_no_rtti_0::extended_type_info_no_rtti_0( |
| 36 | const char * key |
| 37 | ) : |
| 38 | extended_type_info(EXTENDED_TYPE_INFO_NO_RTTI_KEY, key) |
| 39 | {} |
| 40 | |
| 41 | BOOST_SERIALIZATION_DECL bool |
| 42 | extended_type_info_no_rtti_0::is_less_than( |
| 43 | const boost::serialization::extended_type_info &rhs) const |
| 44 | { |
| 45 | // shortcut for common case |
| 46 | if(this == & rhs) |
| 47 | return false; |
| 48 | const char * l = get_key(); |
| 49 | const char * r = rhs.get_key(); |
| 50 | // if this assertion is triggered, it could mean one of the following |
| 51 | // a) This class was never exported - make sure all calls which use |
| 52 | // this method of type id are in fact exported. |
| 53 | // b) This class was used (e.g. serialized through a pointer) before |
| 54 | // it was exported. Make sure that classes which use this method |
| 55 | // of type id are NOT "automatically" registered by serializing |
| 56 | // through a pointer to the most derived class. OR make sure |
| 57 | // that the BOOST_CLASS_EXPORT is included in every file |
| 58 | // which does this. |
| 59 | BOOST_ASSERT(NULL != l); |
| 60 | BOOST_ASSERT(NULL != r); |
| 61 | return std::strcmp(s1: l, s2: r) < 0; |
| 62 | } |
| 63 | |
| 64 | BOOST_SERIALIZATION_DECL bool |
| 65 | extended_type_info_no_rtti_0::is_equal( |
| 66 | const boost::serialization::extended_type_info &rhs) const |
| 67 | { |
| 68 | // shortcut for common case |
| 69 | if(this == & rhs) |
| 70 | return true; |
| 71 | // null keys don't match with anything |
| 72 | const char * l = get_key(); |
| 73 | BOOST_ASSERT(NULL != l); |
| 74 | if(NULL == l) |
| 75 | return false; |
| 76 | const char * r = rhs.get_key(); |
| 77 | BOOST_ASSERT(NULL != r); |
| 78 | if(NULL == r) |
| 79 | return false; |
| 80 | return 0 == std::strcmp(s1: l, s2: r); |
| 81 | } |
| 82 | |
| 83 | BOOST_SERIALIZATION_DECL |
| 84 | extended_type_info_no_rtti_0::~extended_type_info_no_rtti_0() |
| 85 | {} |
| 86 | |
| 87 | } // namespace detail |
| 88 | } // namespace serialization |
| 89 | } // namespace boost |
| 90 |
