Foxit PDF SDK

fx_exception.h
Go to the documentation of this file.
1
20 #ifndef _FX_EXCEPTION_H_
21 #define _FX_EXCEPTION_H_
22
23 #define FX_SETJMP(BUF) setjmp(BUF)
24 #define FX_LONGJMP(BUF, VAL) longjmp(BUF, VAL)
25 #define FX_JMP_BUF jmp_buf
26
27 /* @brief JMP depth default 512.*/
28 #define FX_JMP_DEPTH 512
29
30 #ifndef _FX_ERROR_H_
31 #include "fx_error.h"
32 #endif
33
34 #ifndef _FX_SYSTEM_H_
35 #include "fx_system.h"
36 #endif
37
38 #ifndef _FX_BASIC_H_
39 #include "fx_basic.h"
40 #endif
41
42 class CFX_Exception;
43 class CFX_JmpStack;
44
48 class CFX_JmpStack : public CFX_Object
49 {
50 public:
51 CFX_JmpStack() : code(0)
52 {
53 FXSYS_memset(&buffer, 0 ,sizeof(buffer));
54 }
55
56 int code;
57 FX_JMP_BUF buffer;
58 };
59
60 class CFX_Exception : public CFX_Object
61 {
62 public:
63 CFX_Exception();
64 ~CFX_Exception();
65
66 FX_BOOL Catch(int value);
67 FX_BOOL CatchAll();
68 void EndTry();
69
70 protected:
71 FX_BOOL m_bCatched;
72 };
73
74 #ifdef _FX_SUPPORT_EXCEPTION_
75 //*****************************************************************************
76 //* Exception macro.
77 //*****************************************************************************
93
94 #define FX_TRY \
95 { \
96 CFX_Exception __exception; \
97 if (FX_Push_Try(FX_Thread_GetExceptionContext()->m_pErrContext) && (FX_Thread_GetExceptionContext()->m_pErrContext->stack[FX_Thread_GetExceptionContext()->m_pErrContext->top].code = \
98 FX_SETJMP(FX_Thread_GetExceptionContext()->m_pErrContext->stack[FX_Thread_GetExceptionContext()->m_pErrContext->top].buffer)) == 0)
99
100 #define FX_ALWAYS() \
101 if (1)
102
103 #define FX_CATCH(value) \
104 if (__exception.Catch(value))
105
106 #define FX_CATCHALL() \
107 if (__exception.CatchAll())
108
109 #define FX_ENDTRY \
110 __exception.EndTry(); \
111 }
112
113 //This will throw before throw error value.
114 #define FX_CONTINUETHROW FX_ContinueThrow()
115
116 //This will get current catch error value.
117 #define FX_GETCATCHCODE FX_GetCatchCode()
118
126 void FX_Throw(int iErrCode);
127 void FX_ContinueThrow();
128
133 int FX_GetCatchCode();
134
135 #endif //_FX_SUPPORT_EXCEPTION_
136
138 class CFX_ExceptionErrorContext : public CFX_Object
139 {
140 public:
141 CFX_ExceptionErrorContext();
142
143 void Initialize();
144 void Finalize();
145
146 int top;
147 CFX_JmpStack *stack;
148 };
149
150 class CFX_ExceptionContext : public CFX_Object
151 {
152 public:
153 CFX_ExceptionContext() : m_pErrContext(NULL) {}
154
155 void Initialize();
156 void Finalize();
157
158 CFX_ExceptionErrorContext* m_pErrContext;
159 };
160
161 //*****************************************************************************
162 //* The following function will be implicit called by previous macros.
163 //* Please don't direct use.
164 //*****************************************************************************
165 FX_BOOL FX_Push_Try(CFX_ExceptionErrorContext* pErrContext);
166
167 #endif //_FX_EXCEPTION_H_
168
fx_error.h
Header file for error.
CFX_ExceptionErrorContext
Definition: fx_exception.h:138
FXSYS_memset
#define FXSYS_memset
Use given character to initialize the buffer.
Definition: fx_system.h:1126
fx_system.h
Header file for system related definitions.
NULL
#define NULL
The null-pointer value.
Definition: fx_system.h:792
FX_BOOL
int FX_BOOL
Boolean variable (should be TRUE or FALSE).
Definition: fx_system.h:691
fx_basic.h
Header file for basic data class.
CFX_JmpStack
Definition: fx_exception.h:48