1 // Copyright (C) 2011 The Android Open Source Project 2 // All rights reserved. 3 // 4 // Redistribution and use in source and binary forms, with or without 5 // modification, are permitted provided that the following conditions 6 // are met: 7 // 1. Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // 2. Redistributions in binary form must reproduce the above copyright 10 // notice, this list of conditions and the following disclaimer in the 11 // documentation and/or other materials provided with the distribution. 12 // 3. Neither the name of the project nor the names of its contributors 13 // may be used to endorse or promote products derived from this software 14 // without specific prior written permission. 15 // 16 // THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 // ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 // SUCH DAMAGE. 27 // 28 // typeinfo: RTTI support header. 29 // 30 // References: 31 // Itanium C++ ABI at http://www.codesourcery.com/public/cxx-abi/abi.html. 32 // IHI0041A C++ Application Binary Interface for the ARM architecture. 33 // Linux Standard Base C++ Specification for S390X 4.1. 34 // 35 #ifndef __GABIXX_TYPEINFO__ 36 #define __GABIXX_TYPEINFO__ 37 38 #if !defined(GABIXX_LIBCXX) 39 40 #include <exception> 41 42 namespace std 43 { 44 // Defintion of type_info based on example in C++ ABI section 2.9.3 45 class type_info 46 { 47 public: 48 virtual 49 ~type_info(); 50 51 // Whether two type_infos corresponds to the same types. 52 bool 53 operator==(const type_info &ti) const; 54 55 // Whether two type_infos corresponds to the different types. 56 bool 57 operator!=(const type_info &ti) const; 58 59 bool 60 before(const type_info &ti) const; 61 62 // Return name of type. 63 const char* name() const { 64 // Compatible with GNU 65 return (__type_name[0] == '*') ? __type_name + 1 : __type_name; 66 } 67 68 private: 69 // Assignment of type_info is not allowed. 70 type_info (const type_info& rhs); 71 72 type_info& 73 operator=(const type_info& rhs); 74 75 // Mangled name of type. 76 const char *__type_name; 77 }; 78 79 80 class bad_cast : public exception { 81 public: 82 bad_cast() throw(); 83 virtual ~bad_cast() throw(); 84 virtual const char* what() const throw(); 85 }; 86 87 class bad_typeid : public exception { 88 public: 89 bad_typeid() throw(); 90 virtual ~bad_typeid() throw(); 91 virtual const char* what() const throw(); 92 }; 93 94 } // namespace std 95 96 #endif // !defined(GABIXX_LIBCXX) 97 98 #endif // _GABIXX_TYPEINFO_ 99