tesseract  3.05.02
host.h
Go to the documentation of this file.
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 __HOST__
19 #define __HOST__
20 
21 #include "platform.h"
22 /* _WIN32 */
23 #ifdef _WIN32
24 #include <windows.h>
25 #include <winbase.h> // winbase.h contains windows.h
26 #endif
27 
28 #include <cstdint> // int32_t, ...
29 
30 // definitions of portable data types (numbers and characters)
31 typedef SIGNED char inT8;
32 typedef unsigned char uinT8;
33 typedef short inT16;
34 typedef unsigned short uinT16;
35 typedef int inT32;
36 typedef unsigned int uinT32;
37 #if (_MSC_VER >= 1200) //%%% vkr for VC 6.0
38 typedef INT64 inT64;
39 typedef UINT64 uinT64;
40 #else
41 typedef long long int inT64;
42 typedef unsigned long long int uinT64;
43 #endif //%%% vkr for VC 6.0
44 typedef float FLOAT32;
45 typedef double FLOAT64;
46 typedef unsigned char BOOL8;
47 
48 #define INT32FORMAT "%d"
49 #define INT64FORMAT "%lld"
50 
51 #define MAX_INT8 0x7f
52 #define MAX_INT16 0x7fff
53 #define MAX_INT32 0x7fffffff
54 #define MAX_UINT8 0xff
55 #define MAX_UINT16 0xffff
56 #define MAX_UINT32 0xffffffff
57 #define MAX_FLOAT32 ((float)3.40282347e+38)
58 
59 #define MIN_INT8 0x80
60 #define MIN_INT16 0x8000
61 #define MIN_INT32 static_cast<int>(0x80000000)
62 #define MIN_UINT8 0x00
63 #define MIN_UINT16 0x0000
64 #define MIN_UINT32 0x00000000
65 #define MIN_FLOAT32 ((float)1.17549435e-38)
66 
67 // Defines
68 #ifndef TRUE
69 #define TRUE 1
70 #endif
71 
72 #ifndef FALSE
73 #define FALSE 0
74 #endif
75 
76 // Return true if x is within tolerance of y
77 template<class T> bool NearlyEqual(T x, T y, T tolerance) {
78  T diff = x - y;
79  return diff <= tolerance && -diff <= tolerance;
80 }
81 
82 #endif
bool NearlyEqual(T x, T y, T tolerance)
Definition: host.h:77
short inT16
Definition: host.h:33
unsigned char uinT8
Definition: host.h:32
unsigned char BOOL8
Definition: host.h:46
unsigned short uinT16
Definition: host.h:34
unsigned long long int uinT64
Definition: host.h:42
SIGNED char inT8
Definition: host.h:31
float FLOAT32
Definition: host.h:44
double FLOAT64
Definition: host.h:45
long long int inT64
Definition: host.h:41
int inT32
Definition: host.h:35
#define SIGNED
Definition: platform.h:53
unsigned int uinT32
Definition: host.h:36