Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
serialis.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 * File: serialis.h (Formerly serialmac.h)
3 * Description: Inline routines and macros for serialisation functions
4 * Author: Phil Cheatle
5 * Created: Tue Oct 08 08:33:12 BST 1991
6 *
7 * (C) Copyright 1990, Hewlett-Packard Ltd.
8 ** Licensed under the Apache License, Version 2.0 (the "License");
9 ** you may not use this file except in compliance with the License.
10 ** You may obtain a copy of the License at
11 ** http://www.apache.org/licenses/LICENSE-2.0
12 ** Unless required by applicable law or agreed to in writing, software
13 ** distributed under the License is distributed on an "AS IS" BASIS,
14 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ** See the License for the specific language governing permissions and
16 ** limitations under the License.
17 *
18 **********************************************************************/
19
20 #include "mfcpch.h" //precompiled headers
21 #include "serialis.h"
22 #include "scanutils.h"
23
24 // Byte swap an inT64 or uinT64.
25 DLLSYM uinT64 reverse64(uinT64 num) {
26 return ((uinT64)reverse32((uinT32)(num & 0xffffffff)) << 32)
27 | reverse32((uinT32)((num >> 32) & 0xffffffff));
28 }
29
30 /**********************************************************************
31 * reverse32
32 *
33 * Byte swap an inT32 or uinT32.
34 **********************************************************************/
35
36 DLLSYM uinT32 reverse32( //switch endian
37 uinT32 num //number to fix
38 ) {
39 return (reverse16 ((uinT16) (num & 0xffff)) << 16)
40 | reverse16 ((uinT16) ((num >> 16) & 0xffff));
41 }
42
43
44 /**********************************************************************
45 * reverse16
46 *
47 * Byte swap an inT16 or uinT16.
48 **********************************************************************/
49
50 DLLSYM uinT16 reverse16( //switch endian
51 uinT16 num //number to fix
52 ) {
53 return ((num & 0xff) << 8) | ((num >> 8) & 0xff);
54 }