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 
34 namespace libebook
35 {
36 void 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 
51 namespace libebook
52 {
53 
54 typedef std::shared_ptr<librevenge::RVNGInputStream> RVNGInputStreamPtr_t;
55 
57 {
58  void operator()(void *) {}
59 };
60 
61 uint8_t readU8(librevenge::RVNGInputStream *input, bool = false);
62 uint16_t readU16(librevenge::RVNGInputStream *input, bool bigEndian=false);
63 uint32_t readU32(librevenge::RVNGInputStream *input, bool bigEndian=false);
64 uint64_t readU64(librevenge::RVNGInputStream *input, bool bigEndian=false);
65 
66 const unsigned char *readNBytes(librevenge::RVNGInputStream *input, unsigned long numBytes);
67 
68 std::string readCString(librevenge::RVNGInputStream *input);
69 std::string readPascalString(librevenge::RVNGInputStream *input);
70 
71 void skip(librevenge::RVNGInputStream *input, unsigned long numBytes);
72 
73 void seek(librevenge::RVNGInputStream *input, unsigned long pos);
74 void seekRelative(librevenge::RVNGInputStream *input, long pos);
75 
76 unsigned long getRemainingLength(librevenge::RVNGInputStream *input);
77 
78 uint8_t readU8(std::shared_ptr<librevenge::RVNGInputStream> input, bool = false);
79 uint16_t readU16(std::shared_ptr<librevenge::RVNGInputStream> input, bool bigEndian=false);
80 uint32_t readU32(std::shared_ptr<librevenge::RVNGInputStream> input, bool bigEndian=false);
81 uint64_t readU64(std::shared_ptr<librevenge::RVNGInputStream> input, bool bigEndian=false);
82 
83 const unsigned char *readNBytes(std::shared_ptr<librevenge::RVNGInputStream> input, unsigned long numBytes);
84 
85 std::string readCString(std::shared_ptr<librevenge::RVNGInputStream> input);
86 std::string readPascalString(std::shared_ptr<librevenge::RVNGInputStream> input);
87 
88 void skip(std::shared_ptr<librevenge::RVNGInputStream> input, unsigned long numBytes);
89 
90 void seek(std::shared_ptr<librevenge::RVNGInputStream> input, unsigned long pos);
91 void seekRelative(std::shared_ptr<librevenge::RVNGInputStream> input, long pos);
92 
93 unsigned long getRemainingLength(std::shared_ptr<librevenge::RVNGInputStream> input);
94 
95 bool findSubStreamByExt(const RVNGInputStreamPtr_t &input, const std::string &ext, unsigned &id);
96 
97 librevenge::RVNGPropertyList getDefaultPageSpanPropList();
98 
100 {
101 public:
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: */
uint16_t readU16(librevenge::RVNGInputStream *input, bool bigEndian)
Definition: libebook_utils.cpp:57
Definition: EBOOKHTMLToken.h:89
void skip(librevenge::RVNGInputStream *input, unsigned long numBytes)
Definition: libebook_utils.cpp:145
Definition: libebook_utils.h:131
Definition: libebook_utils.h:105
Definition: libebook_utils.h:99
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr_t
Definition: libebook_utils.h:54
uint32_t readU32(librevenge::RVNGInputStream *input, bool bigEndian)
Definition: libebook_utils.cpp:73
string readCString(librevenge::RVNGInputStream *input)
Definition: libebook_utils.cpp:118
const unsigned char * readNBytes(librevenge::RVNGInputStream *const input, const unsigned long numBytes)
Definition: libebook_utils.cpp:105
Definition: libebook_utils.h:115
uint8_t readU8(librevenge::RVNGInputStream *input, bool)
Definition: libebook_utils.cpp:45
librevenge::RVNGPropertyList getDefaultPageSpanPropList()
Definition: libebook_utils.cpp:265
EndOfStreamException()
Definition: libebook_utils.cpp:275
uint64_t readU64(librevenge::RVNGInputStream *input, bool bigEndian)
Definition: libebook_utils.cpp:89
Definition: libebook_utils.h:56
unsigned long getRemainingLength(librevenge::RVNGInputStream *const input)
Definition: libebook_utils.cpp:170
Definition: libebook_utils.h:123
Definition: libebook_utils.h:111
bool findSubStreamByExt(const RVNGInputStreamPtr_t &input, const std::string &ext, unsigned &id)
Definition: libebook_utils.cpp:245
string readPascalString(librevenge::RVNGInputStream *input)
Definition: libebook_utils.cpp:133
Definition: libebook_utils.h:119
void seek(librevenge::RVNGInputStream *const input, const unsigned long pos)
Definition: libebook_utils.cpp:152
Definition: EBOOKOPFToken.h:54
void seekRelative(librevenge::RVNGInputStream *const input, const long pos)
Definition: libebook_utils.cpp:161
Definition: BBeBCollector.cpp:18
Definition: libebook_utils.h:127
void operator()(void *)
Definition: libebook_utils.h:58

Generated for libe-book by doxygen 1.8.14