home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / stlport / exception < prev    next >
Text File  |  2001-07-05  |  6KB  |  194 lines

  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.  */
  18.  
  19. // This header exists solely for portability.  Normally it just includes
  20. // the native header <exception>.
  21.  
  22. // The header <exception> contains low-level functions that interact
  23. // with a compiler's exception-handling mechanism.  It is assumed to
  24. // be supplied with the compiler, rather than with the library, because
  25. // it is inherently tied very closely to the compiler itself.
  26.  
  27. // On platforms where <exception> does not exist, this header defines
  28. // an exception base class.  This is *not* a substitute for everything
  29. // in <exception>, but it suffices to support a bare minimum of STL
  30. // functionality.
  31.  
  32. # if !defined (_STLP_OUTERMOST_HEADER_ID)
  33. #  define _STLP_OUTERMOST_HEADER_ID 0x423
  34. #  include <stl/_prolog.h>
  35. # elif (_STLP_OUTERMOST_HEADER_ID == 0x423) && ! defined (_STLP_DONT_POP_0x423)
  36. #  define _STLP_DONT_POP_0x423
  37. # endif
  38.  
  39. # if   ! defined (_STLP_NO_EXCEPTION_HEADER)
  40.  
  41. #  if defined ( _UNCAUGHT_EXCEPTION )
  42. #   undef _STLP_INCOMPLETE_EXCEPTION_HEADER
  43. #  endif
  44.  
  45. # if defined(_STLP_BROKEN_EXCEPTION_CLASS)
  46. #  define exception     _STLP_NULLIFIED_BROKEN_EXCEPTION_CLASS
  47. #  define bad_exception _STLP_NULLIFIED_BROKEN_BAD_EXCEPTION_CLASS
  48. #  if defined (_STLP_NO_NEW_NEW_HEADER)
  49. #   include _STLP_NATIVE_CPP_RUNTIME_HEADER(Exception.h)
  50. #  else
  51. #   include _STLP_NATIVE_CPP_RUNTIME_HEADER(Exception)
  52. #  endif
  53. #  undef exception
  54. #  undef bad_exception
  55. # else
  56.  
  57. # if defined (_STLP_NO_NEW_NEW_HEADER)
  58. #  include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception.h)
  59. # else
  60. #   include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception)
  61. # endif
  62.  
  63. # endif
  64.  
  65. #    if defined (_STLP_MSVC) || defined (__ICL)
  66. // dwa 02/04/00 - here I'm assuming that __ICL uses the same library headers as vc6.
  67. // the header <yvals.h> which ships with vc6 and is included by its native <exception>
  68. // actually turns on warnings, so we have to turn them back off.
  69. #      include <config/_msvc_warnings_off.h>
  70. #    endif
  71.  
  72. # if !defined(_STLP_EXCEPTION_BASE) && !defined(_STLP_BROKEN_EXCEPTION_CLASS)
  73. #  define _STLP_EXCEPTION_BASE _STLP_VENDOR_EXCEPT_STD::exception
  74. # endif
  75.  
  76. #  ifdef _STLP_USE_OWN_NAMESPACE
  77.  
  78. _STLP_BEGIN_NAMESPACE
  79.  
  80. #if !defined(_STLP_BROKEN_EXCEPTION_CLASS)
  81. using _STLP_VENDOR_EXCEPT_STD::exception;
  82. using _STLP_VENDOR_EXCEPT_STD::bad_exception;
  83. #endif
  84.  
  85. # if ! defined (_STLP_NO_USING_FOR_GLOBAL_FUNCTIONS)
  86.  
  87. // fbp : many platforms present strange mix of
  88. // those in various namespaces
  89. #  if !defined(_STLP_VENDOR_UNEXPECTED_STD)
  90. #   define _STLP_VENDOR_UNEXPECTED_STD _STLP_VENDOR_EXCEPT_STD
  91. #  endif
  92.  
  93. // weird errors
  94. # if (! defined (__BORLANDC__)) || (defined (__STD_EXCEPTION) && defined (__RWSTD_EXCEPTION_SEEN) && defined ( _STLP_DONT_POP_0x423))
  95. using _STLP_VENDOR_UNEXPECTED_STD::unexpected;
  96. using _STLP_VENDOR_UNEXPECTED_STD::unexpected_handler;
  97. using _STLP_VENDOR_UNEXPECTED_STD::set_unexpected;
  98. using _STLP_VENDOR_UNEXPECTED_STD::terminate;
  99. using _STLP_VENDOR_UNEXPECTED_STD::terminate_handler;
  100. using _STLP_VENDOR_UNEXPECTED_STD::set_terminate;
  101. # endif
  102.  
  103. # if !defined (_STLP_INCOMPLETE_EXCEPTION_HEADER) 
  104. using _STLP_VENDOR_UNEXPECTED_STD::uncaught_exception;
  105. # endif
  106.  
  107. #  endif
  108.  
  109. _STLP_END_NAMESPACE
  110.  
  111. #  endif /* _STLP_OWN_NAMESPACE */
  112.  
  113. #else /* _STLP_NO_EXCEPTION_HEADER */
  114.  
  115. // fbp : absence of <exception> usually means that those
  116. // functions are not going to be called by compiler.
  117. // Still, define them for the user.
  118. typedef void (*unexpected_handler)();
  119. unexpected_handler set_unexpected(unexpected_handler f) _STLP_NOTHROW_INHERENTLY;
  120. void unexpected();
  121.  
  122. typedef void (*terminate_handler)();
  123. terminate_handler set_terminate(terminate_handler f) _STLP_NOTHROW_INHERENTLY;
  124. void terminate();
  125.  
  126. bool uncaught_exception(); // not implemented under mpw as of Jan/1999
  127.  
  128. #endif  /* _STLP_NO_EXCEPTION_HEADER */    
  129.  
  130. # if   defined (_STLP_NO_EXCEPTION_HEADER) || defined(_STLP_BROKEN_EXCEPTION_CLASS)
  131. # ifndef _STLP_EXCEPTION_H
  132. #  define _STLP_EXCEPTION_H
  133.  
  134. _STLP_BEGIN_NAMESPACE
  135.  
  136. // section 18.6.1
  137.     class exception 
  138.     {
  139.     public:
  140. # ifdef _STLP_OWN_IOSTREAMS
  141.             exception() _STLP_NOTHROW;
  142.             virtual ~exception() _STLP_NOTHROW;
  143.         virtual const char* what() const _STLP_NOTHROW;
  144. # else
  145.             exception() _STLP_NOTHROW {}
  146.         virtual ~exception() _STLP_NOTHROW {}
  147.         virtual const char* what() const _STLP_NOTHROW {return "class exception";}
  148. # endif
  149.     };
  150.     
  151.     
  152.  
  153. // section 18.6.2.1
  154.     class bad_exception : public exception 
  155.     {
  156.     public:
  157. # ifdef _STLP_OWN_IOSTREAMS
  158.       bad_exception() _STLP_NOTHROW;
  159.       ~bad_exception() _STLP_NOTHROW;
  160.       const char* what() const _STLP_NOTHROW;
  161. # else
  162.       bad_exception() _STLP_NOTHROW {}
  163.       ~bad_exception() _STLP_NOTHROW {}
  164.       const char* what() const _STLP_NOTHROW {return "class bad_exception";}
  165. # endif
  166.     };
  167.  
  168. # define _STLP_EXCEPTION_BASE exception
  169.  
  170. _STLP_END_NAMESPACE
  171.  
  172. #endif /* _STLP_NO_EXCEPTION_HEADER */
  173.  
  174. _STLP_BEGIN_NAMESPACE
  175. // forward declaration
  176. class __Named_exception;
  177. _STLP_END_NAMESPACE
  178. #endif /* _STLP_EXCEPTION_H */
  179.  
  180. # if (_STLP_OUTERMOST_HEADER_ID == 0x423)
  181. #  if ! defined (_STLP_DONT_POP_0x423)
  182. #   include <stl/_epilog.h>
  183. #   undef  _STLP_OUTERMOST_HEADER_ID
  184. #   endif
  185. #   undef  _STLP_DONT_POP_0x423
  186. # endif
  187.  
  188. // Local Variables:
  189. // mode:C++
  190. // End:
  191.  
  192.  
  193.  
  194.