libvisio_utils.h
Go to the documentation of this file.
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* This file is part of the libvisio project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef __LIBVISIO_UTILS_H__
#define __LIBVISIO_UTILS_H__
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <memory>
#include "VSDTypes.h"
#define VSD_EPSILON 1E-6
#define VSD_ALMOST_ZERO(m) (fabs(m) <= VSD_EPSILON)
#define VSD_APPROX_EQUAL(x, y) VSD_ALMOST_ZERO((x) - (y))
#include <librevenge/librevenge.h>
#include <librevenge-stream/librevenge-stream.h>
#include <unicode/utypes.h>
#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
#define VSD_ATTRIBUTE_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg)))
#else
#define VSD_ATTRIBUTE_PRINTF(fmt, arg)
#endif
// do nothing with debug messages in a release compile
#ifdef DEBUG
#define VSD_DEBUG_MSG(M) libvisio::debugPrint M
#define VSD_DEBUG(M) M
#else
#define VSD_DEBUG_MSG(M)
#define VSD_DEBUG(M)
#endif
#define VSD_NUM_ELEMENTS(array) (sizeof(array)/sizeof((array)[0]))
namespace libvisio
{
typedef std::shared_ptr<librevenge::RVNGInputStream> RVNGInputStreamPtr_t;
struct VSDDummyDeleter
{
void operator()(void *) {}
};
template<typename T>
std::unique_ptr<T> clone(const std::unique_ptr<T> &other)
{
return std::unique_ptr<T>(other->clone());
}
uint8_t readU8(librevenge::RVNGInputStream *input);
uint16_t readU16(librevenge::RVNGInputStream *input);
int16_t readS16(librevenge::RVNGInputStream *input);
uint32_t readU32(librevenge::RVNGInputStream *input);
int32_t readS32(librevenge::RVNGInputStream *input);
uint64_t readU64(librevenge::RVNGInputStream *input);
double readDouble(librevenge::RVNGInputStream *input);
const librevenge::RVNGString getColourString(const Colour &c);
unsigned long getRemainingLength(librevenge::RVNGInputStream *input);
void appendUCS4(librevenge::RVNGString &text, UChar32 ucs4Character);
void debugPrint(const char *format, ...) VSD_ATTRIBUTE_PRINTF(1, 2);
class EndOfStreamException
{
};
class XmlParserException
{
};
class GenericException
{
};
} // namespace libvisio
#endif // __LIBVISIO_UTILS_H__
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
VSDTypes.h
libvisio::EndOfStreamException
Definition libvisio_utils.h:80
libvisio::GenericException
Definition libvisio_utils.h:88
libvisio::XmlParserException
Definition libvisio_utils.h:84
VSD_ATTRIBUTE_PRINTF
#define VSD_ATTRIBUTE_PRINTF(fmt, arg)
Definition libvisio_utils.h:32
libvisio
Definition libvisio_utils.h:47
libvisio::readU8
uint8_t readU8(librevenge::RVNGInputStream *input)
Definition libvisio_utils.cpp:16
libvisio::RVNGInputStreamPtr_t
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr_t
Definition libvisio_utils.h:49
libvisio::getRemainingLength
unsigned long getRemainingLength(librevenge::RVNGInputStream *input)
Definition libvisio_utils.cpp:110
libvisio::readU64
uint64_t readU64(librevenge::RVNGInputStream *input)
Definition libvisio_utils.cpp:74
libvisio::readS32
int32_t readS32(librevenge::RVNGInputStream *input)
Definition libvisio_utils.cpp:69
libvisio::readU16
uint16_t readU16(librevenge::RVNGInputStream *input)
Definition libvisio_utils.cpp:32
libvisio::readS16
int16_t readS16(librevenge::RVNGInputStream *input)
Definition libvisio_utils.cpp:48
libvisio::readDouble
double readDouble(librevenge::RVNGInputStream *input)
Definition libvisio_utils.cpp:90
libvisio::appendUCS4
void appendUCS4(librevenge::RVNGString &text, UChar32 ucs4Character)
Definition libvisio_utils.cpp:132
libvisio::clone
std::unique_ptr< T > clone(const std::unique_ptr< T > &other)
Definition libvisio_utils.h:57
libvisio::getColourString
const librevenge::RVNGString getColourString(const Colour &c)
Definition libvisio_utils.cpp:103
libvisio::debugPrint
void debugPrint(const char *format,...) VSD_ATTRIBUTE_PRINTF(1
Definition libvisio_utils.cpp:146
libvisio::readU32
uint32_t readU32(librevenge::RVNGInputStream *input)
Definition libvisio_utils.cpp:53
libvisio::VSDDummyDeleter
Definition libvisio_utils.h:52
libvisio::VSDDummyDeleter::operator()
void operator()(void *)
Definition libvisio_utils.h:53