From ccd5be05f61c85754daf5c8155f4932f6d35a55a Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 30 Aug 2017 13:23:44 -0400 Subject: Move CFX_BitStream to its own file This CL moves the CFX_BitStream code out of fx_basic and into cfx_bitstream. Bug: pdfium:867 Change-Id: I5b7e6190a7db1fe1d24feb6bd676035a5c73ee92 Reviewed-on: https://pdfium-review.googlesource.com/12350 Commit-Queue: dsinclair Reviewed-by: Tom Sepez --- core/fxcrt/cfx_bitstream.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 core/fxcrt/cfx_bitstream.h (limited to 'core/fxcrt/cfx_bitstream.h') 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 + +#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 m_pData; +}; + +#endif // CORE_FXCRT_CFX_BITSTREAM_H_ -- cgit v1.2.3