libetonyek_utils.h Source File documentation

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

- File List
- File Members

libetonyek_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 libetonyek 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 LIBETONYEK_UTILS_H_INCLUDED
11 #define LIBETONYEK_UTILS_H_INCLUDED
12
13 #include <cmath>
14 #include <stdio.h>
15 #include <string>
16
17 #include <boost/shared_ptr.hpp>
18
19 #include <librevenge/librevenge.h>
20 #include <librevenge-stream/librevenge-stream.h>
21
22 #ifdef _MSC_VER
23
24 typedef unsigned char uint8_t;
25 typedef unsigned short uint16_t;
26 typedef unsigned uint32_t;
27 typedef unsigned __int64 uint64_t;
28 typedef signed char int8_t;
29 typedef short int16_t;
30 typedef int int32_t;
31 typedef __int64 int64_t;
32
33 #else
34
35 #ifdef HAVE_CONFIG_H
36
37 #include <config.h>
38
39 #ifdef HAVE_STDINT_H
40 #include <stdint.h>
41 #endif
42
43 #ifdef HAVE_INTTYPES_H
44 #include <inttypes.h>
45 #endif
46
47 #else
48
49 // assume that the headers are there inside LibreOffice build when no HAVE_CONFIG_H is defined
50 #include <stdint.h>
51 #include <inttypes.h>
52
53 #endif
54
55 #endif
56
57 #define KEY_EPSILON 1e-9
58 #define KEY_ALMOST_ZERO(x) (std::fabs(x) < KEY_EPSILON)
59
60 #define KEY_NUM_ELEMENTS(array) (sizeof(array) / sizeof((array)[0]))
61
62 // debug message includes source file and line number
63 //#define VERBOSE_DEBUG 1
64
65 #undef DEBUG
66 // do nothing with debug messages in a release compile
67 #ifdef DEBUG
68 #ifdef VERBOSE_DEBUG
69 #define KEY_DEBUG_MSG(M) printf("%15s:%5d: ", FILE, LINE); printf M
70 #define KEY_DEBUG(M) M
71 #else
72 #define KEY_DEBUG_MSG(M) printf M
73 #define KEY_DEBUG(M) M
74 #endif
75 #else
76 #define KEY_DEBUG_MSG(M)
77 #define KEY_DEBUG(M)
78 #endif
79
80 namespace libetonyek
81 {
82
83 struct KEYDummyDeleter
84 {
85 void operator()(void *) {}
86 };
87
88 typedef boost::shared_ptr<librevenge::RVNGInputStream> RVNGInputStreamPtr_t;
89
90 uint8_t readU8(const RVNGInputStreamPtr_t &input, bool = false);
91 uint16_t readU16(const RVNGInputStreamPtr_t &input, bool bigEndian=false);
92 uint32_t readU32(const RVNGInputStreamPtr_t &input, bool bigEndian=false);
93 uint64_t readU64(const RVNGInputStreamPtr_t &input, bool bigEndian=false);
94
101 bool approxEqual(double x, double y, double eps = KEY_EPSILON);
102
108 double pt2in(double d);
109
110 class EndOfStreamException
111 {
112 };
113
114 class GenericException
115 {
116 };
117
118 } // namespace libetonyek
119
120 #endif // LIBETONYEK_UTILS_H_INCLUDED
121
122 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libetonyek::approxEqual
bool approxEqual(const KEYPath &left, const KEYPath &right, const double eps)
Definition: KEYPath.cpp:385
libetonyek
Definition: EtonyekDocument.cpp:40
y
double y
Definition: KEYShape.cpp:100
libetonyek::GenericException
Definition: libetonyek_utils.h:114
libetonyek::EndOfStreamException
Definition: libetonyek_utils.h:110
libetonyek::pt2in
double pt2in(const double d)
Convert a length from points to inches.
Definition: libetonyek_utils.cpp:91
libetonyek::KEYDummyDeleter
Definition: libetonyek_utils.h:83
libetonyek::readU32
uint32_t readU32(const RVNGInputStreamPtr_t &input, bool bigEndian)
Definition: libetonyek_utils.cpp:54
x
double x
Definition: KEYShape.cpp:99
libetonyek::readU8
uint8_t readU8(const RVNGInputStreamPtr_t &input, bool)
Definition: libetonyek_utils.cpp:26
KEY_EPSILON
#define KEY_EPSILON
Definition: libetonyek_utils.h:57
libetonyek::readU64
uint64_t readU64(const RVNGInputStreamPtr_t &input, bool bigEndian)
Definition: libetonyek_utils.cpp:70
libetonyek::KEYDummyDeleter::operator()
void operator()(void *)
Definition: libetonyek_utils.h:85
libetonyek::KEY2Token::d
Definition: KEY2Token.h:164
libetonyek::RVNGInputStreamPtr_t
boost::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr_t
Definition: libetonyek_utils.h:88
libetonyek::readU16
uint16_t readU16(const RVNGInputStreamPtr_t &input, bool bigEndian)
Definition: libetonyek_utils.cpp:38
input
RVNGInputStreamPtr_t input
Definition: EtonyekDocument.cpp:59