libepubgen_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 libepubgen 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 INCLUDED_LIBEPUBGEN_UTILS_H
11#define INCLUDED_LIBEPUBGEN_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 <librevenge-stream/librevenge-stream.h>
22
23#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
24#define EPUBGEN_ATTRIBUTE_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg)))
25#else
26#define EPUBGEN_ATTRIBUTE_PRINTF(fmt, arg)
27#endif
28
29// do nothing with debug messages in a release compile
30#ifdef DEBUG
31
32namespace libepubgen
33{
34void debugPrint(const char *format, ...) EPUBGEN_ATTRIBUTE_PRINTF(1, 2);
35}
36
37#define EPUBGEN_DEBUG_MSG(M) libepubgen::debugPrint M
38#define EPUBGEN_DEBUG(M) M
39
40#else
41
42#define EPUBGEN_DEBUG_MSG(M)
43#define EPUBGEN_DEBUG(M)
44
45#endif
46
47#define EPUBGEN_NUM_ELEMENTS(array) (sizeof(array) / sizeof(array[0]))
48
49namespace libepubgen
50{
51
52typedef std::shared_ptr<librevenge::RVNGInputStream> RVNGInputStreamPtr_t;
53
55{
56 void operator()(void *) {}
57};
58
59template<typename T, typename... Args>
60std::unique_ptr<T> make_unique(Args &&... args)
61{
62 return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
63}
64
66{
67};
68
69} // namespace libepubgen
70
71#endif // INCLUDED_LIBEPUBGEN_UTILS_H
72
73/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
Definition libepubgen_utils.h:66
#define EPUBGEN_ATTRIBUTE_PRINTF(fmt, arg)
Definition libepubgen_utils.h:26
Definition EPUBBinarySink.cpp:13
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr_t
Definition libepubgen_utils.h:52
std::unique_ptr< T > make_unique(Args &&... args)
Definition libepubgen_utils.h:60
Definition libepubgen_utils.h:55
void operator()(void *)
Definition libepubgen_utils.h:56

Generated for libepubgen by doxygen 1.9.8