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 <algorithm>
18
#include <memory>
19
20
#include <boost/cstdint.hpp>
21
22
#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
23
#define EPUBGEN_ATTRIBUTE_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg)))
24
#else
25
#define EPUBGEN_ATTRIBUTE_PRINTF(fmt, arg)
26
#endif
27
28
// do nothing with debug messages in a release compile
29
#ifdef DEBUG
30
31
namespace
libepubgen
32
{
33
void
debugPrint(
const
char
*format, ...)
EPUBGEN_ATTRIBUTE_PRINTF
(1, 2);
34
}
35
36
#define EPUBGEN_DEBUG_MSG(M) libepubgen::debugPrint M
37
#define EPUBGEN_DEBUG(M) M
38
39
#else
40
41
#define EPUBGEN_DEBUG_MSG(M)
42
#define EPUBGEN_DEBUG(M)
43
44
#endif
45
46
#define EPUBGEN_NUM_ELEMENTS(array) (sizeof(array) / sizeof(array[0]))
47
48
namespace
libepubgen
49
{
50
51
template
<
typename
T,
typename
... Args>
52
std::unique_ptr<T>
make_unique
(Args &&... args)
53
{
54
return
std::unique_ptr<T>(
new
T(std::forward<Args>(args)...));
55
}
56
57
class
GenericException
58
{
59
};
60
61
}
// namespace libepubgen
62
63
#endif // INCLUDED_LIBEPUBGEN_UTILS_H
64
65
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
EPUBGEN_ATTRIBUTE_PRINTF
#define EPUBGEN_ATTRIBUTE_PRINTF(fmt, arg)
Definition:
libepubgen_utils.h:25
libepubgen::GenericException
Definition:
libepubgen_utils.h:58
libepubgen
Definition:
EPUBBinaryContent.cpp:15
libepubgen::make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition:
libepubgen_utils.h:52
libepubgen_utils.h
Generated for libepubgen by
doxygen
1.8.18