]> gcc.gnu.org Git - gcc.git/blame - libstdc++/typeinfo
diagnostic.h (set_internal_error_function): Renamed.
[gcc.git] / libstdc++ / typeinfo
CommitLineData
9ab916b8
RH
1// RTTI support for -*- C++ -*-
2// Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000 Free Software Foundation
3
4// This file is part of GNU CC.
5//
6// GNU CC is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2, or (at your option)
9// any later version.
10//
11// GNU CC is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with GNU CC; see the file COPYING. If not, write to
18// the Free Software Foundation, 59 Temple Place - Suite 330,
19// Boston, MA 02111-1307, USA.
20
21// As a special exception, you may use this file as part of a free software
22// library without restriction. Specifically, if other files instantiate
23// templates or use macros or inline functions from this file, or you compile
24// this file and link it with other files to produce an executable, this
25// file does not by itself cause the resulting executable to be covered by
26// the GNU General Public License. This exception does not however
27// invalidate any other reasons why the executable file might be covered by
28// the GNU General Public License.
29
30// __GXX_ABI_VERSION distinguishes the ABI that is being used. Values <100
31// indicate the `old' abi, which grew as C++ was defined. Values >=100
32// indicate the `new' abi, which is a cross vendor C++ abi, documented at
33// `http://reality.sgi.com/dehnert_engr/cxx/'.
34
35#ifndef __TYPEINFO__
36#define __TYPEINFO__
37
38#pragma interface "typeinfo"
39
40#include <exception>
41
42extern "C++" {
43
44#if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
45namespace __cxxabiv1
46{
47 class __class_type_info;
48} // namespace __cxxabiv1
49#endif
50
51namespace std {
52
53class type_info {
54public:
55 // Destructor. Being the first non-inline virtual function, this controls in
56 // which translation unit the vtable is emitted. The compiler makes use of
57 // that information to know where to emit the runtime-mandated type_info
58 // structures in the new-abi.
59 virtual ~type_info ();
60
61private:
62 // Assigning type_info is not supported. made private.
63 type_info& operator= (const type_info&);
64 type_info (const type_info&);
65
66protected:
67 const char *__name;
68
69protected:
70 explicit type_info (const char *__n): __name (__n) { }
71
72public:
73 // the public interface
74#if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100
75 // In old abi, there can be multiple instances of a type_info object for one
76 // type. Uniqueness must use the _name value, not object address.
77 bool before (const type_info& arg) const;
78 const char* name () const
79 { return __name; }
80 bool operator== (const type_info& __arg) const;
81 bool operator!= (const type_info& __arg) const
82 { return !operator== (__arg); }
83
84#else
85 // In new abi we can rely on type_info's NTBS being unique,
86 // and therefore address comparisons are sufficient.
87 bool before (const type_info& __arg) const
88 { return __name < __arg.__name; }
89 const char* name () const
90 { return __name; }
91 bool operator== (const type_info& __arg) const
92 { return __name == __arg.__name; }
93 bool operator!= (const type_info& __arg) const
94 { return !operator== (__arg); }
95#endif
96
97 // the internal interface
98#if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
99public:
100 // return true if this is a pointer type of some kind
101 virtual bool __is_pointer_p () const;
102 // return true if this is a function type
103 virtual bool __is_function_p () const;
104
105 // Try and catch a thrown type. Store an adjusted pointer to the caught type
106 // in THR_OBJ. If THR_TYPE is not a pointer type, then THR_OBJ points to the
107 // thrown object. If THR_TYPE is a pointer type, then THR_OBJ is the pointer
108 // itself. OUTER indicates the number of outer pointers, and whether they
109 // were const qualified.
110 virtual bool __do_catch (const type_info *__thr_type, void **__thr_obj,
111 unsigned __outer) const;
112
113 // internally used during catch matching
114 virtual bool __do_upcast (const __cxxabiv1::__class_type_info *__target,
115 void **__obj_ptr) const;
116#endif
117};
118
119class bad_cast : public exception {
120public:
121 bad_cast() { }
122 virtual ~bad_cast() { }
123};
124
125class bad_typeid : public exception {
126 public:
127 bad_typeid () { }
128 virtual ~bad_typeid () { }
129};
130
131} // namespace std
132
133} // extern "C++"
134#endif
This page took 0.074634 seconds and 5 git commands to generate.