Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef CASCATCH_ERRORHANDLER_HXX
00027 #define CASCATCH_ERRORHANDLER_HXX
00028
00029 #include "CASCatch_Failure.hxx"
00030
00031 #include <stdlib.h>
00032 #include <setjmp.h>
00033
00034
00035 extern int K_SETJMP_CASCatch ;
00036
00042 class CASCatch_ErrorHandler
00043 {
00044 friend class CASCatch_Failure;
00045
00046 public:
00047
00048 Standard_EXPORT CASCatch_ErrorHandler();
00049 Standard_EXPORT ~CASCatch_ErrorHandler();
00050 Standard_EXPORT Standard_Boolean Catches (const Handle(Standard_Type)&);
00051
00052 private:
00053 Standard_EXPORT static void Abort();
00054 Standard_EXPORT static void Error(const Handle(CASCatch_Failure)&);
00055 Standard_EXPORT static Handle(CASCatch_Failure) LastCaughtError();
00056
00057
00058 private:
00059 CASCatch_ErrorHandler* Previous;
00060 Handle(CASCatch_Failure) CaughtError;
00061
00062 public:
00063 jmp_buf Label;
00064
00065 };
00066
00067 #undef CASCatch_TRY
00068 #define CASCatch_TRY try
00069
00070 #undef CASCatch_CATCH
00071 #define CASCatch_CATCH catch
00072
00073
00074 #ifdef NO_CXX_EXCEPTION
00075 # undef CASCatch_TRY
00076 # undef CASCatch_CATCH
00077
00078 # if defined(DO_ABORT)
00079
00080 # define DoesNotAbort_CASCatch(aHandler) !(K_SETJMP_CASCatch = setjmp(aHandler.Label))
00081
00082 # define CASCatch_TRY CASCatch_ErrorHandler _Function; \
00083 K_SETJMP_CASCatch = 1 ; \
00084 if(DoesNotAbort_CASCatch(_Function))
00085
00086 # else // ! DO_ABORT
00087 # define DoesNotAbort_CASCatch(aHandler) !setjmp(aHandler.Label)
00088
00089 # define CASCatch_TRY CASCatch_ErrorHandler _Function; \
00090 if(DoesNotAbort_CASCatch(_Function))
00091 # endif // DO_ABORT
00092
00093
00094 # define CASCatch_CATCH(Error) else if(_Function.Catches(STANDARD_TYPE(Error)))
00095 #endif // NO_CXX_EXCEPTION
00096
00097 #endif // CASCATCH_ERRORHANDLER_HXX