summaryrefslogtreecommitdiff
path: root/core/fxcrt/cfx_bitstream.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt/cfx_bitstream.h')
-rw-r--r--core/fxcrt/cfx_bitstream.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/core/fxcrt/cfx_bitstream.h b/core/fxcrt/cfx_bitstream.h
new file mode 100644
index 0000000000..1829f23b92
--- /dev/null
+++ b/core/fxcrt/cfx_bitstream.h
@@ -0,0 +1,38 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCRT_CFX_BITSTREAM_H_
+#define CORE_FXCRT_CFX_BITSTREAM_H_
+
+#include <stdint.h>
+
+#include "core/fxcrt/cfx_unowned_ptr.h"
+
+class CFX_BitStream {
+ public:
+ CFX_BitStream(const uint8_t* pData, uint32_t dwSize);
+ ~CFX_BitStream();
+
+ void ByteAlign();
+
+ bool IsEOF() const { return m_BitPos >= m_BitSize; }
+ uint32_t GetPos() const { return m_BitPos; }
+ uint32_t GetBits(uint32_t nBits);
+
+ void SkipBits(uint32_t nBits) { m_BitPos += nBits; }
+ void Rewind() { m_BitPos = 0; }
+
+ uint32_t BitsRemaining() const {
+ return m_BitSize >= m_BitPos ? m_BitSize - m_BitPos : 0;
+ }
+
+ private:
+ uint32_t m_BitPos;
+ uint32_t m_BitSize;
+ CFX_UnownedPtr<const uint8_t> m_pData;
+};
+
+#endif // CORE_FXCRT_CFX_BITSTREAM_H_