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

  1. /***
  2. *exception - Defines class exception and related functions
  3. *
  4. *    Copyright (c) 1994-1997, Microsoft Corporation. All rights reserved.
  5. *    Modified January 1996 by P.J. Plauger
  6. *
  7. *Purpose:
  8. *       Defines class exception (and derived class bad_exception)
  9. *       plus new and unexpected handler functions.
  10. *
  11. *       [Public]
  12. *
  13. ****/
  14.  
  15.  
  16. #if     _MSC_VER > 1000
  17. #pragma once
  18. #endif
  19.  
  20. #ifndef _EXCEPTION_
  21. #define _EXCEPTION_
  22. #include <xstddef>
  23. #include <eh.h>
  24.  
  25. #ifdef  _MSC_VER
  26. #pragma pack(push,8)
  27. #endif  /* _MSC_VER */
  28.  
  29.  #if !defined(_WIN32) && !defined(_MAC)
  30.   #error ERROR: Only Mac or Win32 targets supported!
  31.  #endif
  32.  
  33. #ifndef _CRTIMP
  34. #ifdef    _NTSDK
  35. /* definition compatible with NT SDK */
  36. #define _CRTIMP
  37. #else    /* ndef _NTSDK */
  38. /* current definition */
  39. #ifdef    _DLL
  40. #define _CRTIMP __declspec(dllimport)
  41. #else    /* ndef _DLL */
  42. #define _CRTIMP
  43. #endif    /* _DLL */
  44. #endif    /* _NTSDK */
  45. #endif    /* _CRTIMP */
  46.  
  47. typedef const char *__exString;
  48.  
  49. class _CRTIMP exception
  50. {
  51. public:
  52.     exception();
  53.     exception(const __exString&);
  54.     exception(const exception&);
  55.     exception& operator= (const exception&);
  56.     virtual ~exception();
  57.     virtual __exString what() const;
  58. private:
  59.     __exString _m_what;
  60.     int _m_doFree;
  61. };
  62. _STD_BEGIN
  63. using ::exception;
  64.  
  65.         // CLASS bad_exception
  66. class _CRTIMP bad_exception : public exception {
  67. public:
  68.     bad_exception(const char *_S = "bad exception") _THROW0()
  69.         : exception(_S) {}
  70.     virtual ~bad_exception() _THROW0()
  71.         {}
  72. protected:
  73.     virtual void _Doraise() const
  74.         {_RAISE(*this); }
  75.     };
  76.  
  77. _CRTIMP bool __cdecl uncaught_exception();
  78.  
  79. _STD_END
  80.  
  81. #ifdef __RTTI_OLDNAMES
  82. typedef exception xmsg;        // A synonym for folks using older standard
  83. #endif
  84.  
  85. #ifdef  _MSC_VER
  86. #pragma pack(pop)
  87. #endif  /* _MSC_VER */
  88.  
  89. #endif /* _EXCEPTION_ */
  90.  
  91. /*
  92.  * 1994-1995, Microsoft Corporation. All rights reserved.
  93.  * Modified January 1996 by P.J. Plauger
  94.  * Consult your license regarding permissions and restrictions.
  95.  */
  96.