Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/tesseract/src/training/unicharset/icuerrorcode.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: icuerrorcode.h | |
| 3 * Description: Wrapper class for UErrorCode, with conversion operators for | |
| 4 * direct use in ICU C and C++ APIs. | |
| 5 * Author: Fredrik Roubert | |
| 6 * Created: Thu July 4 2013 | |
| 7 * | |
| 8 * Features: | |
| 9 * - The constructor initializes the internal UErrorCode to U_ZERO_ERROR, | |
| 10 * removing one common source of errors. | |
| 11 * - Same use in C APIs taking a UErrorCode* (pointer) and C++ taking | |
| 12 * UErrorCode& (reference), via conversion operators. | |
| 13 * - Automatic checking for success when it goes out of scope. On failure, | |
| 14 * the destructor will log an error message and exit. | |
| 15 * | |
| 16 * Most of ICU will handle errors gracefully and provide sensible fallbacks. | |
| 17 * Using IcuErrorCode, it is therefore possible to write very compact code | |
| 18 * that does sensible things on failure and provides logging for debugging. | |
| 19 * | |
| 20 * Example: | |
| 21 * IcuErrorCode icuerrorcode; | |
| 22 * return collator.compareUTF8(a, b, icuerrorcode) == UCOL_EQUAL; | |
| 23 * | |
| 24 * (C) Copyright 2013, Google Inc. | |
| 25 * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 26 * you may not use this file except in compliance with the License. | |
| 27 * You may obtain a copy of the License at | |
| 28 * http://www.apache.org/licenses/LICENSE-2.0 | |
| 29 * Unless required by applicable law or agreed to in writing, software | |
| 30 * distributed under the License is distributed on an "AS IS" BASIS, | |
| 31 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 32 * See the License for the specific language governing permissions and | |
| 33 * limitations under the License. | |
| 34 * | |
| 35 **********************************************************************/ | |
| 36 #ifndef TESSERACT_CCUTIL_ICUERRORCODE_H_ | |
| 37 #define TESSERACT_CCUTIL_ICUERRORCODE_H_ | |
| 38 | |
| 39 #include <cstdlib> // for exit | |
| 40 #include "tprintf.h" | |
| 41 #include "unicode/errorcode.h" // From libicu | |
| 42 | |
| 43 namespace tesseract { | |
| 44 | |
| 45 class IcuErrorCode : public icu::ErrorCode { | |
| 46 public: | |
| 47 IcuErrorCode() = default; | |
| 48 ~IcuErrorCode() override; | |
| 49 | |
| 50 protected: | |
| 51 void handleFailure() const override { | |
| 52 tprintf("ICU ERROR: %s\n", errorName()); | |
| 53 exit(errorCode); | |
| 54 } | |
| 55 | |
| 56 private: | |
| 57 // Disallow implicit copying of object. | |
| 58 IcuErrorCode(const IcuErrorCode &) = delete; | |
| 59 void operator=(const IcuErrorCode &) = delete; | |
| 60 }; | |
| 61 | |
| 62 } // namespace tesseract | |
| 63 #endif // TESSERACT_CCUTIL_ICUERRORCODE_H_ |
