libvisio_utils.h Source File documentation

libvisio_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 libvisio 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 __LIBVISIO_UTILS_H__
11#define __LIBVISIO_UTILS_H__
12
13#ifdef HAVE_CONFIG_H
14#include "config.h"
15#endif
16
17#include <memory>
18
19#include <boost/cstdint.hpp>
20
21#include "VSDTypes.h"
22
23#define VSD_EPSILON 1E-6
24#define VSD_ALMOST_ZERO(m) (fabs(m) <= VSD_EPSILON)
25#define VSD_APPROX_EQUAL(x, y) VSD_ALMOST_ZERO((x) - (y))
26
27#include <librevenge/librevenge.h>
28#include <librevenge-stream/librevenge-stream.h>
29#include <unicode/utypes.h>
30
31#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
32#define VSD_ATTRIBUTE_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg)))
33#else
34#define VSD_ATTRIBUTE_PRINTF(fmt, arg)
35#endif
36
37// do nothing with debug messages in a release compile
38#ifdef DEBUG
39#define VSD_DEBUG_MSG(M) libvisio::debugPrint M
40#define VSD_DEBUG(M) M
41#else
42#define VSD_DEBUG_MSG(M)
43#define VSD_DEBUG(M)
44#endif
45
46#define VSD_NUM_ELEMENTS(array) (sizeof(array)/sizeof((array)[0]))
47
48 namespace libvisio
49{
50
51 typedef std::shared_ptr<librevenge::RVNGInputStream> RVNGInputStreamPtr_t;
52
53 struct VSDDummyDeleter
54{
55 void operator()(void *) {}
56};
57
58uint8_t readU8(librevenge::RVNGInputStream *input);
59uint16_t readU16(librevenge::RVNGInputStream *input);
60int16_t readS16(librevenge::RVNGInputStream *input);
61uint32_t readU32(librevenge::RVNGInputStream *input);
62int32_t readS32(librevenge::RVNGInputStream *input);
63uint64_t readU64(librevenge::RVNGInputStream *input);
64
65double readDouble(librevenge::RVNGInputStream *input);
66
67const librevenge::RVNGString getColourString(const Colour &c);
68
69unsigned long getRemainingLength(librevenge::RVNGInputStream *input);
70
71void appendUCS4(librevenge::RVNGString &text, UChar32 ucs4Character);
72
73void debugPrint(const char *format, ...) VSD_ATTRIBUTE_PRINTF(1, 2);
74
75class EndOfStreamException
76{
77};
78
79 class XmlParserException
80{
81};
82
83 class GenericException
84{
85};
86
87} // namespace libvisio
88
89#endif // __LIBVISIO_UTILS_H__
90/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
VSDTypes.h
libvisio::EndOfStreamException
Definition libvisio_utils.h:76
libvisio::GenericException
Definition libvisio_utils.h:84
libvisio::XmlParserException
Definition libvisio_utils.h:80
VSD_ATTRIBUTE_PRINTF
#define VSD_ATTRIBUTE_PRINTF(fmt, arg)
Definition libvisio_utils.h:34
libvisio
Definition libvisio_utils.h:49
libvisio::readU8
uint8_t readU8(librevenge::RVNGInputStream *input)
Definition libvisio_utils.cpp:18
libvisio::RVNGInputStreamPtr_t
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr_t
Definition libvisio_utils.h:51
libvisio::getRemainingLength
unsigned long getRemainingLength(librevenge::RVNGInputStream *input)
Definition libvisio_utils.cpp:112
libvisio::readU64
uint64_t readU64(librevenge::RVNGInputStream *input)
Definition libvisio_utils.cpp:76
libvisio::readS32
int32_t readS32(librevenge::RVNGInputStream *input)
Definition libvisio_utils.cpp:71
libvisio::readU16
uint16_t readU16(librevenge::RVNGInputStream *input)
Definition libvisio_utils.cpp:34
libvisio::readS16
int16_t readS16(librevenge::RVNGInputStream *input)
Definition libvisio_utils.cpp:50
libvisio::readDouble
double readDouble(librevenge::RVNGInputStream *input)
Definition libvisio_utils.cpp:92
libvisio::appendUCS4
void appendUCS4(librevenge::RVNGString &text, UChar32 ucs4Character)
Definition libvisio_utils.cpp:134
libvisio::getColourString
const librevenge::RVNGString getColourString(const Colour &c)
Definition libvisio_utils.cpp:105
libvisio::debugPrint
void debugPrint(const char *format,...) VSD_ATTRIBUTE_PRINTF(1
Definition libvisio_utils.cpp:148
libvisio::readU32
uint32_t readU32(librevenge::RVNGInputStream *input)
Definition libvisio_utils.cpp:55
libvisio::VSDDummyDeleter
Definition libvisio_utils.h:54
libvisio::VSDDummyDeleter::operator()
void operator()(void *)
Definition libvisio_utils.h:55