EBOOKBitStream.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 EBOOKBITSTREAM_H_INCLUDED
11 #define EBOOKBITSTREAM_H_INCLUDED
12
13 #include "libebook_utils.h"
14
15
16 namespace libebook
17 {
18
19 class EBOOKBitStream
20 {
21 public:
22 explicit EBOOKBitStream(librevenge::RVNGInputStream *stream);
23
24 uint32_t read(uint8_t numberOfBits, bool bigEndian = false);
25
26 bool isEnd() const;
27 bool atLastByte() const;
28
29 private:
30 void fill();
31
36 uint8_t readByte();
37
45 uint8_t readBits(uint8_t numberOfBits);
46
47 uint8_t readAvailableBits(uint8_t numberOfBits);
48
49 private:
50 static const uint8_t s_masks[8];
51
52 private:
53 librevenge::RVNGInputStream *const m_stream;
54 uint8_t m_current;
55 uint8_t m_available;
56 };
57
58 }
59
60 #endif // EBOOKBITSTREAM_H_INCLUDED
61
62 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libebook::EBOOKBitStream::readAvailableBits
uint8_t readAvailableBits(uint8_t numberOfBits)
Definition: EBOOKBitStream.cpp:131
libebook::EBOOKBitStream::EBOOKBitStream
EBOOKBitStream(librevenge::RVNGInputStream *stream)
Definition: EBOOKBitStream.cpp:21
libebook::EBOOKBitStream
Definition: EBOOKBitStream.h:19
libebook::EBOOKBitStream::read
uint32_t read(uint8_t numberOfBits, bool bigEndian=false)
Definition: EBOOKBitStream.cpp:28
libebook::EBOOKBitStream::readBits
uint8_t readBits(uint8_t numberOfBits)
Reads a given amount of bits from the stream.
Definition: EBOOKBitStream.cpp:106
libebook_utils.h
libebook::EBOOKBitStream::s_masks
static const uint8_t s_masks[8]
Definition: EBOOKBitStream.h:50
libebook::EBOOKBitStream::m_current
uint8_t m_current
Definition: EBOOKBitStream.h:54
libebook::EBOOKBitStream::fill
void fill()
Definition: EBOOKBitStream.cpp:91
libebook::EBOOKBitStream::atLastByte
bool atLastByte() const
Definition: EBOOKBitStream.cpp:82
libebook::EBOOKBitStream::isEnd
bool isEnd() const
Definition: EBOOKBitStream.cpp:77
libebook
Definition: CHMParser.cpp:20
libebook::EBOOKBitStream::readByte
uint8_t readByte()
Reads a byte from the stream.
Definition: EBOOKBitStream.cpp:101
stream
RVNGInputStreamPtr_t stream
Definition: CHMStream.cpp:79
libebook::EBOOKBitStream::m_stream
librevenge::RVNGInputStream *const m_stream
Definition: EBOOKBitStream.h:53
libebook::EBOOKBitStream::m_available
uint8_t m_available
Definition: EBOOKBitStream.h:55