2 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
4 * Copyright (c) 1996,1997
5 * Silicon Graphics Computer Systems, Inc.
10 * This material is provided "as is", with absolutely no warranty expressed
11 * or implied. Any use is at your own risk.
13 * Permission to use or copy this software for any purpose is hereby granted
14 * without fee, provided the above notices are retained on all copies.
15 * Permission to modify the code and to distribute modified code is granted,
16 * provided the above notices are retained, and a notice that the code was
17 * modified is included with the above copyright notice.
21 // This header exists solely for portability. Normally it just includes
22 // the native header <exception>.
24 // The header <exception> contains low-level functions that interact
25 // with a compiler's exception-handling mechanism. It is assumed to
26 // be supplied with the compiler, rather than with the library, because
27 // it is inherently tied very closely to the compiler itself.
29 // On platforms where <exception> does not exist, this header defines
30 // an exception base class. This is *not* a substitute for everything
31 // in <exception>, but it suffices to support a bare minimum of STL
35 # if !defined (_STLP_OUTERMOST_HEADER_ID)
36 # define _STLP_OUTERMOST_HEADER_ID 0x423
37 # include <stl/_prolog.h>
38 # elif (_STLP_OUTERMOST_HEADER_ID == 0x423) && ! defined (_STLP_DONT_POP_0x423)
39 # define _STLP_DONT_POP_0x423
42 #ifndef _STLP_EXCEPTION
43 #define _STLP_EXCEPTION
45 # if ! defined (_STLP_NO_EXCEPTION_HEADER)
47 # if defined ( _UNCAUGHT_EXCEPTION )
48 # undef _STLP_INCOMPLETE_EXCEPTION_HEADER
51 # if defined(_STLP_BROKEN_EXCEPTION_CLASS)
52 # define exception _STLP_NULLIFIED_BROKEN_EXCEPTION_CLASS
53 # define bad_exception _STLP_NULLIFIED_BROKEN_BAD_EXCEPTION_CLASS
54 # if defined (_STLP_NO_NEW_NEW_HEADER)
55 # include _STLP_NATIVE_CPP_RUNTIME_HEADER(Exception.h)
57 # include _STLP_NATIVE_CPP_RUNTIME_HEADER(Exception)
63 #ifndef _STLP_NO_NEW_NEW_HEADER
64 #define _STLP_NO_NEW_NEW_HEADER
67 # if defined (_STLP_NO_NEW_NEW_HEADER)
68 # include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception.h)
70 # include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception)
75 # if defined (_STLP_MSVC) || defined (__ICL)
76 // dwa 02/04/00 - here I'm assuming that __ICL uses the same library headers as vc6.
77 // the header <yvals.h> which ships with vc6 and is included by its native <exception>
78 // actually turns on warnings, so we have to turn them back off.
79 # include <config/_msvc_warnings_off.h>
83 # ifdef _STLP_USE_OWN_NAMESPACE
87 #if !defined(_STLP_BROKEN_EXCEPTION_CLASS)
88 using _STLP_VENDOR_EXCEPT_STD::exception;
89 using _STLP_VENDOR_EXCEPT_STD::bad_exception;
92 # if ! defined (_STLP_NO_USING_FOR_GLOBAL_FUNCTIONS)
94 // fbp : many platforms present strange mix of
95 // those in various namespaces
96 # if !defined(_STLP_VENDOR_UNEXPECTED_STD)
97 # define _STLP_VENDOR_UNEXPECTED_STD _STLP_VENDOR_EXCEPT_STD
101 # if (! defined (__BORLANDC__)) || (defined (__STD_EXCEPTION) && defined (__RWSTD_EXCEPTION_SEEN) && defined ( _STLP_DONT_POP_0x423))
102 using _STLP_VENDOR_UNEXPECTED_STD::unexpected;
103 using _STLP_VENDOR_UNEXPECTED_STD::unexpected_handler;
104 using _STLP_VENDOR_UNEXPECTED_STD::set_unexpected;
105 using _STLP_VENDOR_UNEXPECTED_STD::terminate;
106 using _STLP_VENDOR_UNEXPECTED_STD::terminate_handler;
107 using _STLP_VENDOR_UNEXPECTED_STD::set_terminate;
110 # if !defined (_STLP_INCOMPLETE_EXCEPTION_HEADER)
111 using _STLP_VENDOR_UNEXPECTED_STD::uncaught_exception;
118 # endif /* _STLP_OWN_NAMESPACE */
120 #else /* _STLP_NO_EXCEPTION_HEADER */
122 // fbp : absence of <exception> usually means that those
123 // functions are not going to be called by compiler.
124 // Still, define them for the user.
126 _STLP_BEGIN_NAMESPACE
127 #endif //__SYMBIAN32__
128 typedef void (*unexpected_handler)();
129 unexpected_handler set_unexpected(unexpected_handler f) _STLP_NOTHROW_INHERENTLY;
132 typedef void (*terminate_handler)();
133 terminate_handler set_terminate(terminate_handler f) _STLP_NOTHROW_INHERENTLY;
136 bool uncaught_exception(); // not implemented under mpw as of Jan/1999
140 #endif //__SYMBIAN32__
142 #endif /* _STLP_NO_EXCEPTION_HEADER */
144 # if defined (_STLP_NO_EXCEPTION_HEADER) || defined(_STLP_BROKEN_EXCEPTION_CLASS)
145 # ifndef _STLP_EXCEPTION_H
146 # define _STLP_EXCEPTION_H
148 _STLP_BEGIN_NAMESPACE
154 class _STLP_CLASS_DECLSPEC exception
158 # ifdef _STLP_OWN_IOSTREAMS
159 _STLP_DECLSPEC exception() _STLP_NOTHROW;
160 _STLP_DECLSPEC virtual ~exception() _STLP_NOTHROW;
161 _STLP_DECLSPEC virtual const char* what() const _STLP_NOTHROW;
163 exception() _STLP_NOTHROW {}
164 virtual ~exception() _STLP_NOTHROW {}
165 virtual const char* what() const _STLP_NOTHROW {return "class exception";}
173 class bad_exception : public exception
175 class _STLP_CLASS_DECLSPEC bad_exception : public exception
179 # ifdef _STLP_OWN_IOSTREAMS
180 _STLP_DECLSPEC bad_exception() _STLP_NOTHROW;
181 _STLP_DECLSPEC ~bad_exception() _STLP_NOTHROW;
182 _STLP_DECLSPEC const char* what() const _STLP_NOTHROW;
184 bad_exception() _STLP_NOTHROW {}
185 ~bad_exception() _STLP_NOTHROW {}
186 const char* what() const _STLP_NOTHROW {return "class bad_exception";}
191 // Give forward declaration, this should be supported by the stdard libraries from platform vendor.
192 typedef void (*unexpected_handler)();
193 _STLP_DECLSPEC unexpected_handler set_unexpected(unexpected_handler f) _STLP_NOTHROW_INHERENTLY;
194 _STLP_DECLSPEC void unexpected();
196 typedef void (*terminate_handler)();
197 _STLP_DECLSPEC terminate_handler set_terminate(terminate_handler f) _STLP_NOTHROW_INHERENTLY;
198 _STLP_DECLSPEC void terminate();
200 _STLP_DECLSPEC bool uncaught_exception(); // not implemented under mpw as of Jan/1999
205 #endif /* _STLP_NO_EXCEPTION_HEADER */
207 _STLP_BEGIN_NAMESPACE
208 // forward declaration
209 class __Named_exception;
211 #endif /* _STLP_EXCEPTION_H */
213 #endif //_STLP_EXCEPTION
215 # if (_STLP_OUTERMOST_HEADER_ID == 0x423)
216 # if ! defined (_STLP_DONT_POP_0x423)
217 # include <stl/_epilog.h>
218 # undef _STLP_OUTERMOST_HEADER_ID
220 # undef _STLP_DONT_POP_0x423