libcdr_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 libcdr 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 __LIBCDR_UTILS_H__
11 #define __LIBCDR_UTILS_H__
12 
13 #include <stdio.h>
14 #include <string>
15 #include <math.h>
16 #include <vector>
17 #include <libwpd-stream/libwpd-stream.h>
18 #include <libwpd/libwpd.h>
19 
20 #ifndef M_PI
21 #define M_PI 3.14159265358979323846
22 #endif
23 
24 #define CDR_EPSILON 1E-6
25 #define CDR_ALMOST_ZERO(m) (fabs(m) <= CDR_EPSILON)
26 
27 #ifdef _MSC_VER
28 
29 typedef unsigned char uint8_t;
30 typedef unsigned short uint16_t;
31 typedef short int16_t;
32 typedef unsigned uint32_t;
33 typedef int int32_t;
34 typedef unsigned __int64 uint64_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 CDR_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M
68 #define CDR_DEBUG(M) M
69 #else
70 #define CDR_DEBUG_MSG(M) printf M
71 #define CDR_DEBUG(M) M
72 #endif
73 #else
74 #define CDR_DEBUG_MSG(M)
75 #define CDR_DEBUG(M)
76 #endif
77 
78 namespace libcdr
79 {
80 
81 uint8_t readU8(WPXInputStream *input, bool bigEndian=false);
82 uint16_t readU16(WPXInputStream *input, bool bigEndian=false);
83 uint32_t readU32(WPXInputStream *input, bool bigEndian=false);
84 uint64_t readU64(WPXInputStream *input, bool bigEndian=false);
85 int32_t readS32(WPXInputStream *input, bool bigEndian=false);
86 int16_t readS16(WPXInputStream *input, bool bigEndian=false);
87 
88 double readDouble(WPXInputStream *input, bool bigEndian=false);
89 
90 double readFixedPoint(WPXInputStream *input, bool bigEndian=false);
91 
92 int cdr_round(double d);
93 
94 void writeU8(WPXBinaryData &buffer, const int value);
95 void writeU16(WPXBinaryData &buffer, const int value);
96 void writeU32(WPXBinaryData &buffer, const int value);
97 void appendCharacters(WPXString &text, std::vector<unsigned char> characters, unsigned short charset);
98 void appendCharacters(WPXString &text, std::vector<unsigned char> characters);
99 
100 #ifdef DEBUG
101 const char *toFourCC(unsigned value, bool bigEndian=false);
102 #endif
103 
105 {
106 };
107 
109 {
110 };
111 
113 {
114 };
115 
117 {
118 };
119 
120 } // namespace libcdr
121 
122 #endif // __LIBCDR_UTILS_H__
123 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */

Generated for libcdr by doxygen 1.8.3.1