Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/tesseract/src/ccutil/errcode.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /********************************************************************** | |
| 2 * File: errcode.h (Formerly error.h) | |
| 3 * Description: Header file for generic error handler class | |
| 4 * Author: Ray Smith | |
| 5 * | |
| 6 * (C) Copyright 1990, Hewlett-Packard Ltd. | |
| 7 ** Licensed under the Apache License, Version 2.0 (the "License"); | |
| 8 ** you may not use this file except in compliance with the License. | |
| 9 ** You may obtain a copy of the License at | |
| 10 ** http://www.apache.org/licenses/LICENSE-2.0 | |
| 11 ** Unless required by applicable law or agreed to in writing, software | |
| 12 ** distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 ** See the License for the specific language governing permissions and | |
| 15 ** limitations under the License. | |
| 16 * | |
| 17 **********************************************************************/ | |
| 18 | |
| 19 #ifndef ERRCODE_H | |
| 20 #define ERRCODE_H | |
| 21 | |
| 22 #include <tesseract/export.h> // for TESS_API | |
| 23 | |
| 24 namespace tesseract { | |
| 25 | |
| 26 /*Control parameters for error()*/ | |
| 27 enum TessErrorLogCode { | |
| 28 DBG = -1, /*log without alert */ | |
| 29 TESSLOG = 0, /*alert user */ | |
| 30 TESSEXIT = 1, /*exit after error */ | |
| 31 ABORT = 2 /*abort after error */ | |
| 32 }; | |
| 33 | |
| 34 #if !defined(__GNUC__) && !defined(__attribute__) | |
| 35 # define __attribute__(attr) // compiler without support for __attribute__ | |
| 36 #endif | |
| 37 | |
| 38 class TESS_API ERRCODE { // error handler class | |
| 39 const char *message; // error message | |
| 40 public: | |
| 41 void error( // error print function | |
| 42 const char *caller, // function location | |
| 43 TessErrorLogCode action, // action to take | |
| 44 const char *format, ... // fprintf format | |
| 45 ) const __attribute__((format(printf, 4, 5))); | |
| 46 void error(const char *caller, TessErrorLogCode action) const; | |
| 47 constexpr ERRCODE(const char *string) : message(string) {} // initialize with string | |
| 48 }; | |
| 49 | |
| 50 constexpr ERRCODE ASSERT_FAILED("Assert failed"); | |
| 51 | |
| 52 #define DO_NOTHING static_cast<void>(0) | |
| 53 | |
| 54 #define ASSERT_HOST(x) \ | |
| 55 (x) ? DO_NOTHING : ASSERT_FAILED.error(#x, ABORT, "in file %s, line %d", __FILE__, __LINE__) | |
| 56 | |
| 57 #define ASSERT_HOST_MSG(x, ...) \ | |
| 58 if (!(x)) { \ | |
| 59 tprintf(__VA_ARGS__); \ | |
| 60 ASSERT_FAILED.error(#x, ABORT, "in file %s, line %d", __FILE__, __LINE__); \ | |
| 61 } | |
| 62 | |
| 63 } // namespace tesseract | |
| 64 | |
| 65 #endif |
