|
|
|
1 |
|
/*** |
2 |
|
*typeinfo.h - Defines the type_info structure and exceptions used for RTTI |
3 |
|
* |
4 |
|
* Copyright (c) Microsoft Corporation. All rights reserved. |
5 |
|
* Modified January 1996 by P.J. Plauger |
6 |
|
* |
7 |
|
*Purpose: |
8 |
|
* Defines the type_info structure and exceptions used for |
9 |
|
* Runtime Type Identification. |
10 |
|
* |
11 |
|
* [Public] |
12 |
|
* |
13 |
|
****/ |
14 |
|
|
15 |
|
#if _MSC_VER > 1000 |
16 |
|
#pragma once |
17 |
|
#endif |
18 |
|
|
19 |
|
#ifndef _TYPEINFO_ |
20 |
|
#define _TYPEINFO_ |
21 |
|
#ifndef RC_INVOKED |
22 |
|
#include <xstddef> |
23 |
|
|
24 |
|
#ifdef _MSC_VER |
25 |
|
#pragma pack(push,_CRT_PACKING) |
26 |
|
#endif /* _MSC_VER */ |
27 |
|
|
28 |
|
#ifndef __cplusplus |
29 |
|
#error This header requires a C++ compiler ... |
30 |
|
#endif |
31 |
|
|
32 |
|
#if !defined(_WIN32) |
33 |
|
#error ERROR: Only Win32 target supported! |
34 |
|
#endif |
35 |
|
|
36 |
|
struct __type_info_node { |
37 |
|
void *memPtr; |
38 |
|
__type_info_node* next; |
39 |
|
}; |
40 |
|
|
41 |
|
extern __type_info_node __type_info_root_node; |
42 |
|
|
43 |
|
class type_info { |
44 |
|
public: |
45 |
|
virtual ~type_info(); |
46 |
|
_CRTIMP_PURE bool __CLR_OR_THIS_CALL operator==(const type_info& rhs) const; |
47 |
|
_CRTIMP_PURE bool __CLR_OR_THIS_CALL operator!=(const type_info& rhs) const; |
48 |
|
_CRTIMP_PURE int __CLR_OR_THIS_CALL before(const type_info& rhs) const; |
49 |
|
_CRTIMP_PURE const char* __CLR_OR_THIS_CALL name(__type_info_node* __ptype_info_node = &__type_info_root_node) const; |
50 |
|
_CRTIMP_PURE const char* __CLR_OR_THIS_CALL raw_name() const; |
51 |
|
private: |
52 |
|
void *_m_data; |
53 |
|
char _m_d_name[1]; |
54 |
|
__CLR_OR_THIS_CALL type_info(const type_info& rhs); |
55 |
|
type_info& __CLR_OR_THIS_CALL operator=(const type_info& rhs); |
56 |
|
_CRTIMP_PURE static const char *__CLRCALL_OR_CDECL _Name_base(const type_info *,__type_info_node* __ptype_info_node); |
57 |
|
_CRTIMP_PURE static void __CLRCALL_OR_CDECL _Type_info_dtor(type_info *); |
58 |
|
}; |
59 |
|
|
60 |
|
#if _HAS_EXCEPTIONS |
61 |
|
|
62 |
|
_STD_BEGIN |
63 |
|
|
64 |
|
using ::type_info; |
65 |
|
|
66 |
|
_STD_END |
67 |
|
|
68 |
|
|
69 |
|
// This include must occur below the definition of class type_info |
70 |
|
#include <exception> |
71 |
|
|
72 |
|
_STD_BEGIN |
73 |
|
|
74 |
|
class _CRTIMP_PURE bad_cast : public exception { |
75 |
|
public: |
76 |
|
#ifdef _M_CEE_PURE |
77 |
|
__CLR_OR_THIS_CALL bad_cast(const char * _Message = "bad cast") |
78 |
|
: exception(_Message) |
79 |
|
{} |
80 |
|
__CLR_OR_THIS_CALL bad_cast(const bad_cast &_That) |
81 |
|
: exception(_That) |
82 |
|
{} |
83 |
|
virtual __CLR_OR_THIS_CALL ~bad_cast() |
84 |
|
{} |
85 |
|
#else /* _M_CEE_PURE */ |
86 |
|
__CLR_OR_THIS_CALL bad_cast(const char * _Message = "bad cast"); |
87 |
|
__CLR_OR_THIS_CALL bad_cast(const bad_cast &); |
88 |
|
virtual __CLR_OR_THIS_CALL ~bad_cast(); |
89 |
|
#endif /* _M_CEE_PURE */ |
90 |
|
}; |
91 |
|
|
92 |
|
class _CRTIMP_PURE bad_typeid : public exception { |
93 |
|
public: |
94 |
|
#ifdef _M_CEE_PURE |
95 |
|
__CLR_OR_THIS_CALL bad_typeid(const char * _Message = "bad typeid") |
96 |
|
: exception(_Message) |
97 |
|
{} |
98 |
|
__CLR_OR_THIS_CALL bad_typeid(const bad_typeid &_That) |
99 |
|
: exception(_That) |
100 |
|
{} |
101 |
|
virtual __CLR_OR_THIS_CALL ~bad_typeid() |
102 |
|
{} |
103 |
|
#else /* _M_CEE_PURE */ |
104 |
|
__CLR_OR_THIS_CALL bad_typeid(const char * _Message = "bad typeid"); |
105 |
|
__CLR_OR_THIS_CALL bad_typeid(const bad_typeid &); |
106 |
|
virtual __CLR_OR_THIS_CALL ~bad_typeid(); |
107 |
|
#endif /* _M_CEE_PURE */ |
108 |
|
|
109 |
|
}; |
110 |
|
|
111 |
|
class _CRTIMP_PURE __non_rtti_object : public bad_typeid { |
112 |
|
public: |
113 |
|
#ifdef _M_CEE_PURE |
114 |
|
__CLR_OR_THIS_CALL __non_rtti_object(const char * _Message) |
115 |
|
: bad_typeid(_Message) |
116 |
|
{} |
117 |
|
__CLR_OR_THIS_CALL __non_rtti_object(const __non_rtti_object &_That) |
118 |
|
: bad_typeid(_That) |
119 |
|
{} |
120 |
|
virtual __CLR_OR_THIS_CALL ~__non_rtti_object() |
121 |
|
{} |
122 |
|
#else /* _M_CEE_PURE */ |
123 |
|
__CLR_OR_THIS_CALL __non_rtti_object(const char * _Message); |
124 |
|
__CLR_OR_THIS_CALL __non_rtti_object(const __non_rtti_object &); |
125 |
|
virtual __CLR_OR_THIS_CALL ~__non_rtti_object(); |
126 |
|
#endif /* _M_CEE_PURE */ |
127 |
|
}; |
128 |
|
|
129 |
|
_STD_END |
130 |
|
|
131 |
|
|
132 |
|
#else |
133 |
|
|
134 |
|
_STD_BEGIN |
135 |
|
|
136 |
|
// CLASS bad_cast |
137 |
|
class _CRTIMP2 bad_cast |
138 |
|
: public exception |
139 |
|
{ // base of all bad cast exceptions |
140 |
|
public: |
141 |
|
bad_cast(const char *_Message = "bad cast") _THROW0() |
142 |
|
: exception(_Message) |
143 |
|
{ // construct from message string |
144 |
|
} |
145 |
|
|
146 |
|
virtual ~bad_cast() _THROW0() |
147 |
|
{ // destroy the object |
158 |
|
class _CRTIMP2 bad_typeid |
159 |
|
: public exception |
160 |
|
{ // base of all bad typeid exceptions |
161 |
|
public: |
162 |
|
bad_typeid(const char *_Message = "bad typeid") _THROW0() |
163 |
|
: exception(_Message) |
164 |
|
{ // construct from message string |
165 |
|
} |
166 |
|
|
167 |
|
virtual ~bad_typeid() _THROW0() |
168 |
|
{ // destroy the object |
169 |
|
} |
170 |
|
|
171 |
|
protected: |
172 |
|
virtual void _Doraise() const |
173 |
|
{ // perform class-specific exception handling |
174 |
|
_RAISE(*this); |
175 |
|
} |
176 |
|
}; |
177 |
|
|
178 |
|
class _CRTIMP2 __non_rtti_object |
179 |
|
: public bad_typeid |
180 |
|
{ // report a non RTTI object |
181 |
|
public: |
182 |
|
__non_rtti_object(const char *_Message) |
183 |
|
: bad_typeid(_Message) |
184 |
|
{ // construct from message string |
185 |
|
} |
186 |
|
}; |
187 |
|
_STD_END |
188 |
|
|
189 |
|
#endif /* _HAS_EXCEPTIONS */ |
190 |
|
|
191 |
|
#endif /* RC_INVOKED */ |
192 |
|
|
193 |
|
#ifdef _MSC_VER |
194 |
|
#pragma pack(pop) |
195 |
|
#endif /* _MSC_VER */ |
196 |
|
|
197 |
|
#endif // _TYPEINFO_ |
198 |
|
|
199 |
|
/* |
200 |
|
* Copyright (c) Microsoft Corporation. All rights reserved. |
201 |
|
* Modified January 1996 by P.J. Plauger |
202 |
|
* Modified November 1998 by P.J. Plauger |
203 |
|
* Consult your license regarding permissions and restrictions. |
204 |
|
*/ |
205 |
|
|
|
|
|