Leaked source code of windows server 2003
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.

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