home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / typeinfo < prev    next >
Text File  |  1998-06-16  |  3KB  |  123 lines

  1. /***
  2. *typeinfo.h - Defines the type_info structure and exceptions used for RTTI
  3. *
  4. *    Copyright (c) 1994-1997, 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.  
  16. #if     _MSC_VER > 1000
  17. #pragma once
  18. #endif
  19.  
  20. #ifndef __cplusplus
  21. #error This header requires a C++ compiler ...
  22. #endif
  23.  
  24. #ifndef _INC_TYPEINFO
  25. #define _INC_TYPEINFO
  26.  
  27.  #if !defined(_WIN32) && !defined(_MAC)
  28.   #error ERROR: Only Mac or Win32 targets supported!
  29.  #endif
  30.  
  31.  
  32. /* Define _CRTIMP */
  33.  
  34. #ifndef _CRTIMP
  35. #ifdef    _NTSDK
  36. /* definition compatible with NT SDK */
  37. #define _CRTIMP
  38. #else    /* ndef _NTSDK */
  39. /* current definition */
  40. #ifdef    _DLL
  41. #define _CRTIMP __declspec(dllimport)
  42. #else    /* ndef _DLL */
  43. #define _CRTIMP
  44. #endif    /* _DLL */
  45. #endif    /* _NTSDK */
  46. #endif    /* _CRTIMP */
  47.  
  48. #include <xstddef>
  49.  
  50. #ifdef  _MSC_VER
  51. #pragma pack(push,8)
  52. #endif  /* _MSC_VER */
  53.  
  54. class type_info {
  55. public:
  56.     _CRTIMP virtual ~type_info();
  57.     _CRTIMP int operator==(const type_info& rhs) const;
  58.     _CRTIMP int operator!=(const type_info& rhs) const;
  59.     _CRTIMP int before(const type_info& rhs) const;
  60.     _CRTIMP const char* name() const;
  61.     _CRTIMP const char* raw_name() const;
  62. private:
  63.     void *_m_data;
  64.     char _m_d_name[1];
  65.     type_info(const type_info& rhs);
  66.     type_info& operator=(const type_info& rhs);
  67. };
  68.  
  69.  
  70. // This include must occur below the definition of class type_info
  71.  #include <exception>
  72.  
  73.  _STD_BEGIN
  74.         // CLASS bad_cast
  75. class _CRTIMP bad_cast : public exception {
  76. public:
  77.     bad_cast(const char *_S = "bad cast") _THROW0()
  78.         : exception(_S) {}
  79.     virtual ~bad_cast() _THROW0()
  80.         {}
  81. protected:
  82.     virtual void _Doraise() const
  83.         {_RAISE(*this); }
  84.     };
  85.         // CLASS bad_typeid
  86. class _CRTIMP bad_typeid : public exception {
  87. public:
  88.     bad_typeid(const char *_S = "bad typeid") _THROW0()
  89.         : exception(_S) {}
  90.     virtual ~bad_typeid() _THROW0()
  91.         {}
  92. protected:
  93.     virtual void _Doraise() const
  94.         {_RAISE(*this); }
  95.     };
  96.  
  97. class _CRTIMP __non_rtti_object : public bad_typeid {
  98. public:
  99.     __non_rtti_object(const char * what_arg) : bad_typeid(what_arg) {}
  100. };
  101. using ::type_info;
  102.  _STD_END
  103. using std::__non_rtti_object;
  104.  
  105. #ifdef __RTTI_OLDNAMES
  106. // Some synonyms for folks using older standard
  107. typedef type_info Type_info;
  108. typedef bad_cast Bad_cast;
  109. typedef bad_typeid Bad_typeid;
  110. #endif    // __RTTI_OLDNAMES
  111.  
  112. #ifdef  _MSC_VER
  113. #pragma pack(pop)
  114. #endif  /* _MSC_VER */
  115.  
  116. #endif // _INC_TYPEINFO
  117.  
  118. /*
  119.  * 1994-1995, Microsoft Corporation. All rights reserved.
  120.  * Modified January 1996 by P.J. Plauger
  121.  * Consult your license regarding permissions and restrictions.
  122.  */
  123.