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
41namespace libfreehand
42{
43void 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
54namespace libfreehand
55{
56
57uint8_t readU8(librevenge::RVNGInputStream *input);
58uint16_t readU16(librevenge::RVNGInputStream *input);
59uint32_t readU32(librevenge::RVNGInputStream *input);
60int8_t readS8(librevenge::RVNGInputStream *input);
61int16_t readS16(librevenge::RVNGInputStream *input);
62int32_t readS32(librevenge::RVNGInputStream *input);
63
64unsigned long getRemainingLength(librevenge::RVNGInputStream *input);
65
66void writeU16(librevenge::RVNGBinaryData &buffer, const int value);
67void writeU32(librevenge::RVNGBinaryData &buffer, const int value);
68
69void _appendUTF16(librevenge::RVNGString &text, std::vector<unsigned short> &characters);
70void _appendMacRoman(librevenge::RVNGString &text, unsigned char character);
71
73{
74};
75
77{
78};
79
80} // namespace libfreehand
81
82#endif // __LIBFREEHAND_UTILS_H__
83/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
Definition libfreehand_utils.h:73
Definition libfreehand_utils.h:77
Definition FHCollector.h:23
void _appendUTF16(librevenge::RVNGString &text, std::vector< unsigned short > &characters)
Definition libfreehand_utils.cpp:153
unsigned long getRemainingLength(librevenge::RVNGInputStream *input)
Definition libfreehand_utils.cpp:130
uint8_t readU8(librevenge::RVNGInputStream *input)
Definition libfreehand_utils.cpp:64
int8_t readS8(librevenge::RVNGInputStream *input)
Definition libfreehand_utils.cpp:80
void _appendMacRoman(librevenge::RVNGString &text, unsigned char character)
Definition libfreehand_utils.cpp:189
void writeU32(librevenge::RVNGBinaryData &buffer, const int value)
Definition libfreehand_utils.cpp:181
uint32_t readU32(librevenge::RVNGInputStream *input)
Definition libfreehand_utils.cpp:107
int16_t readS16(librevenge::RVNGInputStream *input)
Definition libfreehand_utils.cpp:102
void writeU16(librevenge::RVNGBinaryData &buffer, const int value)
Definition libfreehand_utils.cpp:175
uint16_t readU16(librevenge::RVNGInputStream *input)
Definition libfreehand_utils.cpp:85
int32_t readS32(librevenge::RVNGInputStream *input)
Definition libfreehand_utils.cpp:125

Generated for libfreehand by doxygen 1.9.7