BioHDF version 0.3 alpha
Scalable NGS Data Storage Based on HDF5
biohdf_error.h
00001 /*****************************************************************************
00002  * Copyright by The HDF Group                                                *
00003  * All rights reserved.                                                      *
00004  *                                                                           *
00005  * This file is part of BioHDF.  The full BioHDF copyright notice, including *
00006  * terms governing use, modification, and redistribution, is contained in    *
00007  * the file COPYING.  COPYING can be found at the root of the source code    *
00008  * distribution tree.  If you do not have access to this file, you may       *
00009  * request a copy from help@hdfgroup.org.                                    *
00010  *****************************************************************************/
00011 
00019 #ifndef _BIOHDF_ERROR_H
00020 #define _BIOHDF_ERROR_H
00021 
00022 
00023 
00024 /*****************************************************************************
00025  * Error codes and definitions                                               *
00026  *****************************************************************************/
00027 
00028 
00029 
00031 typedef int biohdf_error;
00032 
00033 
00034 
00036 #define BIOHDF_NO_ERROR 0
00037 
00038 
00039 
00041 #define BIOHDF_BADNESS -1
00042 
00043 
00044 
00045 /*****************************************************************************
00046  * Error macros                                                              *
00047  *****************************************************************************/
00048 
00049 /* NOTE: Any function which uses these macros must have a FAIL target        */
00050 
00051 #if defined(_MSC_VER)
00052     #define __func__ __FUNCTION__
00053 #endif
00054 
00055 /* Check to ensure a BioHDF error (biohdf_error) is BIOHDF_NO_ERROR. */
00056 #define CHECK_BIO(val)                                                      \
00057 do                                                                          \
00058 {                                                                           \
00059     if((val) != BIOHDF_NO_ERROR){                                           \
00060         BIOHDFemit_error_message(__FILE__, __func__, (int)__LINE__);        \
00061         goto FAIL;                                                          \
00062     }                                                                       \
00063 }while(0)
00064 
00065 /* Check to ensure an HDF5 herr_t is not an error value. */
00066 #define CHECK_HERR_T(val)                                                   \
00067 do                                                                          \
00068 {                                                                           \
00069     if((val) < 0){                                                          \
00070         BIOHDFemit_error_message(__FILE__, __func__, (int)__LINE__);        \
00071         goto FAIL;                                                          \
00072     }                                                                       \
00073 }while(0)
00074 
00075 /* Check to ensure an HDF5 hid_t is not an error value. */
00076 #define CHECK_HID_T(val)                                                    \
00077 do                                                                          \
00078 {                                                                           \
00079     if((val) < 0){                                                          \
00080         BIOHDFemit_error_message(__FILE__, __func__, (int)__LINE__);        \
00081         goto FAIL;                                                          \
00082     }                                                                       \
00083 }while(0)
00084 
00085 /* Check to ensure a pointer is not NULL. */
00086 #define CHECK_PTR(val)                                                      \
00087 do                                                                          \
00088 {                                                                           \
00089     if(NULL == (val)){                                                      \
00090         BIOHDFemit_error_message(__FILE__, __func__, (int)__LINE__);        \
00091         goto FAIL;                                                          \
00092     }                                                                       \
00093 }while(0)
00094 
00095 /* Check to ensure an integer matches a test value. */
00096 #define CHECK_INT_EQ(val, test)                                             \
00097 do                                                                          \
00098 {                                                                           \
00099     if((val) != (test)){                                                    \
00100         BIOHDFemit_error_message(__FILE__, __func__, (int)__LINE__);        \
00101         goto FAIL;                                                          \
00102     }                                                                       \
00103 }while(0)
00104 
00105 /* Check to ensure an integer does not match a test value. */
00106 #define CHECK_INT_NE(val, test)                                             \
00107 do                                                                          \
00108 {                                                                           \
00109     if((val) == (test)){                                                    \
00110         BIOHDFemit_error_message(__FILE__, __func__, (int)__LINE__);        \
00111         goto FAIL;                                                          \
00112     }                                                                       \
00113 }while(0)
00114 
00115 /* Check to ensure an integer is not >= a particular value */
00116 #define CHECK_INT_LT(val, test)                                             \
00117 do                                                                          \
00118 {                                                                           \
00119     if((val) >= (test)){                                                     \
00120         BIOHDFemit_error_message(__FILE__, __func__, (int)__LINE__);        \
00121         goto FAIL;                                                          \
00122     }                                                                       \
00123 }while(0)
00124 
00125 /* Check to ensure an integer is not <= a particular value */
00126 #define CHECK_INT_GT(val, test)                                             \
00127 do                                                                          \
00128 {                                                                           \
00129     if((val) <= (test)){                                                     \
00130         BIOHDFemit_error_message(__FILE__, __func__, (int)__LINE__);        \
00131         goto FAIL;                                                          \
00132     }                                                                       \
00133 }while(0)
00134 
00135 /* Check to ensure an integer is not > a particular value */
00136 #define CHECK_INT_LE(val, test)                                             \
00137 do                                                                          \
00138 {                                                                           \
00139     if((val) > (test)){                                                     \
00140         BIOHDFemit_error_message(__FILE__, __func__, (int)__LINE__);        \
00141         goto FAIL;                                                          \
00142     }                                                                       \
00143 }while(0)
00144 
00145 /* Check to ensure an integer is not < a particular value */
00146 #define CHECK_INT_GE(val, test)                                             \
00147 do                                                                          \
00148 {                                                                           \
00149     if((val) < (test)){                                                     \
00150         BIOHDFemit_error_message(__FILE__, __func__, (int)__LINE__);        \
00151         goto FAIL;                                                          \
00152     }                                                                       \
00153 }while(0)
00154 
00155 
00156 /*****************************************************************************
00157  * Set/unset verbose STDERR output                                           *
00158  *****************************************************************************/
00159 
00160 
00161 
00169 BIOHDF_API void
00170 BIOHDFset_stderr_setting(int use_stderr);
00171 
00172 
00173 
00178 BIOHDF_API void
00179 BIOHDFget_stderr_setting(int *use_stderr);
00180 
00181 
00182 
00183 /*****************************************************************************
00184  * Emit an error message                                                     *
00185  *****************************************************************************/
00186 
00187 
00188 
00192 BIOHDF_API void
00193 BIOHDFemit_error_message(const char *filename, const char *function, int line);
00194 
00195 
00197 #endif
 All Data Structures Variables