home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / typeinfo.h < prev    next >
C/C++ Source or Header  |  1998-06-16  |  2KB  |  83 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
  17.  
  18. #ifndef __cplusplus
  19. #error This header requires a C++ compiler ...
  20. #endif
  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
  28.  
  29.  
  30. /* Define _CRTIMP */
  31.  
  32. #ifndef _CRTIMP
  33. #ifdef  _DLL
  34. #define _CRTIMP __declspec(dllimport)
  35. #else   /* ndef _DLL */
  36. #define _CRTIMP
  37. #endif  /* _DLL */
  38. #endif  /* _CRTIMP */
  39.  
  40. class type_info {
  41. public:
  42.     _CRTIMP virtual ~type_info();
  43.     _CRTIMP int operator==(const type_info& rhs) const;
  44.     _CRTIMP int operator!=(const type_info& rhs) const;
  45.     _CRTIMP int before(const type_info& rhs) const;
  46.     _CRTIMP const char* name() const;
  47.     _CRTIMP const char* raw_name() const;
  48. private:
  49.     void *_m_data;
  50.     char _m_d_name[1];
  51.     type_info(const type_info& rhs);
  52.     type_info& operator=(const type_info& rhs);
  53. };
  54.  
  55.  
  56. // This include must occur below the definition of class type_info
  57. #include <stdexcpt.h>
  58.  
  59. class _CRTIMP bad_cast : public exception {
  60. public:
  61.     bad_cast(const __exString& what_arg) : exception (what_arg) {}
  62. };
  63.  
  64. class _CRTIMP bad_typeid : public exception {
  65. public:
  66.     bad_typeid(const char * what_arg) : exception (what_arg) {}
  67. };
  68.  
  69. class _CRTIMP __non_rtti_object : public bad_typeid {
  70. public:
  71.     __non_rtti_object(const char * what_arg) : bad_typeid(what_arg) {}
  72. };
  73.  
  74. #ifdef  __RTTI_OLDNAMES
  75. // Some synonyms for folks using older standard
  76. typedef type_info Type_info;
  77. typedef bad_cast Bad_cast;
  78. typedef bad_typeid Bad_typeid;
  79. #endif  // __RTTI_OLDNAMES
  80.  
  81.  
  82. #endif  // _INC_TYPEINFO
  83.