libepubgen_utils.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libepubgen project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef INCLUDED_LIBEPUBGEN_UTILS_H
00011 #define INCLUDED_LIBEPUBGEN_UTILS_H
00012 
00013 #ifdef HAVE_CONFIG_H
00014 #include "config.h"
00015 #endif
00016 
00017 #include <memory>
00018 
00019 #include <boost/cstdint.hpp>
00020 
00021 #include <librevenge-stream/librevenge-stream.h>
00022 
00023 #if defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
00024 #define EPUBGEN_ATTRIBUTE_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg)))
00025 #else
00026 #define EPUBGEN_ATTRIBUTE_PRINTF(fmt, arg)
00027 #endif
00028 
00029 // do nothing with debug messages in a release compile
00030 #ifdef DEBUG
00031 
00032 namespace libepubgen
00033 {
00034 void debugPrint(const char *format, ...) EPUBGEN_ATTRIBUTE_PRINTF(1, 2);
00035 }
00036 
00037 #define EPUBGEN_DEBUG_MSG(M) libepubgen::debugPrint M
00038 #define EPUBGEN_DEBUG(M) M
00039 
00040 #else
00041 
00042 #define EPUBGEN_DEBUG_MSG(M)
00043 #define EPUBGEN_DEBUG(M)
00044 
00045 #endif
00046 
00047 #define EPUBGEN_NUM_ELEMENTS(array) (sizeof(array) / sizeof(array[0]))
00048 
00049 namespace libepubgen
00050 {
00051 
00052 typedef std::shared_ptr<librevenge::RVNGInputStream> RVNGInputStreamPtr_t;
00053 
00054 struct EPUBGENDummyDeleter
00055 {
00056   void operator()(void *) {}
00057 };
00058 
00059 template<typename T, typename... Args>
00060 std::unique_ptr<T> make_unique(Args &&... args)
00061 {
00062   return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
00063 }
00064 
00065 class GenericException
00066 {
00067 };
00068 
00069 } // namespace libepubgen
00070 
00071 #endif // INCLUDED_LIBEPUBGEN_UTILS_H
00072 
00073 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */