libfreehand_utils.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * This file is part of the libfreehand project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef __LIBFREEHAND_UTILS_H__
11 #define __LIBFREEHAND_UTILS_H__
12 
13 #include <vector>
14 #include <stdio.h>
15 #include <string>
16 #include <math.h>
17 #include <librevenge/librevenge.h>
18 
19 #ifndef M_PI
20 #define M_PI 3.14159265358979323846
21 #endif
22 
23 #define FH_EPSILON 1E-6
24 #define FH_ALMOST_ZERO(m) (fabs(m) <= FH_EPSILON)
25 
26 #ifdef _MSC_VER
27 
28 typedef unsigned char uint8_t;
29 typedef unsigned short uint16_t;
30 typedef unsigned uint32_t;
31 typedef unsigned __int64 uint64_t;
32 typedef signed char int8_t;
33 typedef short int16_t;
34 typedef int int32_t;
35 typedef __int64 int64_t;
36 
37 #else
38 
39 #ifdef HAVE_CONFIG_H
40 
41 #include <config.h>
42 
43 #ifdef HAVE_STDINT_H
44 #include <stdint.h>
45 #endif
46 
47 #ifdef HAVE_INTTYPES_H
48 #include <inttypes.h>
49 #endif
50 
51 #else
52 
53 // assume that the headers are there inside LibreOffice build when no HAVE_CONFIG_H is defined
54 #include <stdint.h>
55 #include <inttypes.h>
56 
57 #endif
58 
59 #endif
60 
61 // debug message includes source file and line number
62 //#define VERBOSE_DEBUG 1
63 
64 // do nothing with debug messages in a release compile
65 #ifdef DEBUG
66 #ifdef VERBOSE_DEBUG
67 #define FH_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M
68 #define FH_DEBUG(M) M
69 #else
70 #define FH_DEBUG_MSG(M) printf M
71 #define FH_DEBUG(M) M
72 #endif
73 #else
74 #define FH_DEBUG_MSG(M)
75 #define FH_DEBUG(M)
76 #endif
77 
78 namespace libfreehand
79 {
80 
81 uint8_t readU8(librevenge::RVNGInputStream *input);
82 uint16_t readU16(librevenge::RVNGInputStream *input);
83 uint32_t readU32(librevenge::RVNGInputStream *input);
84 int8_t readS8(librevenge::RVNGInputStream *input);
85 int16_t readS16(librevenge::RVNGInputStream *input);
86 int32_t readS32(librevenge::RVNGInputStream *input);
87 
88 void writeU16(librevenge::RVNGBinaryData &buffer, const int value);
89 void writeU32(librevenge::RVNGBinaryData &buffer, const int value);
90 
91 void _appendUTF16(librevenge::RVNGString &text, std::vector<unsigned short> &characters);
92 void _appendMacRoman(librevenge::RVNGString &text, unsigned char character);
93 
95 {
96 };
97 
99 {
100 };
101 
102 } // namespace libfreehand
103 
104 #endif // __LIBFREEHAND_UTILS_H__
105 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
uint16_t readU16(librevenge::RVNGInputStream *input)
Definition: libfreehand_utils.cpp:73
uint32_t readU32(librevenge::RVNGInputStream *input)
Definition: libfreehand_utils.cpp:95
uint8_t readU8(librevenge::RVNGInputStream *input)
Definition: libfreehand_utils.cpp:52
int32_t readS32(librevenge::RVNGInputStream *input)
Definition: libfreehand_utils.cpp:113
void _appendMacRoman(librevenge::RVNGString &text, unsigned char character)
Definition: libfreehand_utils.cpp:154
Definition: libfreehand_utils.h:94
void writeU16(librevenge::RVNGBinaryData &buffer, const int value)
Definition: libfreehand_utils.cpp:140
void writeU32(librevenge::RVNGBinaryData &buffer, const int value)
Definition: libfreehand_utils.cpp:146
void _appendUTF16(librevenge::RVNGString &text, std::vector< unsigned short > &characters)
Definition: libfreehand_utils.cpp:118
int16_t readS16(librevenge::RVNGInputStream *input)
Definition: libfreehand_utils.cpp:90
int8_t readS8(librevenge::RVNGInputStream *input)
Definition: libfreehand_utils.cpp:68
Definition: libfreehand_utils.h:98

Generated for libfreehand by doxygen 1.8.5