epoc32/include/stdapis/stlportv5/exception
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
     1 /*
     1 /*
     2  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
     2  * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(- *   * ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the License "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     3  *
     8  *
     4  * Copyright (c) 1996,1997
     9  * Initial Contributors:
     5  * Silicon Graphics Computer Systems, Inc.
    10  * Nokia Corporation - initial contribution.
     6  *
    11  *
     7  * Copyright (c) 1999 
    12  * Contributors:
     8  * Boris Fomitchev
       
     9  *
    13  *
    10  * This material is provided "as is", with absolutely no warranty expressed
    14  * Description:
    11  * or implied. Any use is at your own risk.
    15  * Name       : exception
    12  *
    16  * Part of    : standard c++ library.
    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.
       
    18  *
    17  *
    19  */
    18  */
    20 
    19 
    21 // This header exists solely for portability.  Normally it just includes
       
    22 // the native header <exception>.
       
    23 
       
    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.
       
    28 
       
    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
       
    32 // functionality.
       
    33 
       
    34 
       
    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
       
    40 # endif
       
    41 
       
    42 #ifndef _STLP_EXCEPTION
       
    43 #define _STLP_EXCEPTION
       
    44 
       
    45 # if   ! defined (_STLP_NO_EXCEPTION_HEADER)
       
    46 
       
    47 #  if defined ( _UNCAUGHT_EXCEPTION )
       
    48 #   undef _STLP_INCOMPLETE_EXCEPTION_HEADER
       
    49 #  endif
       
    50 
       
    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)
       
    56 #  else
       
    57 #   include _STLP_NATIVE_CPP_RUNTIME_HEADER(Exception)
       
    58 #  endif
       
    59 #  undef exception
       
    60 #  undef bad_exception
       
    61 # else
       
    62 
       
    63 #ifndef _STLP_NO_NEW_NEW_HEADER
       
    64 #define _STLP_NO_NEW_NEW_HEADER
       
    65 #endif
       
    66 
       
    67 # if defined (_STLP_NO_NEW_NEW_HEADER)
       
    68 #  include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception.h)
       
    69 # else
       
    70 #   include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception)
       
    71 # endif
       
    72 
       
    73 # endif
       
    74 
       
    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>
       
    80 #    endif
       
    81 
       
    82 
       
    83 #  ifdef _STLP_USE_OWN_NAMESPACE
       
    84 
       
    85 _STLP_BEGIN_NAMESPACE
       
    86 
       
    87 #if !defined(_STLP_BROKEN_EXCEPTION_CLASS)
       
    88 using _STLP_VENDOR_EXCEPT_STD::exception;
       
    89 using _STLP_VENDOR_EXCEPT_STD::bad_exception;
       
    90 #endif
       
    91 
       
    92 # if ! defined (_STLP_NO_USING_FOR_GLOBAL_FUNCTIONS)
       
    93 
       
    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
       
    98 #  endif
       
    99 
       
   100 // weird errors
       
   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;
       
   108 # endif
       
   109 
       
   110 # if !defined (_STLP_INCOMPLETE_EXCEPTION_HEADER) 
       
   111 using _STLP_VENDOR_UNEXPECTED_STD::uncaught_exception;
       
   112 # endif
       
   113 
       
   114 #  endif
       
   115 
       
   116 _STLP_END_NAMESPACE
       
   117 
       
   118 #  endif /* _STLP_OWN_NAMESPACE */
       
   119 
       
   120 #else /* _STLP_NO_EXCEPTION_HEADER */
       
   121 
       
   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.
       
   125 #ifdef __SYMBIAN32__
       
   126 _STLP_BEGIN_NAMESPACE
       
   127 #endif //__SYMBIAN32__
       
   128 typedef void (*unexpected_handler)();
       
   129 unexpected_handler set_unexpected(unexpected_handler f) _STLP_NOTHROW_INHERENTLY;
       
   130 void unexpected();
       
   131 
       
   132 typedef void (*terminate_handler)();
       
   133 terminate_handler set_terminate(terminate_handler f) _STLP_NOTHROW_INHERENTLY;
       
   134 void terminate();
       
   135 
       
   136 bool uncaught_exception(); // not implemented under mpw as of Jan/1999
       
   137 
       
   138 #ifdef __SYMBIAN32__
       
   139 _STLP_END_NAMESPACE
       
   140 #endif //__SYMBIAN32__
       
   141 
       
   142 #endif  /* _STLP_NO_EXCEPTION_HEADER */	
       
   143 
       
   144 # if   defined (_STLP_NO_EXCEPTION_HEADER) || defined(_STLP_BROKEN_EXCEPTION_CLASS)
       
   145 # ifndef _STLP_EXCEPTION_H
       
   146 #  define _STLP_EXCEPTION_H
       
   147 
       
   148 _STLP_BEGIN_NAMESPACE
       
   149 
       
   150 // section 18.6.1
       
   151 #ifdef __SYMBIAN32__
       
   152 class exception
       
   153 #else
       
   154 class _STLP_CLASS_DECLSPEC exception 
       
   155 #endif
       
   156 	{
       
   157 	public:
       
   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;
       
   162 # else
       
   163         exception() _STLP_NOTHROW {}
       
   164 		virtual ~exception() _STLP_NOTHROW {}
       
   165 		virtual const char* what() const _STLP_NOTHROW {return "class exception";}
       
   166 # endif
       
   167 	};
       
   168 	
       
   169 	
       
   170 
       
   171 // section 18.6.2.1
       
   172 #ifdef __SYMBIAN32__
       
   173 class bad_exception : public exception 
       
   174 #else
       
   175 class _STLP_CLASS_DECLSPEC bad_exception : public exception 
       
   176 #endif
       
   177 	{
       
   178 	public:
       
   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;
       
   183 # else
       
   184 	  bad_exception() _STLP_NOTHROW {}
       
   185 	  ~bad_exception() _STLP_NOTHROW {}
       
   186 	  const char* what() const _STLP_NOTHROW {return "class bad_exception";}
       
   187 # endif
       
   188 	};
       
   189 
       
   190 #ifdef __SYMBIAN32__
       
   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();
       
   195 
       
   196 typedef void (*terminate_handler)();
       
   197 _STLP_DECLSPEC terminate_handler set_terminate(terminate_handler f) _STLP_NOTHROW_INHERENTLY;
       
   198 _STLP_DECLSPEC void terminate();
       
   199 
       
   200 _STLP_DECLSPEC bool uncaught_exception(); // not implemented under mpw as of Jan/1999
       
   201 
       
   202 #endif
       
   203 _STLP_END_NAMESPACE
       
   204 
       
   205 #endif /* _STLP_NO_EXCEPTION_HEADER */
       
   206 
       
   207 _STLP_BEGIN_NAMESPACE
       
   208 // forward declaration
       
   209 class __Named_exception;
       
   210 _STLP_END_NAMESPACE
       
   211 #endif /* _STLP_EXCEPTION_H */
       
   212 
       
   213 #endif //_STLP_EXCEPTION
       
   214 
       
   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
       
   219 #   endif
       
   220 #   undef  _STLP_DONT_POP_0x423
       
   221 # endif
       
   222 
       
   223 
       
   224 // Local Variables:
       
   225 // mode:C++
       
   226 // End:
       
   227 
    20 
   228 
    21 
   229 
    22 
       
    23 #ifndef _SYMCPP_EXCEPTION_H_
       
    24 #define _SYMCPP_EXCEPTION_H_
       
    25 
       
    26 #ifdef __EABI__
       
    27 /* EABI specific definitions */
       
    28 #include <e32def.h>
       
    29 namespace std
       
    30 {
       
    31     class exception
       
    32         {
       
    33     public:
       
    34         IMPORT_C exception() __NO_THROW;
       
    35         IMPORT_C exception(const exception&) __NO_THROW;
       
    36         IMPORT_C exception& operator=(const exception&) __NO_THROW;
       
    37         IMPORT_C virtual ~exception() __NO_THROW;
       
    38         IMPORT_C virtual const char* what() const __NO_THROW;
       
    39         };
       
    40 
       
    41     class bad_exception : public exception
       
    42         {
       
    43     public:
       
    44         IMPORT_C bad_exception() __NO_THROW;
       
    45         IMPORT_C bad_exception(const bad_exception&)  __NO_THROW;
       
    46         IMPORT_C bad_exception& operator=(const bad_exception&)  __NO_THROW;
       
    47         IMPORT_C virtual ~bad_exception()  __NO_THROW;
       
    48         IMPORT_C virtual const char* what() const  __NO_THROW;
       
    49         };
       
    50 
       
    51     typedef void (*unexpected_handler)();
       
    52 
       
    53     IMPORT_C unexpected_handler set_unexpected(unexpected_handler)  __NO_THROW;
       
    54     IMPORT_C void unexpected();
       
    55 
       
    56     typedef void (*terminate_handler)();
       
    57 
       
    58     IMPORT_C terminate_handler set_terminate(terminate_handler)  __NO_THROW;
       
    59     IMPORT_C void terminate();
       
    60 
       
    61     IMPORT_C extern bool uncaught_exception()  __NO_THROW;
       
    62 } 
       
    63 
       
    64 
       
    65 
       
    66 #  else
       
    67 
       
    68 /* Declarations common to all other platforms (Non-EABI) here.
       
    69  * WINSCW specific definitions are in exception_winscw.h
       
    70  */
       
    71 #    include <e32def.h>
       
    72 
       
    73 namespace std {
       
    74 
       
    75   class exception {
       
    76   public:
       
    77 	  exception() __NO_THROW;
       
    78 	  exception(const exception&) __NO_THROW;
       
    79       exception& operator=(const exception&) __NO_THROW;
       
    80       virtual ~exception() __NO_THROW;
       
    81       virtual const char* what() const __NO_THROW;
       
    82   };
       
    83 
       
    84   class bad_exception : public exception {
       
    85   public:
       
    86       bad_exception() __NO_THROW; 
       
    87       bad_exception(const bad_exception&) __NO_THROW; 
       
    88       bad_exception& operator=(const bad_exception&) __NO_THROW;
       
    89       virtual ~bad_exception() __NO_THROW;
       
    90       virtual const char* what() const __NO_THROW;
       
    91   };
       
    92 
       
    93   typedef void (*terminate_handler)();
       
    94   extern terminate_handler set_terminate(terminate_handler) __NO_THROW;
       
    95 
       
    96   typedef void (*unexpected_handler)();
       
    97   extern unexpected_handler set_unexpected(unexpected_handler) __NO_THROW;
       
    98 
       
    99   void terminate();
       
   100   void unexpected();
       
   101   bool uncaught_exception() __NO_THROW;
       
   102 
       
   103 }
       
   104 
       
   105 #    ifdef __WINSCW__
       
   106 /*
       
   107  * C++ Exception specific stuff required from the CW runtime.
       
   108  * Certain functions are implemented inline in CW headers.
       
   109  * We're providing the same in exception_winscw.h
       
   110  */
       
   111 #      include <stdapis/stlportv5/exception_winscw.h>
       
   112 #    endif //__WINSCW__
       
   113 
       
   114 #endif // __EABI__
       
   115 #endif //_SYMCPP_EXCEPTION_
       
   116