• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_FXCRT_CFX_BITSTREAM_H_
8 #define CORE_FXCRT_CFX_BITSTREAM_H_
9 
10 #include <stdint.h>
11 
12 #include "core/fxcrt/unowned_ptr.h"
13 
14 class CFX_BitStream {
15  public:
16   CFX_BitStream(const uint8_t* pData, uint32_t dwSize);
17   ~CFX_BitStream();
18 
19   void ByteAlign();
20 
IsEOF()21   bool IsEOF() const { return m_BitPos >= m_BitSize; }
GetPos()22   uint32_t GetPos() const { return m_BitPos; }
23   uint32_t GetBits(uint32_t nBits);
24 
SkipBits(uint32_t nBits)25   void SkipBits(uint32_t nBits) { m_BitPos += nBits; }
Rewind()26   void Rewind() { m_BitPos = 0; }
27 
BitsRemaining()28   uint32_t BitsRemaining() const {
29     return m_BitSize >= m_BitPos ? m_BitSize - m_BitPos : 0;
30   }
31 
32  private:
33   uint32_t m_BitPos;
34   uint32_t m_BitSize;
35   UnownedPtr<const uint8_t> m_pData;
36 };
37 
38 #endif  // CORE_FXCRT_CFX_BITSTREAM_H_
39