EBOOKBitStream.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 libe-book 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 EBOOKBITSTREAM_H_INCLUDED
00011 #define EBOOKBITSTREAM_H_INCLUDED
00012 
00013 #include "libebook_utils.h"
00014 
00015 
00016 namespace libebook
00017 {
00018 
00019 class EBOOKBitStream
00020 {
00021 public:
00022   explicit EBOOKBitStream(librevenge::RVNGInputStream *stream);
00023 
00024   uint32_t read(uint8_t numberOfBits, bool bigEndian = false);
00025 
00026   bool isEnd() const;
00027   bool atLastByte() const;
00028 
00029 private:
00030   void fill();
00031 
00036   uint8_t readByte();
00037 
00045   uint8_t readBits(uint8_t numberOfBits);
00046 
00047   uint8_t readAvailableBits(uint8_t numberOfBits);
00048 
00049 private:
00050   static const uint8_t s_masks[8];
00051 
00052 private:
00053   librevenge::RVNGInputStream *const m_stream;
00054   uint8_t m_current;
00055   uint8_t m_available;
00056 };
00057 
00058 }
00059 
00060 #endif // EBOOKBITSTREAM_H_INCLUDED
00061 
00062 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */