libebook_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 libe-book 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 LIBEBOOK_UTILS_H_INCLUDED
11#define LIBEBOOK_UTILS_H_INCLUDED
12
13#ifdef HAVE_CONFIG_H
14#include "config.h"
15#endif
16
17#include <memory>
18#include <string>
19
20#include <boost/cstdint.hpp>
21
22#include <librevenge-stream/librevenge-stream.h>
23#include <librevenge/librevenge.h>
24
25// do nothing with debug messages in a release compile
26#ifdef DEBUG
27
28#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
29#define EBOOK_ATTRIBUTE_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg)))
30#else
31#define EBOOK_ATTRIBUTE_PRINTF(fmt, arg)
32#endif
33
34namespace libebook
35{
36void debugPrint(const char *format, ...) EBOOK_ATTRIBUTE_PRINTF(1, 2);
37}
38
39#define EBOOK_DEBUG_MSG(M) libebook::debugPrint M
40#define EBOOK_DEBUG(M) M
41
42#else
43
44#define EBOOK_DEBUG_MSG(M)
45#define EBOOK_DEBUG(M)
46
47#endif
48
49#define EBOOK_NUM_ELEMENTS(array) sizeof(array)/sizeof(array[0])
50
51namespace libebook
52{
53
54typedef std::shared_ptr<librevenge::RVNGInputStream> RVNGInputStreamPtr_t;
55
57{
58 void operator()(void *) {}
59};
60
61uint8_t readU8(librevenge::RVNGInputStream *input, bool = false);
62uint16_t readU16(librevenge::RVNGInputStream *input, bool bigEndian=false);
63uint32_t readU32(librevenge::RVNGInputStream *input, bool bigEndian=false);
64uint64_t readU64(librevenge::RVNGInputStream *input, bool bigEndian=false);
65
66const unsigned char *readNBytes(librevenge::RVNGInputStream *input, unsigned long numBytes);
67
68std::string readCString(librevenge::RVNGInputStream *input);
69std::string readPascalString(librevenge::RVNGInputStream *input);
70
71void skip(librevenge::RVNGInputStream *input, unsigned long numBytes);
72
73void seek(librevenge::RVNGInputStream *input, unsigned long pos);
74void seekRelative(librevenge::RVNGInputStream *input, long pos);
75
76unsigned long getRemainingLength(librevenge::RVNGInputStream *input);
77
78uint8_t readU8(std::shared_ptr<librevenge::RVNGInputStream> input, bool = false);
79uint16_t readU16(std::shared_ptr<librevenge::RVNGInputStream> input, bool bigEndian=false);
80uint32_t readU32(std::shared_ptr<librevenge::RVNGInputStream> input, bool bigEndian=false);
81uint64_t readU64(std::shared_ptr<librevenge::RVNGInputStream> input, bool bigEndian=false);
82
83const unsigned char *readNBytes(std::shared_ptr<librevenge::RVNGInputStream> input, unsigned long numBytes);
84
85std::string readCString(std::shared_ptr<librevenge::RVNGInputStream> input);
86std::string readPascalString(std::shared_ptr<librevenge::RVNGInputStream> input);
87
88void skip(std::shared_ptr<librevenge::RVNGInputStream> input, unsigned long numBytes);
89
90void seek(std::shared_ptr<librevenge::RVNGInputStream> input, unsigned long pos);
91void seekRelative(std::shared_ptr<librevenge::RVNGInputStream> input, long pos);
92
93unsigned long getRemainingLength(std::shared_ptr<librevenge::RVNGInputStream> input);
94
95bool findSubStreamByExt(const RVNGInputStreamPtr_t &input, const std::string &ext, unsigned &id);
96
97librevenge::RVNGPropertyList getDefaultPageSpanPropList();
98
100{
101public:
103};
104
106{
107};
108
109// parser exceptions
110
112{
113};
114
116{
117};
118
120{
121};
122
124{
125};
126
128{
129};
130
132{
133};
134
135} // namespace libebook
136
137#endif // LIBEBOOK_UTILS_H_INCLUDED
138/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
Definition libebook_utils.h:100
EndOfStreamException()
Definition libebook_utils.cpp:275
Definition libebook_utils.h:112
Definition libebook_utils.h:106
Definition libebook_utils.h:116
Definition libebook_utils.h:120
Definition libebook_utils.h:124
Definition libebook_utils.h:128
Definition libebook_utils.h:132
Definition BBeBCollector.cpp:19
string readCString(librevenge::RVNGInputStream *input)
Definition libebook_utils.cpp:118
bool findSubStreamByExt(const RVNGInputStreamPtr_t &input, const std::string &ext, unsigned &id)
Definition libebook_utils.cpp:245
librevenge::RVNGPropertyList getDefaultPageSpanPropList()
Definition libebook_utils.cpp:265
uint8_t readU8(librevenge::RVNGInputStream *input, bool)
Definition libebook_utils.cpp:45
void seek(librevenge::RVNGInputStream *const input, const unsigned long pos)
Definition libebook_utils.cpp:152
unsigned long getRemainingLength(librevenge::RVNGInputStream *const input)
Definition libebook_utils.cpp:170
void skip(librevenge::RVNGInputStream *input, unsigned long numBytes)
Definition libebook_utils.cpp:145
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr_t
Definition libebook_utils.h:54
string readPascalString(librevenge::RVNGInputStream *input)
Definition libebook_utils.cpp:133
uint64_t readU64(librevenge::RVNGInputStream *input, bool bigEndian)
Definition libebook_utils.cpp:89
uint16_t readU16(librevenge::RVNGInputStream *input, bool bigEndian)
Definition libebook_utils.cpp:57
const unsigned char * readNBytes(librevenge::RVNGInputStream *const input, const unsigned long numBytes)
Definition libebook_utils.cpp:105
uint32_t readU32(librevenge::RVNGInputStream *input, bool bigEndian)
Definition libebook_utils.cpp:73
void seekRelative(librevenge::RVNGInputStream *const input, const long pos)
Definition libebook_utils.cpp:161
Definition libebook_utils.h:57
void operator()(void *)
Definition libebook_utils.h:58

Generated for libe-book by doxygen 1.9.7