GDAL: cpl_error.h Source File

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

# cpl_error.h

Go to the documentation of this file.

    00001 /**********************************************************************
    00002  * $Id: cpl_error.h 14047 2008-03-20 18:46:12Z rouault $
    00003  *
    00004  * Name:     cpl_error.h
    00005  * Project:  CPL - Common Portability Library
    00006  * Purpose:  CPL Error handling
    00007  * Author:   Daniel Morissette, danmo@videotron.ca
    00008  *
    00009  **********************************************************************
    00010  * Copyright (c) 1998, Daniel Morissette
    00011  *
    00012  * Permission is hereby granted, free of charge, to any person obtaining a
    00013  * copy of this software and associated documentation files (the "Software"),
    00014  * to deal in the Software without restriction, including without limitation
    00015  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
    00016  * and/or sell copies of the Software, and to permit persons to whom the
    00017  * Software is furnished to do so, subject to the following conditions:
    00018  *
    00019  * The above copyright notice and this permission notice shall be included
    00020  * in all copies or substantial portions of the Software.
    00021  *
    00022  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00023  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00024  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
    00025  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00026  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    00027  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    00028  * DEALINGS IN THE SOFTWARE.
    00029  ****************************************************************************/
    00030
    00031 #ifndef CPL_ERROR_H_INCLUDED
    00032 #define CPL_ERROR_H_INCLUDED
    00033
    00034 #include "cpl_port.h"
    00035
    00036 /*=====================================================================
    00037                    Error handling functions (cpl_error.c)
    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 CPL_STDCALL CPLErrorReset( void );
    00060 int CPL_DLL CPL_STDCALL CPLGetLastErrorNo( void );
    00061 CPLErr CPL_DLL CPL_STDCALL CPLGetLastErrorType( void );
    00062 const char CPL_DLL * CPL_STDCALL CPLGetLastErrorMsg( void );
    00063
    00064 typedef void (CPL_STDCALL *CPLErrorHandler)(CPLErr, int, const char*);
    00065
    00066 void CPL_DLL CPL_STDCALL CPLLoggingErrorHandler( CPLErr, int, const char * );
    00067 void CPL_DLL CPL_STDCALL CPLDefaultErrorHandler( CPLErr, int, const char * );
    00068 void CPL_DLL CPL_STDCALL CPLQuietErrorHandler( CPLErr, int, const char * );
    00069
    00070 CPLErrorHandler CPL_DLL CPL_STDCALL CPLSetErrorHandler(CPLErrorHandler);
    00071 void CPL_DLL CPL_STDCALL CPLPushErrorHandler( CPLErrorHandler );
    00072 void CPL_DLL CPL_STDCALL CPLPopErrorHandler(void);
    00073
    00074 void CPL_DLL CPL_STDCALL CPLDebug( const char *, const char *, ... )  CPL_PRINT_FUNC_FORMAT (2, 3);
    00075 void CPL_DLL CPL_STDCALL _CPLAssert( const char *, const char *, int );
    00076
    00077 #ifdef DEBUG
    00078 #  define CPLAssert(expr)  ((expr) ? (void)(0) : _CPLAssert(#expr,__FILE__,__LINE__))
    00079 #else
    00080 #  define CPLAssert(expr)
    00081 #endif
    00082
    00083 CPL_C_END
    00084
    00085 /*
    00086  * Helper macros used for input parameters validation.
    00087  */
    00088 #ifdef DEBUG
    00089 #  define VALIDATE_POINTER_ERR CE_Fatal
    00090 #else
    00091 #  define VALIDATE_POINTER_ERR CE_Failure
    00092 #endif
    00093
    00094 #define VALIDATE_POINTER0(ptr, func) \
    00095    do { if( NULL == ptr ) \
    00096       { \
    00097         CPLErr const ret = VALIDATE_POINTER_ERR; \
    00098         CPLError( ret, CPLE_ObjectNull, \
    00099            "Pointer \'%s\' is NULL in \'%s\'.\n", #ptr, (func)); \
    00100          return; }} while(0)
    00101
    00102 #define VALIDATE_POINTER1(ptr, func, rc) \
    00103    do { if( NULL == ptr ) \
    00104       { \
    00105           CPLErr const ret = VALIDATE_POINTER_ERR; \
    00106           CPLError( ret, CPLE_ObjectNull, \
    00107            "Pointer \'%s\' is NULL in \'%s\'.\n", #ptr, (func)); \
    00108         return (rc); }} while(0)
    00109
    00110 /* ==================================================================== */
    00111 /*      Well known error codes.                                         */
    00112 /* ==================================================================== */
    00113
    00114 #define CPLE_None                       0
    00115 #define CPLE_AppDefined                 1
    00116 #define CPLE_OutOfMemory                2
    00117 #define CPLE_FileIO                     3
    00118 #define CPLE_OpenFailed                 4
    00119 #define CPLE_IllegalArg                 5
    00120 #define CPLE_NotSupported               6
    00121 #define CPLE_AssertionFailed            7
    00122 #define CPLE_NoWriteAccess              8
    00123 #define CPLE_UserInterrupt              9
    00124 #define CPLE_ObjectNull                 10
    00125
    00126 /* 100 - 299 reserved for GDAL */
    00127
    00128 #endif /* CPL_ERROR_H_INCLUDED */

Generated for GDAL by 1.5.9.