libfreehand_utils.h Source File documentation

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 #ifdef HAVE_CONFIG_H
14 #include "config.h"
15 #endif
16
17 #include <vector>
18 #include <string>
19 #include <math.h>
20
21 #include <boost/cstdint.hpp>
22
23 #include <librevenge/librevenge.h>
24
25 #ifndef M_PI
26 #define M_PI 3.14159265358979323846
27 #endif
28
29 #define FH_EPSILON 1E-6
30 #define FH_ALMOST_ZERO(m) (fabs(m) <= FH_EPSILON)
31
32 // do nothing with debug messages in a release compile
33 #ifdef DEBUG
34
35 #if defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
36 #define FH_ATTRIBUTE_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg)))
37 #else
38 #define FH_ATTRIBUTE_PRINTF(fmt, arg)
39 #endif
40
41 namespace libfreehand
42 {
43 void debugPrint(const char *format, ...) FH_ATTRIBUTE_PRINTF(1, 2);
44 }
45
46 #define FH_DEBUG_MSG(M) debugPrint M
47 #define FH_DEBUG(M) M
48
49 #else
50 #define FH_DEBUG_MSG(M)
51 #define FH_DEBUG(M)
52 #endif
53
54 namespace libfreehand
55 {
56
57 uint8_t readU8(librevenge::RVNGInputStream *input);
58 uint16_t readU16(librevenge::RVNGInputStream *input);
59 uint32_t readU32(librevenge::RVNGInputStream *input);
60 int8_t readS8(librevenge::RVNGInputStream *input);
61 int16_t readS16(librevenge::RVNGInputStream *input);
62 int32_t readS32(librevenge::RVNGInputStream *input);
63
64 unsigned long getRemainingLength(librevenge::RVNGInputStream *input);
65
66 void writeU16(librevenge::RVNGBinaryData &buffer, const int value);
67 void writeU32(librevenge::RVNGBinaryData &buffer, const int value);
68
69 void _appendUTF16(librevenge::RVNGString &text, std::vector<unsigned short> &characters);
70 void _appendMacRoman(librevenge::RVNGString &text, unsigned char character);
71
72 class EndOfStreamException
73 {
74 };
75
76 class GenericException
77 {
78 };
79
80 } // namespace libfreehand
81
82 #endif // __LIBFREEHAND_UTILS_H__
83 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libfreehand::readU16
uint16_t readU16(librevenge::RVNGInputStream *input)
Definition: libfreehand_utils.cpp:85
libfreehand::readU32
uint32_t readU32(librevenge::RVNGInputStream *input)
Definition: libfreehand_utils.cpp:107
libfreehand
Definition: FHCollector.h:22
libfreehand::readU8
uint8_t readU8(librevenge::RVNGInputStream *input)
Definition: libfreehand_utils.cpp:64
libfreehand::readS32
int32_t readS32(librevenge::RVNGInputStream *input)
Definition: libfreehand_utils.cpp:125
libfreehand::_appendMacRoman
void _appendMacRoman(librevenge::RVNGString &text, unsigned char character)
Definition: libfreehand_utils.cpp:189
libfreehand::EndOfStreamException
Definition: libfreehand_utils.h:72
libfreehand::writeU16
void writeU16(librevenge::RVNGBinaryData &buffer, const int value)
Definition: libfreehand_utils.cpp:175
libfreehand::writeU32
void writeU32(librevenge::RVNGBinaryData &buffer, const int value)
Definition: libfreehand_utils.cpp:181
libfreehand::_appendUTF16
void _appendUTF16(librevenge::RVNGString &text, std::vector< unsigned short > &characters)
Definition: libfreehand_utils.cpp:153
libfreehand::readS16
int16_t readS16(librevenge::RVNGInputStream *input)
Definition: libfreehand_utils.cpp:102
libfreehand::readS8
int8_t readS8(librevenge::RVNGInputStream *input)
Definition: libfreehand_utils.cpp:80
libfreehand::GenericException
Definition: libfreehand_utils.h:76
libfreehand::getRemainingLength
unsigned long getRemainingLength(librevenge::RVNGInputStream *input)
Definition: libfreehand_utils.cpp:130