Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
3.7 KiB

  1. // exception standard header for Microsoft
  2. #pragma once
  3. #ifndef _EXCEPTION_
  4. #define _EXCEPTION_
  5. #include <xstddef>
  6. #pragma pack(push,8)
  7. #pragma warning(push,3)
  8. _STD_BEGIN
  9. #define _USE_EX using::exception;
  10. #if _HAS_EXCEPTIONS
  11. _STD_END
  12. #include <eh.h>
  13. #if !defined(_WIN32)
  14. #error ERROR: Only Win32 targets supported!
  15. #endif
  16. #ifndef _CRTIMP
  17. #ifdef _DLL
  18. #define _CRTIMP __declspec(dllimport)
  19. #else /* ndef _DLL */
  20. #define _CRTIMP
  21. #endif /* _DLL */
  22. #endif /* _CRTIMP */
  23. typedef const char *__exString;
  24. class _CRTIMP exception
  25. { // base of all library exceptions
  26. public:
  27. exception();
  28. exception(const char *const&);
  29. exception(const exception&);
  30. exception& operator=(const exception&);
  31. virtual ~exception();
  32. virtual const char *what() const;
  33. private:
  34. const char *_m_what;
  35. int _m_doFree;
  36. };
  37. _STD_BEGIN
  38. _USE_EX
  39. typedef void (*_Prhand)(const exception&);
  40. extern _CRTIMP2 _Prhand _Raise_handler;
  41. _CRTIMP2 bool __cdecl uncaught_exception();
  42. using ::unexpected_handler; using ::set_unexpected; using ::unexpected;
  43. using ::terminate_handler; using ::set_terminate; using ::terminate;
  44. #else /* _HAS_EXCEPTIONS */
  45. // CLASS exception
  46. class exception;
  47. typedef void (*_Prhand)(const exception&);
  48. extern _CRTIMP2 _Prhand _Raise_handler; // pointer to raise handler
  49. _CRTIMP2 void __cdecl _Throw(const exception&); // throw the exception
  50. class exception
  51. { // base of all library exceptions
  52. public:
  53. static _Prhand _Set_raise_handler(_Prhand _Pnew)
  54. { // register a handler for _Raise calls
  55. const _Prhand _Pold = _Raise_handler;
  56. _Raise_handler = _Pnew;
  57. return (_Pold);
  58. }
  59. explicit exception(const char *_Message = _MESG("unknown"))
  60. _THROW0()
  61. : _Ptr(_Message)
  62. { // construct from message string
  63. }
  64. exception(const exception& _Right) _THROW0()
  65. : _Ptr(_Right._Ptr)
  66. { // construct by copying _Right
  67. }
  68. exception& operator=(const exception& _Right) _THROW0()
  69. { // assign _Right
  70. _Ptr = _Right._Ptr;
  71. return (*this);
  72. }
  73. virtual ~exception()
  74. { // destroy the object
  75. }
  76. virtual const char *what() const _THROW0()
  77. { // return pointer to message string
  78. return (_Ptr);
  79. }
  80. void _Raise() const
  81. { // raise the exception
  82. if (_Raise_handler != 0)
  83. (*_Raise_handler)(*this); // call raise handler if present
  84. _Doraise(); // call the protected virtual
  85. _RAISE(*this); // raise this exception
  86. }
  87. protected:
  88. virtual void _Doraise() const
  89. { // perform class-specific exception handling
  90. }
  91. const char *_Ptr; // the message pointer
  92. };
  93. // TYPES
  94. typedef void (__cdecl *terminate_handler)();
  95. typedef void (__cdecl *unexpected_handler)();
  96. // DUMMY FUNCTION DECLARATIONS
  97. inline terminate_handler __cdecl set_terminate(terminate_handler)
  98. _THROW0()
  99. { // register a terminate handler
  100. return 0;
  101. }
  102. inline unexpected_handler __cdecl set_unexpected(unexpected_handler)
  103. _THROW0()
  104. { // register an unexpected handler
  105. return 0;
  106. }
  107. inline void __cdecl terminate()
  108. { // handle exception termination
  109. }
  110. inline void __cdecl unexpected()
  111. { // handle unexpected exception
  112. }
  113. _CRTIMP2 bool __cdecl uncaught_exception(); // handle uncaught exception
  114. #endif /* _HAS_EXCEPTIONS */
  115. // CLASS bad_exception
  116. class bad_exception : public exception
  117. { // base of all bad exceptions
  118. public:
  119. bad_exception(const char *_Message = _MESG("bad exception"))
  120. _THROW0()
  121. : exception(_Message)
  122. { // construct from message string
  123. }
  124. virtual ~bad_exception() _THROW0()
  125. { // destroy the object
  126. }
  127. #if !_HAS_EXCEPTIONS
  128. protected:
  129. virtual void _Doraise() const
  130. { // raise this exception
  131. _RAISE(*this);
  132. }
  133. #endif /* _HAS_EXCEPTIONS */
  134. };
  135. _STD_END
  136. #pragma warning(pop)
  137. #pragma pack(pop)
  138. #endif /* _EXCEPTION_ */
  139. /*
  140. * Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
  141. * Consult your license regarding permissions and restrictions.
  142. V3.10:0009 */