tesseract  3.03
/usr/local/google/home/jbreiden/tesseract-ocr-read-only/ccutil/errcode.h
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        errcode.h  (Formerly error.h)
00003  * Description: Header file for generic error handler class
00004  * Author:      Ray Smith
00005  * Created:     Tue May  1 16:23:36 BST 1990
00006  *
00007  * (C) Copyright 1990, Hewlett-Packard Ltd.
00008  ** Licensed under the Apache License, Version 2.0 (the "License");
00009  ** you may not use this file except in compliance with the License.
00010  ** You may obtain a copy of the License at
00011  ** http://www.apache.org/licenses/LICENSE-2.0
00012  ** Unless required by applicable law or agreed to in writing, software
00013  ** distributed under the License is distributed on an "AS IS" BASIS,
00014  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  ** See the License for the specific language governing permissions and
00016  ** limitations under the License.
00017  *
00018  **********************************************************************/
00019 
00020 #ifndef           ERRCODE_H
00021 #define           ERRCODE_H
00022 
00023 #include          "host.h"
00024 
00025 /*Control parameters for error()*/
00026 enum TessErrorLogCode {
00027   DBG =     -1,           /*log without alert */
00028   TESSLOG =  0,            /*alert user */
00029   TESSEXIT = 1,            /*exit after erro */
00030   ABORT =    2            /*abort after error */
00031 };
00032 
00033 /* Explicit Error Abort codes */
00034 #define NO_ABORT_CODE      0
00035 #define LIST_ABORT      1
00036 #define MEMORY_ABORT    2
00037 #define FILE_ABORT      3
00038 
00039 /* Location of code at error codes Reserve 0..2 (status codes 0..23 for UNLV)*/
00040 #define LOC_UNUSED0        0
00041 #define LOC_UNUSED1        1
00042 #define LOC_UNUSED2        2
00043 #define LOC_INIT      3
00044 #define LOC_EDGE_PROG   4
00045 #define LOC_TEXT_ORD_ROWS 5
00046 #define LOC_TEXT_ORD_WORDS  6
00047 #define LOC_PASS1     7
00048 #define LOC_PASS2     8
00049 /* Reserve up to 8..13 for adding subloc 0/3 plus subsubloc 0/1/2 */
00050 #define LOC_FUZZY_SPACE   14
00051 /* Reserve up to 14..20 for adding subloc 0/3 plus subsubloc 0/1/2 */
00052 #define LOC_MM_ADAPT    21
00053 #define LOC_DOC_BLK_REJ   22
00054 #define LOC_WRITE_RESULTS 23
00055 #define LOC_ADAPTIVE    24
00056 /* DONT DEFINE ANY LOCATION > 31 !!! */
00057 
00058 /* Sub locatation determines whether pass2 was in normal mode or fix xht mode*/
00059 #define SUBLOC_NORM     0
00060 #define SUBLOC_FIX_XHT    3
00061 
00062 /* Sub Sub locatation determines whether match_word_pass2 was in Tess
00063   matcher, NN matcher or somewhere else */
00064 
00065 #define SUBSUBLOC_OTHER   0
00066 #define SUBSUBLOC_TESS    1
00067 #define SUBSUBLOC_NN    2
00068 
00069 class TESS_API ERRCODE {           // error handler class
00070   const char *message;           // error message
00071  public:
00072   void error(                  // error print function
00073     const char *caller,        // function location
00074     TessErrorLogCode action,   // action to take
00075     const char *format, ...    // fprintf format
00076   ) const;
00077   ERRCODE(const char *string) {
00078     message = string;
00079   }                            // initialize with string
00080 };
00081 
00082 const ERRCODE ASSERT_FAILED = "Assert failed";
00083 
00084 #define ASSERT_HOST(x) if (!(x))                                        \
00085   {                                                                     \
00086     ASSERT_FAILED.error(#x, ABORT, "in file %s, line %d",               \
00087                         __FILE__, __LINE__);                            \
00088   }
00089 
00090 #ifdef _MSC_VER
00091 #define ASSERT_HOST_MSG(x, msg, ...) if (!(x))                            \
00092   {                                                                     \
00093     tprintf(msg);                                                       \
00094     ASSERT_FAILED.error(#x, ABORT, "in file %s, line %d",               \
00095                         __FILE__, __LINE__);                            \
00096   }
00097 #else
00098 #define ASSERT_HOST_MSG(x, msg...) if (!(x))                            \
00099   {                                                                     \
00100     tprintf(msg);                                                       \
00101     ASSERT_FAILED.error(#x, ABORT, "in file %s, line %d",               \
00102                         __FILE__, __LINE__);                            \
00103   }
00104 #endif
00105 
00106 void signal_exit(int signal_code);
00107 
00108 void set_global_loc_code(int loc_code);
00109 
00110 void set_global_subloc_code(int loc_code);
00111 
00112 void set_global_subsubloc_code(int loc_code);
00113 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines