Blame src/lib/libmspub_utils.h

rpm-build 9243a4
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
rpm-build 9243a4
/*
rpm-build 9243a4
 * This file is part of the libmspub project.
rpm-build 9243a4
 *
rpm-build 9243a4
 * This Source Code Form is subject to the terms of the Mozilla Public
rpm-build 9243a4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
rpm-build 9243a4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
rpm-build 9243a4
 */
rpm-build 9243a4
rpm-build 9243a4
#ifndef INCLUDED_LIBMSPUB_UTILS_H
rpm-build 9243a4
#define INCLUDED_LIBMSPUB_UTILS_H
rpm-build 9243a4
rpm-build 9243a4
#ifdef HAVE_CONFIG_H
rpm-build 9243a4
#include "config.h"
rpm-build 9243a4
#endif
rpm-build 9243a4
rpm-build 9243a4
#include <cmath>
rpm-build 9243a4
#include <vector>
rpm-build 9243a4
rpm-build 9243a4
#include <boost/cstdint.hpp>
rpm-build 9243a4
rpm-build 9243a4
#include <librevenge/librevenge.h>
rpm-build 9243a4
rpm-build 9243a4
#include <librevenge-stream/librevenge-stream.h>
rpm-build 9243a4
rpm-build 9243a4
#include "MSPUBTypes.h"
rpm-build 9243a4
rpm-build 9243a4
#ifndef M_PI
rpm-build 9243a4
#define M_PI 3.14159265358979323846
rpm-build 9243a4
#endif
rpm-build 9243a4
rpm-build 9243a4
#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
rpm-build 9243a4
#  define MSPUB_ATTRIBUTE_PRINTF(fmt, arg) __attribute__((__format__(__printf__, fmt, arg)))
rpm-build 9243a4
#else
rpm-build 9243a4
#  define MSPUB_ATTRIBUTE_PRINTF(fmt, arg)
rpm-build 9243a4
#endif
rpm-build 9243a4
rpm-build 9243a4
#if defined(HAVE_CLANG_ATTRIBUTE_FALLTHROUGH)
rpm-build 9243a4
#  define MSPUB_FALLTHROUGH [[clang::fallthrough]]
rpm-build 9243a4
#elif defined(HAVE_GCC_ATTRIBUTE_FALLTHROUGH)
rpm-build 9243a4
#  define MSPUB_FALLTHROUGH __attribute__((fallthrough))
rpm-build 9243a4
#else
rpm-build 9243a4
#  define MSPUB_FALLTHROUGH ((void) 0)
rpm-build 9243a4
#endif
rpm-build 9243a4
rpm-build 9243a4
// do nothing with debug messages in a release compile
rpm-build 9243a4
#ifdef DEBUG
rpm-build 9243a4
namespace libmspub
rpm-build 9243a4
{
rpm-build 9243a4
void debugPrint(const char *format, ...) MSPUB_ATTRIBUTE_PRINTF(1, 2);
rpm-build 9243a4
}
rpm-build 9243a4
#define MSPUB_DEBUG_MSG(M) libmspub::debugPrint M
rpm-build 9243a4
#define MSPUB_DEBUG(M) M
rpm-build 9243a4
#else
rpm-build 9243a4
#define MSPUB_DEBUG_MSG(M)
rpm-build 9243a4
#define MSPUB_DEBUG(M)
rpm-build 9243a4
#endif
rpm-build 9243a4
rpm-build 9243a4
namespace libmspub
rpm-build 9243a4
{
rpm-build 9243a4
const char *mimeByImgType(ImgType type);
rpm-build 9243a4
const char *windowsCharsetNameByOriginalCharset(const char *name);
rpm-build 9243a4
rpm-build 9243a4
uint8_t readU8(librevenge::RVNGInputStream *input);
rpm-build 9243a4
uint16_t readU16(librevenge::RVNGInputStream *input);
rpm-build 9243a4
uint32_t readU32(librevenge::RVNGInputStream *input);
rpm-build 9243a4
uint64_t readU64(librevenge::RVNGInputStream *input);
rpm-build 9243a4
int8_t readS8(librevenge::RVNGInputStream *input);
rpm-build 9243a4
int16_t readS16(librevenge::RVNGInputStream *input);
rpm-build 9243a4
int32_t readS32(librevenge::RVNGInputStream *input);
rpm-build 9243a4
double readFixedPoint(librevenge::RVNGInputStream *input);
rpm-build 9243a4
double toFixedPoint(int fp);
rpm-build 9243a4
void readNBytes(librevenge::RVNGInputStream *input, unsigned long length, std::vector<unsigned char> &out;;
rpm-build 9243a4
rpm-build 9243a4
unsigned long getLength(librevenge::RVNGInputStream *input);
rpm-build 9243a4
rpm-build 9243a4
void appendCharacters(librevenge::RVNGString &text, const std::vector<unsigned char> &characters, const char *encoding);
rpm-build 9243a4
rpm-build 9243a4
bool stillReading(librevenge::RVNGInputStream *input, unsigned long until);
rpm-build 9243a4
rpm-build 9243a4
void rotateCounter(double &x, double &y, double centerX, double centerY, short rotation);
rpm-build 9243a4
void flipIfNecessary(double &x, double &y, double centerX, double centerY, bool flipVertical, bool flipHorizontal);
rpm-build 9243a4
rpm-build 9243a4
unsigned correctModulo(int x, unsigned n);
rpm-build 9243a4
double doubleModulo(double x, double y);
rpm-build 9243a4
rpm-build 9243a4
template <class MapT> typename MapT::mapped_type *getIfExists(MapT &map, const typename MapT::key_type &key)
rpm-build 9243a4
{
rpm-build 9243a4
  auto i = map.find(key);
rpm-build 9243a4
  return i == map.end() ? nullptr : &(i->second);
rpm-build 9243a4
}
rpm-build 9243a4
rpm-build 9243a4
template <class MapT> const typename MapT::mapped_type *getIfExists_const(MapT &map, const typename MapT::key_type &key)
rpm-build 9243a4
{
rpm-build 9243a4
  auto i = map.find(key);
rpm-build 9243a4
  return i == map.end() ? nullptr : &(i->second);
rpm-build 9243a4
}
rpm-build 9243a4
rpm-build 9243a4
template <class MapT> typename MapT::mapped_type ptr_getIfExists(MapT &map, const typename MapT::key_type &key)
rpm-build 9243a4
{
rpm-build 9243a4
  typename MapT::iterator i = map.find(key);
rpm-build 9243a4
  return i == map.end() ? NULL : i->second;
rpm-build 9243a4
}
rpm-build 9243a4
rpm-build 9243a4
class EndOfStreamException
rpm-build 9243a4
{
rpm-build 9243a4
};
rpm-build 9243a4
rpm-build 9243a4
class GenericException
rpm-build 9243a4
{
rpm-build 9243a4
};
rpm-build 9243a4
rpm-build 9243a4
librevenge::RVNGBinaryData inflateData(librevenge::RVNGBinaryData);
rpm-build 9243a4
rpm-build 9243a4
} // namespace libmspub
rpm-build 9243a4
rpm-build 9243a4
#endif // INCLUDED_LIBMSPUB_UTILS_H
rpm-build 9243a4
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */