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
00027
00028
00029
00030
00031 #ifndef CPL_ERROR_H_INCLUDED
00032 #define CPL_ERROR_H_INCLUDED
00033
00034 #include "cpl_port.h"
00035
00036
00037
00038
00039
00046 CPL_C_START
00047
00048 typedef enum
00049 {
00050 CE_None = 0,
00051 CE_Debug = 1,
00052 CE_Warning = 2,
00053 CE_Failure = 3,
00054 CE_Fatal = 4
00055 } CPLErr;
00056
00057 void CPL_DLL CPLError(CPLErr eErrClass, int err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (3, 4);
00058 void CPL_DLL CPLErrorV(CPLErr, int, const char *, va_list );
00059 void CPL_DLL CPLEmergencyError( const char * );
00060 void CPL_DLL CPL_STDCALL CPLErrorReset( void );
00061 int CPL_DLL CPL_STDCALL CPLGetLastErrorNo( void );
00062 CPLErr CPL_DLL CPL_STDCALL CPLGetLastErrorType( void );
00063 const char CPL_DLL * CPL_STDCALL CPLGetLastErrorMsg( void );
00064 void CPL_DLL * CPL_STDCALL CPLGetErrorHandlerUserData(void);
00065 void CPL_DLL CPLErrorSetState( CPLErr eErrClass, int err_no, const char* pszMsg );
00066 void CPL_DLL CPLCleanupErrorMutex( void );
00067
00068 typedef void (CPL_STDCALL *CPLErrorHandler)(CPLErr, int, const char*);
00069
00070 void CPL_DLL CPL_STDCALL CPLLoggingErrorHandler( CPLErr, int, const char * );
00071 void CPL_DLL CPL_STDCALL CPLDefaultErrorHandler( CPLErr, int, const char * );
00072 void CPL_DLL CPL_STDCALL CPLQuietErrorHandler( CPLErr, int, const char * );
00073 void CPLTurnFailureIntoWarning(int bOn );
00074
00075 CPLErrorHandler CPL_DLL CPL_STDCALL CPLSetErrorHandler(CPLErrorHandler);
00076 CPLErrorHandler CPL_DLL CPL_STDCALL CPLSetErrorHandlerEx(CPLErrorHandler, void*);
00077 void CPL_DLL CPL_STDCALL CPLPushErrorHandler( CPLErrorHandler );
00078 void CPL_DLL CPL_STDCALL CPLPushErrorHandlerEx( CPLErrorHandler, void* );
00079 void CPL_DLL CPL_STDCALL CPLPopErrorHandler(void);
00080
00081 void CPL_DLL CPL_STDCALL CPLDebug( const char *, const char *, ... ) CPL_PRINT_FUNC_FORMAT (2, 3);
00082 void CPL_DLL CPL_STDCALL _CPLAssert( const char *, const char *, int );
00083
00084 #ifdef DEBUG
00085 # define CPLAssert(expr) ((expr) ? (void)(0) : _CPLAssert(#expr,__FILE__,__LINE__))
00086 #else
00087 # define CPLAssert(expr)
00088 #endif
00089
00090 CPL_C_END
00091
00092
00093
00094
00095 #ifdef DEBUG
00096 # define VALIDATE_POINTER_ERR CE_Fatal
00097 #else
00098 # define VALIDATE_POINTER_ERR CE_Failure
00099 #endif
00100
00101 #define VALIDATE_POINTER0(ptr, func) \
00102 do { if( NULL == ptr ) \
00103 { \
00104 CPLErr const ret = VALIDATE_POINTER_ERR; \
00105 CPLError( ret, CPLE_ObjectNull, \
00106 "Pointer \'%s\' is NULL in \'%s\'.\n", #ptr, (func)); \
00107 return; }} while(0)
00108
00109 #define VALIDATE_POINTER1(ptr, func, rc) \
00110 do { if( NULL == ptr ) \
00111 { \
00112 CPLErr const ret = VALIDATE_POINTER_ERR; \
00113 CPLError( ret, CPLE_ObjectNull, \
00114 "Pointer \'%s\' is NULL in \'%s\'.\n", #ptr, (func)); \
00115 return (rc); }} while(0)
00116
00117
00118
00119
00120
00121 #define CPLE_None 0
00122 #define CPLE_AppDefined 1
00123 #define CPLE_OutOfMemory 2
00124 #define CPLE_FileIO 3
00125 #define CPLE_OpenFailed 4
00126 #define CPLE_IllegalArg 5
00127 #define CPLE_NotSupported 6
00128 #define CPLE_AssertionFailed 7
00129 #define CPLE_NoWriteAccess 8
00130 #define CPLE_UserInterrupt 9
00131 #define CPLE_ObjectNull 10
00132
00133
00134
00135 #endif