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