home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / typeinfo.h < prev    next >
C/C++ Source or Header  |  1998-06-17  |  2KB  |  96 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. *
  6. *Purpose:
  7. *       Defines the type_info structure and exceptions used for
  8. *       Runtime Type Identification.
  9. *
  10. *       [Public]
  11. *
  12. ****/
  13.  
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif  /* _MSC_VER > 1000 */
  17.  
  18. #ifndef __cplusplus
  19. #error This header requires a C++ compiler ...
  20. #endif  /* __cplusplus */
  21.  
  22. #ifndef _INC_TYPEINFO
  23. #define _INC_TYPEINFO
  24.  
  25. #if !defined (_WIN32) && !defined (_MAC)
  26. #error ERROR: Only Mac or Win32 targets supported!
  27. #endif  /* !defined (_WIN32) && !defined (_MAC) */
  28.  
  29. #ifndef _CRTBLD
  30. /* This version of the header files is NOT for user programs.
  31.  * It is intended for use when building the C runtimes ONLY.
  32.  * The version intended for public use will not have this message.
  33.  */
  34. #error ERROR: Use of C runtime library internal header file.
  35. #endif  /* _CRTBLD */
  36.  
  37. /* Define _CRTIMP */
  38.  
  39. #ifndef _CRTIMP
  40. #ifdef CRTDLL
  41. #define _CRTIMP __declspec(dllexport)
  42. #else  /* CRTDLL */
  43. #ifdef _DLL
  44. #define _CRTIMP __declspec(dllimport)
  45. #else  /* _DLL */
  46. #define _CRTIMP
  47. #endif  /* _DLL */
  48. #endif  /* CRTDLL */
  49. #endif  /* _CRTIMP */
  50.  
  51. class type_info {
  52. public:
  53.     _CRTIMP virtual ~type_info();
  54.     _CRTIMP int operator==(const type_info& rhs) const;
  55.     _CRTIMP int operator!=(const type_info& rhs) const;
  56.     _CRTIMP int before(const type_info& rhs) const;
  57.     _CRTIMP const char* name() const;
  58.     _CRTIMP const char* raw_name() const;
  59. private:
  60.     void *_m_data;
  61.     char _m_d_name[1];
  62.     type_info(const type_info& rhs);
  63.     type_info& operator=(const type_info& rhs);
  64. };
  65.  
  66. #ifndef _TICORE
  67.  
  68. // This include must occur below the definition of class type_info
  69. #include <stdexcpt.h>
  70.  
  71. class _CRTIMP bad_cast : public exception {
  72. public:
  73.     bad_cast(const __exString& what_arg) : exception (what_arg) {}
  74. };
  75.  
  76. class _CRTIMP bad_typeid : public exception {
  77. public:
  78.     bad_typeid(const char * what_arg) : exception (what_arg) {}
  79. };
  80.  
  81. class _CRTIMP __non_rtti_object : public bad_typeid {
  82. public:
  83.     __non_rtti_object(const char * what_arg) : bad_typeid(what_arg) {}
  84. };
  85.  
  86. #ifdef __RTTI_OLDNAMES
  87. // Some synonyms for folks using older standard
  88. typedef type_info Type_info;
  89. typedef bad_cast Bad_cast;
  90. typedef bad_typeid Bad_typeid;
  91. #endif  /* __RTTI_OLDNAMES */
  92.  
  93. #endif  /* _TICORE */
  94.  
  95. #endif  /* _INC_TYPEINFO */
  96.