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
24typedef unsigned char uint8_t;
25typedef unsigned short uint16_t;
26typedef unsigned uint32_t;
27typedef unsigned __int64 uint64_t;
28typedef signed char int8_t;
29typedef short int16_t;
30typedef int int32_t;
31typedef __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
80namespace libetonyek
81{
82
84{
85 void operator()(void *) {}
86};
87
88typedef boost::shared_ptr<librevenge::RVNGInputStream> RVNGInputStreamPtr_t;
89
90uint8_t readU8(const RVNGInputStreamPtr_t &input, bool = false);
91uint16_t readU16(const RVNGInputStreamPtr_t &input, bool bigEndian=false);
92uint32_t readU32(const RVNGInputStreamPtr_t &input, bool bigEndian=false);
93uint64_t readU64(const RVNGInputStreamPtr_t &input, bool bigEndian=false);
94
101bool approxEqual(double x, double y, double eps = KEY_EPSILON);
102
108double pt2in(double d);
109
111{
112};
113
115{
116};
117
118} // namespace libetonyek
119
120#endif // LIBETONYEK_UTILS_H_INCLUDED
121
122/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
RVNGInputStreamPtr_t input
Definition: EtonyekDocument.cpp:59
double y
Definition: KEYShape.cpp:100
double x
Definition: KEYShape.cpp:99
Definition: libetonyek_utils.h:111
Definition: libetonyek_utils.h:115
#define KEY_EPSILON
Definition: libetonyek_utils.h:57
@ d
Definition: KEY2Token.h:164
Definition: EtonyekDocument.cpp:41
boost::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr_t
Definition: libetonyek_utils.h:88
bool approxEqual(const KEYPath &left, const KEYPath &right, const double eps)
Definition: KEYPath.cpp:385
uint8_t readU8(const RVNGInputStreamPtr_t &input, bool)
Definition: libetonyek_utils.cpp:26
uint32_t readU32(const RVNGInputStreamPtr_t &input, bool bigEndian)
Definition: libetonyek_utils.cpp:54
uint16_t readU16(const RVNGInputStreamPtr_t &input, bool bigEndian)
Definition: libetonyek_utils.cpp:38
uint64_t readU64(const RVNGInputStreamPtr_t &input, bool bigEndian)
Definition: libetonyek_utils.cpp:70
double pt2in(const double d)
Convert a length from points to inches.
Definition: libetonyek_utils.cpp:91
Definition: libetonyek_utils.h:84
void operator()(void *)
Definition: libetonyek_utils.h:85

Generated for libetonyek by doxygen 1.9.3