Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
typeinfo.cpp
Go to the documentation of this file.
1
30#define _RWSTD_LIB_SRC
31
32#include <rw/_defs.h>
33
34#include <typeinfo>
35#include <string.h>
36
37
39
40inline int
41__rw_ticmp (const _STD::type_info &lhs, const _STD::type_info &rhs)
42{
43 const char* const n1 = lhs.name ();
44 const char* const n2 = rhs.name ();
45
46 return strcmp (n1 ? n1 : "", n2 ? n2 : "");
47}
48
49} // namespace __rw
50
51
52// class type_info members
53
54#if defined _RWSTD_TYPEINFO_INCLUDED
55
56// define type_info members only if our own <typeinfo> header
57// (as opposed to the compiler's native) has been included
58// SunPro always #includes its own, regardless of options
59
60# if !defined (_RWSTD_NO_STD_TYPE_INFO) \
61 || !defined (_RWSTD_NO_GLOBAL_TYPE_INFO)
62
63// at least one of the config tests above succeeded,
64// rely on config tests for each individual member
65
66# ifndef _RWSTD_NO_STD_TYPE_INFO
67
68// define type_info et al in namespace std iff they are found to be
69// defined in namespace std in the compiler's language support library
70// or if they are not found to be defined in either namespace std or
71// in the global namespace
72
74
75# endif // _RWSTD_NO_STD_TYPE_INFO
76
77
78# ifdef _RWSTD_NO_TYPE_INFO_DTOR
79
80type_info::~type_info () { }
81
82# endif // _RWSTD_NO_TYPE_INFO_DTOR
83
84
85# ifdef _RWSTD_NO_TYPE_INFO_BEFORE
86
87bool type_info::before (const type_info &rhs) const
88{
89 return 0 > _RW::__rw_ticmp (*this, rhs);
90}
91
92# endif // _RWSTD_NO_TYPE_INFO_BEFORE
93
94
95# ifdef _RWSTD_NO_TYPE_INFO_NAME
96
97// used in type_info::name() when the class has no member called _C_name
98static const char _C_name[] = "";
99
100const char* type_info::name () const
101{
102 // silence warning: _C_name declared but never used
103#ifdef _RWSTD_NO_STD_TYPE_INFO
104 _RWSTD_UNUSED (::_C_name);
105#else
106 _RWSTD_UNUSED (std::_C_name);
107#endif // _RWSTD_NO_STD_TYPE_INFO
108
109 return _C_name;
110}
111
112# endif // _RWSTD_NO_TYPE_INFO_NAME
113
114
115# ifdef _RWSTD_NO_TYPE_INFO_EQUALITY
116
117bool type_info::operator== (const type_info &rhs) const
118{
119 return !before (rhs) && !rhs.before (*this);
120}
121
122# endif // _RWSTD_NO_TYPE_INFO_EQUALITY
123
124
125# ifdef _RWSTD_NO_TYPE_INFO_INEQUALITY
126
127bool type_info::operator!= (const type_info &rhs) const
128{
129 return !(*this == rhs);
130}
131
132# endif // _RWSTD_NO_TYPE_INFO_INEQUALITY
133
134# ifndef _RWSTD_NO_STD_TYPE_INFO
135
136} // namespace std
137
138# endif // _RWSTD_NO_STD_TYPE_INFO
139
140# else // if _RWSTD_NO_STD_TYPEINFO && _RWSTD_NO_GLOBAL_TYPEINFO
141
142// both config tests for class type_info failed so config test
143// results for each individual member are likely to be unreliable
144// rely on platform knowledge instead
145
146# ifndef _RWSTD_NO_RUNTIME_IN_STD
147
149
150# endif // _RWSTD_NO_RUNTIME_IN_STD
151
152# if defined (__HP_aCC)
153
154const char* type_info::name () const
155{
156 return _C_name;
157}
158
159# ifdef _HP_IA64ABI
160
161bool type_info::before (const type_info &rhs) const
162{
163 return name () < rhs.name ();
164}
165
166bool type_info::operator== (const type_info &rhs) const
167{
168 return name () == rhs.name ();
169}
170
171bool type_info::operator!= (const type_info &rhs) const
172{
173 return !(*this == rhs);
174}
175
176# endif // _HP_IA64ABI
177
178# elif defined (__INTEL_COMPILER) && !defined (_MSC_VER)
179
180const char* type_info::name () const
181{
182 return _C_name;
183}
184
185bool type_info::before (const type_info &rhs) const
186{
187 return name () < rhs.name ();
188}
189
190bool type_info::operator== (const type_info &rhs) const
191{
192 return name () == rhs.name ();
193}
194
195bool type_info::operator!= (const type_info &rhs) const
196{
197 return !(*this == rhs);
198}
199
200# elif defined (__GNUG__) && !defined (_RWSTD_NO_HONOR_STD)
201
202// define member functions inline in namespace std (they are defined
203// as members of ::type_info (as opposed to std::type_info) in libstdc++
204// unless lib is built with -fhonor-std
205
206const char* type_info::name () const
207{
208 return _C_name;
209}
210
211bool type_info::operator== (const type_info &rhs) const
212{
213 return !this->before (rhs) && !rhs.before (*this);
214}
215
216bool type_info::operator!= (const type_info &rhs) const
217{
218 return !(*this == rhs);
219}
220
221# elif defined (__IBMCPP__)
222
223const char* type_info::name () const
224{
225 return _C_typeName;
226}
227
228bool type_info::operator== (const type_info &rhs) const
229{
230 return !this->before (rhs) && !rhs.before (*this);
231}
232
233bool type_info::operator!= (const type_info &rhs) const
234{
235 return !(*this == rhs);
236}
237
238# endif // __IBMCPP__
239
240
241# if defined (__GNUG__) && !defined (_RWSTD_NO_HONOR_STD)
242
243// define member function in namespace std (it is defined as a member
244// of ::type_info (as opposed to std::type_info) in libstdc++
245// unless lib is built with -fhonor-std
246bool type_info::before (const type_info &rhs) const
247{
248 return 0 > _RW::__rw_ticmp (*this, rhs);
249}
250
251# elif defined (__IBMCPP__)
252
253bool type_info::before (const type_info &rhs) const
254{
255 return 0 > _RW::__rw_ticmp (*this, rhs);
256}
257
258# endif // __GNUG__ && !_RWSTD_NO_HONOR_STD
259
260
261# ifdef _MSC_VER
262
263const char* type_info::name () const
264{
265 return _C_name;
266}
267
268
269// define in global namespace just like MSVC wants it
270bool type_info::before (const type_info &rhs) const
271{
272 return 0 > _RW::__rw_ticmp (*this, rhs);
273}
274
275
276bool type_info::operator== (const type_info &rhs) const
277{
278 return 0 == _RW::__rw_ticmp (*this, rhs);
279}
280
281
282bool type_info::operator!= (const type_info &rhs) const
283{
284 return !(*this == rhs);
285}
286
287# endif // _MSC_VER
288
289# ifndef _RWSTD_NO_RUNTIME_IN_STD
290
291} // namespace std
292
293# endif // _RWSTD_NO_RUNTIME_IN_STD
294
295# endif // !_RWSTD_NO_STD_TYPEINFO || !_RWSTD_NO_GLOBAL_TYPEINFO
296
297
298//**************************************************************************
299// class bad_cast members
300
301# ifndef _RWSTD_NO_STD_BAD_CAST
302
304
305# endif // _RWSTD_NO_STD_BAD_CAST
306
307# ifdef _RWSTD_NO_BAD_CAST_DEFAULT_CTOR
308
309bad_cast::bad_cast () _THROWS (())
310{
311 // empty
312}
313
314# endif // _RWSTD_NO_BAD_CAST_DEFAULT_CTOR
315
316# ifdef _RWSTD_NO_BAD_CAST_COPY_CTOR
317
318bad_cast::bad_cast (const bad_cast &rhs) _THROWS (())
319 : exception (rhs)
320{
321 // empty
322}
323
324# endif // _RWSTD_NO_BAD_CAST_COPY_CTOR
325
326# ifdef _RWSTD_NO_BAD_CAST_DTOR
327
328bad_cast::~bad_cast () _THROWS (())
329{
330 // empty
331}
332
333# endif // _RWSTD_NO_BAD_CAST_DTOR
334
335# ifdef _RWSTD_NO_BAD_CAST_ASSIGNMENT
336
338bad_cast::operator= (const bad_cast &rhs) _THROWS (())
339{
340 exception::operator= (rhs);
341
342 return *this;
343}
344
345# endif // _RWSTD_NO_BAD_CAST_ASSIGNMENT
346
347# ifdef _RWSTD_NO_BAD_CAST_WHAT
348
349const char* bad_cast::what () const _THROWS (())
350{
351 return "bad_cast";
352}
353
354# endif // _RWSTD_NO_BAD_CAST_WHAT
355
356# ifndef _RWSTD_NO_STD_BAD_CAST
357
358} // namespace std
359
360# endif // _RWSTD_NO_STD_BAD_CAST
361
362
363//**************************************************************************
364// class bad_typeid members
365
366# ifndef _RWSTD_NO_STD_BAD_TYPEID
367
369
370# endif // _RWSTD_NO_STD_BAD_TYPEID
371
372bad_typeid::bad_typeid () _THROWS (())
373{
374 // empty
375}
376
377bad_typeid::bad_typeid (const bad_typeid &rhs) _THROWS (())
378 : exception (rhs)
379{
380 // empty
381}
382
383bad_typeid::~bad_typeid () _THROWS (())
384{
385 // empty
386}
387
388# ifdef _RWSTD_NO_BAD_TYPEID_ASSIGNMENT
389
391bad_typeid::operator= (const bad_typeid &rhs) _THROWS (())
392{
393 exception::operator= (rhs);
394
395 return *this;
396}
397
398# endif // _RWSTD_NO_BAD_TYPEID_ASSIGNMENT
399
400const char* bad_typeid::what () const _THROWS (())
401{
402 return "bad_typeid";
403}
404
405# ifndef _RWSTD_NO_STD_BAD_TYPEID
406
407} // namespace std
408
409# endif // _RWSTD_NO_STD_BAD_TYPEID
410
411#endif // _RWSTD_TYPEINFO_INCLUDED
#define rhs
Definition 17.names.cpp:536
#define n2
Definition 17.names.cpp:263
#define lhs
Definition 17.names.cpp:489
#define n1
Definition 17.names.cpp:237
#define _THROWS()
bad_typeid
#define _RWSTD_UNUSED(arg)
Definition _defs.h:972
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567
const char * name
Definition codecvt1.cpp:72
Definition json.h:5363