1 /* Converted to D from C:/devLibs/gdal21/include/cpl_error.h by htod */
2 module gdal.cpl.error;
3 /**********************************************************************
4  * $Id: cpl_error.h 33842 2016-04-01 08:37:32Z rouault $
5  *
6  * Name:     cpl_error.h
7  * Project:  CPL - Common Portability Library
8  * Purpose:  CPL Error handling
9  * Author:   Daniel Morissette, danmo@videotron.ca
10  *
11  **********************************************************************
12  * Copyright (c) 1998, Daniel Morissette
13  *
14  * Permission is hereby granted, free of charge, to any person obtaining a
15  * copy of this software and associated documentation files (the "Software"),
16  * to deal in the Software without restriction, including without limitation
17  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18  * and/or sell copies of the Software, and to permit persons to whom the
19  * Software is furnished to do so, subject to the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be included
22  * in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
27  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30  * DEALINGS IN THE SOFTWARE.
31  ****************************************************************************/
32 
33 import core.stdc.stdarg : va_list;
34 
35 import gdal.cpl.port;
36 
37 /*=====================================================================
38                    Error handling functions (cpl_error.c)
39  =====================================================================*/
40 
41 /**
42  * \file cpl_error.h
43  *
44  * CPL error handling services.
45  */
46 enum
47 {
48     CE_None    = 0,
49     CE_Debug   = 1,
50     CE_Warning = 2,
51     CE_Failure = 3,
52     CE_Fatal   = 4,
53 }
54 extern (C):
55 alias int CPLErr;
56 
57 /* ==================================================================== */
58 /*      Well known error codes.                                         */
59 /* ==================================================================== */
60 
61 alias int CPLErrorNum;
62 enum CPLE_None                     =  0;
63 enum CPLE_AppDefined               =  1;
64 enum CPLE_OutOfMemory              =  2;
65 enum CPLE_FileIO                   =  3;
66 enum CPLE_OpenFailed               =  4;
67 enum CPLE_IllegalArg               =  5;
68 enum CPLE_NotSupported             =  6;
69 enum CPLE_AssertionFailed          =  7;
70 enum CPLE_NoWriteAccess            =  8;
71 enum CPLE_UserInterrupt            =  9;
72 enum CPLE_ObjectNull               = 10;
73 
74 /*
75  * Filesystem-specific errors
76  */
77 enum CPLE_HttpResponse             = 11;
78 enum CPLE_AWSBucketNotFound        = 12;
79 enum CPLE_AWSObjectNotFound        = 13;
80 enum CPLE_AWSAccessDenied          = 14;
81 enum CPLE_AWSInvalidCredentials    = 15;
82 enum CPLE_AWSSignatureDoesNotMatch = 16;
83 /* 100 - 299 reserved for GDAL */
84 
85 
86 void  CPLError(CPLErr eErrClass, CPLErrorNum err_no, const(char) *fmt,...) nothrow @nogc;
87 void  CPLErrorV(CPLErr , CPLErrorNum , const(char) *, va_list ) nothrow @nogc;
88 void  CPLEmergencyError(const(char) *) nothrow @nogc;
89 
90 extern (System):
91 void  CPLErrorReset() nothrow @nogc;
92 CPLErrorNum  CPLGetLastErrorNo() nothrow @nogc;
93 CPLErr  CPLGetLastErrorType() nothrow @nogc;
94 const(char) * CPLGetLastErrorMsg() nothrow @nogc;
95 void * CPLGetErrorHandlerUserData() nothrow @nogc;
96 
97 extern (C):
98 void  CPLErrorSetState(CPLErr eErrClass, CPLErrorNum err_no, const(char) *pszMsg) nothrow @nogc;
99 void  CPLCleanupErrorMutex() nothrow @nogc;
100 
101 alias void  function(CPLErr , CPLErrorNum , const(char) *)CPLErrorHandler;
102 
103 extern (System):
104 void  CPLLoggingErrorHandler(CPLErr , CPLErrorNum , const(char) *) nothrow @nogc;
105 void  CPLDefaultErrorHandler(CPLErr , CPLErrorNum , const(char) *) nothrow @nogc;
106 void  CPLQuietErrorHandler(CPLErr , CPLErrorNum , const(char) *) nothrow @nogc;
107 
108 extern (C):
109 void  CPLTurnFailureIntoWarning(int bOn) nothrow @nogc;
110 
111 extern (System):
112 CPLErrorHandler  CPLSetErrorHandler(CPLErrorHandler ) nothrow @nogc;
113 CPLErrorHandler  CPLSetErrorHandlerEx(CPLErrorHandler , void *) nothrow @nogc;
114 void  CPLPushErrorHandler(CPLErrorHandler ) nothrow @nogc;
115 void  CPLPushErrorHandlerEx(CPLErrorHandler , void *) nothrow @nogc;
116 void  CPLSetCurrentErrorHandlerCatchDebug(int bCatchDebug) nothrow @nogc;
117 void  CPLPopErrorHandler() nothrow @nogc;
118 void  _CPLAssert(const(char) *, const(char) *, int ) nothrow @nogc;
119 
120 /*
121  * Helper macros used for input parameters validation.
122  */
123 alias CE_Failure VALIDATE_POINTER_ERR;
124 
125 
126 /* Not sure what to do with these, if anything at all is needed. */
127 //C     #define VALIDATE_POINTER0(ptr, func)    do { if( NULL == ptr )       {         CPLErr const ret = VALIDATE_POINTER_ERR;         CPLError( ret, CPLE_ObjectNull,            "Pointer \'%s\' is NULL in \'%s\'.\n", #ptr, (func));          return; }} while(0)
128 
129 //C     #define VALIDATE_POINTER1(ptr, func, rc)    do { if( NULL == ptr )       {           CPLErr const ret = VALIDATE_POINTER_ERR;           CPLError( ret, CPLE_ObjectNull,            "Pointer \'%s\' is NULL in \'%s\'.\n", #ptr, (func));         return (rc); }} while(0)