_exception.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * Copyright (c) 1996,1997
  3. * Silicon Graphics Computer Systems, Inc.
  4. *
  5. * Copyright (c) 1999
  6. * Boris Fomitchev
  7. *
  8. * This material is provided "as is", with absolutely no warranty expressed
  9. * or implied. Any use is at your own risk.
  10. *
  11. * Permission to use or copy this software for any purpose is hereby granted
  12. * without fee, provided the above notices are retained on all copies.
  13. * Permission to modify the code and to distribute modified code is granted,
  14. * provided the above notices are retained, and a notice that the code was
  15. * modified is included with the above copyright notice.
  16. */
  17. // The header <exception> contains low-level functions that interact
  18. // with a compiler's exception-handling mechanism. It is assumed to
  19. // be supplied with the compiler, rather than with the library, because
  20. // it is inherently tied very closely to the compiler itself.
  21. // On platforms where <exception> does not exist, this header defines
  22. // an exception base class. This is *not* a substitute for everything
  23. // in <exception>, but it suffices to support a bare minimum of STL
  24. // functionality.
  25. #ifndef _STLP_INTERNAL_EXCEPTION
  26. #define _STLP_INTERNAL_EXCEPTION
  27. #if !defined (_STLP_NO_EXCEPTION_HEADER)
  28. # if defined ( _UNCAUGHT_EXCEPTION )
  29. # undef _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT
  30. # endif
  31. # if defined (_STLP_BROKEN_EXCEPTION_CLASS)
  32. # define exception _STLP_NULLIFIED_BROKEN_EXCEPTION_CLASS
  33. # define bad_exception _STLP_NULLIFIED_BROKEN_BAD_EXCEPTION_CLASS
  34. # if defined (_STLP_NO_NEW_NEW_HEADER)
  35. # include _STLP_NATIVE_CPP_RUNTIME_HEADER(Exception.h)
  36. # else
  37. # include _STLP_NATIVE_CPP_RUNTIME_HEADER(Exception)
  38. # endif
  39. # undef exception
  40. # undef bad_exception
  41. # else
  42. # if defined (_STLP_NO_NEW_NEW_HEADER)
  43. # if defined (_STLP_HAS_INCLUDE_NEXT)
  44. # include_next <exception.h>
  45. # else
  46. # include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception.h)
  47. # endif
  48. # else
  49. # if defined (_STLP_HAS_INCLUDE_NEXT)
  50. # include_next <exception>
  51. # else
  52. # include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception)
  53. # endif
  54. # endif
  55. # endif
  56. # if defined (_STLP_HAS_SPECIFIC_PROLOG_EPILOG) && defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB < 1300)
  57. // dwa 02/04/00
  58. // The header <yvals.h> which ships with vc6 and is included by its native <exception>
  59. // actually turns on warnings, so we have to turn them back off.
  60. # include <stl/config/_warnings_off.h>
  61. # endif
  62. # if defined (_STLP_USE_OWN_NAMESPACE)
  63. _STLP_BEGIN_NAMESPACE
  64. # if !defined (_STLP_BROKEN_EXCEPTION_CLASS)
  65. # if !defined (_STLP_USING_PLATFORM_SDK_COMPILER) || !defined (_WIN64)
  66. using _STLP_VENDOR_EXCEPT_STD::exception;
  67. # else
  68. using ::exception;
  69. # endif
  70. using _STLP_VENDOR_EXCEPT_STD::bad_alloc;
  71. using _STLP_VENDOR_EXCEPT_STD::bad_exception;
  72. # endif
  73. # if !defined (_STLP_NO_USING_FOR_GLOBAL_FUNCTIONS)
  74. // fbp : many platforms present strange mix of
  75. // those in various namespaces
  76. # if !defined (_STLP_VENDOR_UNEXPECTED_STD)
  77. # define _STLP_VENDOR_UNEXPECTED_STD _STLP_VENDOR_EXCEPT_STD
  78. # else
  79. /* The following definitions are for backward compatibility as _STLP_VENDOR_TERMINATE_STD
  80. * and _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD has been introduce after _STLP_VENDOR_UNEXPECTED_STD
  81. * and _STLP_VENDOR_UNEXPECTED_STD was the macro used in their place before that introduction.
  82. */
  83. # if !defined (_STLP_VENDOR_TERMINATE_STD)
  84. # define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_UNEXPECTED_STD
  85. # endif
  86. # if !defined (_STLP_VENDOR_UNCAUGHT_EXCEPTION_STD)
  87. # define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_UNEXPECTED_STD
  88. # endif
  89. # endif
  90. # if !defined (_STLP_VENDOR_TERMINATE_STD)
  91. # define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_EXCEPT_STD
  92. # endif
  93. # if !defined (_STLP_VENDOR_UNCAUGHT_EXCEPTION_STD)
  94. # define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_EXCEPT_STD
  95. # endif
  96. # if !defined (_STLP_VENDOR_TERMINATE_STD)
  97. # define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_EXCEPT_STD
  98. # endif
  99. # if !defined (_STLP_VENDOR_UNCAUGHT_EXCEPTION_STD)
  100. # define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_EXCEPT_STD
  101. # endif
  102. // weird errors
  103. # if !defined (_STLP_NO_UNEXPECTED_EXCEPT_SUPPORT)
  104. # if defined (__ICL) && (__ICL >= 900) && (_STLP_MSVC_LIB < 1300)
  105. //See config/_intel.h for reason about this workaround
  106. using std::unexpected;
  107. # else
  108. using _STLP_VENDOR_UNEXPECTED_STD::unexpected;
  109. # endif
  110. using _STLP_VENDOR_UNEXPECTED_STD::unexpected_handler;
  111. using _STLP_VENDOR_UNEXPECTED_STD::set_unexpected;
  112. # endif
  113. using _STLP_VENDOR_TERMINATE_STD::terminate;
  114. using _STLP_VENDOR_TERMINATE_STD::terminate_handler;
  115. using _STLP_VENDOR_TERMINATE_STD::set_terminate;
  116. # if !defined (_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT)
  117. using _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD::uncaught_exception;
  118. # endif
  119. # endif /* !_STLP_NO_USING_FOR_GLOBAL_FUNCTIONS */
  120. _STLP_END_NAMESPACE
  121. # endif /* _STLP_OWN_NAMESPACE */
  122. #else /* _STLP_NO_EXCEPTION_HEADER */
  123. /* fbp : absence of <exception> usually means that those
  124. * functions are not going to be called by compiler.
  125. * Still, define them for the user.
  126. * dums: Policy modification, if the function do not behave like the Standard
  127. * defined it we do not grant it in the STLport namespace. We will have
  128. * compile time error rather than runtime error.
  129. */
  130. #if 0
  131. /*
  132. typedef void (*unexpected_handler)();
  133. unexpected_handler set_unexpected(unexpected_handler f) _STLP_NOTHROW_INHERENTLY;
  134. void unexpected();
  135. typedef void (*terminate_handler)();
  136. terminate_handler set_terminate(terminate_handler f) _STLP_NOTHROW_INHERENTLY;
  137. void terminate();
  138. bool uncaught_exception(); // not implemented under mpw as of Jan/1999
  139. */
  140. #endif
  141. #endif /* _STLP_NO_EXCEPTION_HEADER */
  142. #if defined (_STLP_NO_EXCEPTION_HEADER) || defined (_STLP_BROKEN_EXCEPTION_CLASS)
  143. _STLP_BEGIN_NAMESPACE
  144. // section 18.6.1
  145. class _STLP_CLASS_DECLSPEC exception {
  146. public:
  147. # ifndef _STLP_USE_NO_IOSTREAMS
  148. exception() _STLP_NOTHROW;
  149. virtual ~exception() _STLP_NOTHROW;
  150. virtual const char* what() const _STLP_NOTHROW;
  151. # else
  152. exception() _STLP_NOTHROW {}
  153. virtual ~exception() _STLP_NOTHROW {}
  154. virtual const char* what() const _STLP_NOTHROW {return "class exception";}
  155. # endif
  156. };
  157. // section 18.6.2.1
  158. class _STLP_CLASS_DECLSPEC bad_exception : public exception {
  159. public:
  160. # ifndef _STLP_USE_NO_IOSTREAMS
  161. bad_exception() _STLP_NOTHROW;
  162. ~bad_exception() _STLP_NOTHROW;
  163. const char* what() const _STLP_NOTHROW;
  164. # else
  165. bad_exception() _STLP_NOTHROW {}
  166. ~bad_exception() _STLP_NOTHROW {}
  167. const char* what() const _STLP_NOTHROW {return "class bad_exception";}
  168. # endif
  169. };
  170. // forward declaration
  171. class __Named_exception;
  172. _STLP_END_NAMESPACE
  173. #endif
  174. #endif /* _STLP_INTERNAL_EXCEPTION */