EBOOKBitStream.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* libe-book
3  * Version: MPL 2.0 / LGPLv2.1+
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  * Alternatively, the contents of this file may be used under the terms
10  * of the GNU Lesser General Public License Version 2.1 or later
11  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
12  * applicable instead of those above.
13  *
14  * For further information visit http://libebook.sourceforge.net
15  */
16 
17 #ifndef EBOOKBITSTREAM_H_INCLUDED
18 #define EBOOKBITSTREAM_H_INCLUDED
19 
20 #include "libebook_utils.h"
21 
22 class WPXInputStream;
23 
24 namespace libebook
25 {
26 
28 {
29 public:
30  explicit EBOOKBitStream(WPXInputStream *stream);
31 
32  uint32_t read(uint8_t numberOfBits, bool bigEndian = false);
33 
34  bool atEOS() const;
35  bool atLastByte() const;
36 
37 private:
38  void fill();
39 
44  uint8_t readByte();
45 
53  uint8_t readBits(uint8_t numberOfBits);
54 
55  uint8_t readAvailableBits(uint8_t numberOfBits);
56 
57 private:
58  static const uint8_t s_masks[8];
59 
60 private:
61  WPXInputStream *const m_stream;
62  uint8_t m_current;
63  uint8_t m_available;
64 };
65 
66 }
67 
68 #endif // EBOOKBITSTREAM_H_INCLUDED
69 
70 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
uint8_t readAvailableBits(uint8_t numberOfBits)
Definition: EBOOKBitStream.cpp:138
Definition: EBOOKBitStream.h:27
EBOOKBitStream(WPXInputStream *stream)
Definition: EBOOKBitStream.cpp:28
uint32_t read(uint8_t numberOfBits, bool bigEndian=false)
Definition: EBOOKBitStream.cpp:35
uint8_t readBits(uint8_t numberOfBits)
Reads a given amount of bits from the stream.
Definition: EBOOKBitStream.cpp:113
static const uint8_t s_masks[8]
Definition: EBOOKBitStream.h:58
uint8_t m_current
Definition: EBOOKBitStream.h:62
void fill()
Definition: EBOOKBitStream.cpp:98
WPXInputStream *const m_stream
Definition: EBOOKBitStream.h:61
uint8_t readByte()
Reads a byte from the stream.
Definition: EBOOKBitStream.cpp:108
bool atLastByte() const
Definition: EBOOKBitStream.cpp:89
bool atEOS() const
Definition: EBOOKBitStream.cpp:84
uint8_t m_available
Definition: EBOOKBitStream.h:63

Generated for libe-book by doxygen 1.8.5