tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
host.h
1 /******************************************************************************
2  ** Filename: host.h
3  ** Purpose: This is the system independent typedefs and defines
4  ** Author: MN, JG, MD
5  **
6  ** (c) Copyright Hewlett-Packard Company, 1988-1996.
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 #ifndef TESSERACT_CCUTIL_HOST_H_
19 #define TESSERACT_CCUTIL_HOST_H_
20 
21 #include <limits>
22 #include "platform.h"
23 /* _WIN32 */
24 #ifdef _WIN32
25 #include <windows.h>
26 #undef min
27 #undef max
28 #endif
29 
30 #include <cinttypes> // PRId32, ...
31 #include <cstdint> // int32_t, ...
32 
33 // definitions of portable data types (numbers and characters)
34 using BOOL8 = unsigned char;
35 
36 #if defined(_WIN32)
37 
38 /* MinGW defines the standard PRI... macros, but MSVS doesn't. */
39 
40 #if !defined(PRId32)
41 #define PRId32 "d"
42 #endif
43 
44 #if !defined(PRId64)
45 #define PRId64 "I64d"
46 #endif
47 
48 #endif /* _WIN32 */
49 
50 // Defines
51 #ifndef TRUE
52 #define TRUE 1
53 #endif
54 
55 #ifndef FALSE
56 #define FALSE 0
57 #endif
58 
59 // Return true if x is within tolerance of y
60 template<class T> bool NearlyEqual(T x, T y, T tolerance) {
61  T diff = x - y;
62  return diff <= tolerance && -diff <= tolerance;
63 }
64 
65 #endif // TESSERACT_CCUTIL_HOST_H_