Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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_FPDFAPI_PAGE_CPDF_STREAMPARSER_H_ | |
| 8 #define CORE_FPDFAPI_PAGE_CPDF_STREAMPARSER_H_ | |
| 9 | |
| 10 #include <memory> | |
| 11 #include <utility> | |
| 12 | |
| 13 #include "core/fpdfapi/parser/cpdf_dictionary.h" | |
| 14 #include "core/fpdfapi/parser/cpdf_document.h" | |
| 15 #include "core/fpdfapi/parser/cpdf_object.h" | |
| 16 #include "core/fpdfapi/parser/cpdf_stream.h" | |
| 17 #include "core/fxcrt/cfx_string_pool_template.h" | |
| 18 #include "core/fxcrt/cfx_weak_ptr.h" | |
| 19 | |
| 20 class CPDF_StreamParser { | |
| 21 public: | |
| 22 enum SyntaxType { EndOfData, Number, Keyword, Name, Others }; | |
| 23 | |
| 24 CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize); | |
| 25 CPDF_StreamParser(const uint8_t* pData, | |
| 26 uint32_t dwSize, | |
| 27 const CFX_WeakPtr<CFX_ByteStringPool>& pPool); | |
| 28 ~CPDF_StreamParser(); | |
| 29 | |
| 30 SyntaxType ParseNextElement(); | |
| 31 uint8_t* GetWordBuf() { return m_WordBuffer; } | |
|
dsinclair
2016/11/22 18:13:23
const?
Tom Sepez
2016/11/22 18:36:31
const uint8_t* GWB() const {}
| |
| 32 uint32_t GetWordSize() const { return m_WordSize; } | |
| 33 uint32_t GetPos() const { return m_Pos; } | |
| 34 void SetPos(uint32_t pos) { m_Pos = pos; } | |
| 35 std::unique_ptr<CPDF_Object> GetObject() { return std::move(m_pLastObj); } | |
| 36 std::unique_ptr<CPDF_Object> ReadNextObject(bool bAllowNestedArray, | |
| 37 uint32_t dwInArrayLevel); | |
| 38 std::unique_ptr<CPDF_Stream> ReadInlineStream( | |
| 39 CPDF_Document* pDoc, | |
| 40 std::unique_ptr<CPDF_Dictionary> pDict, | |
| 41 CPDF_Object* pCSObj); | |
| 42 | |
| 43 private: | |
| 44 friend class cpdf_streamparser_ReadHexString_Test; | |
| 45 | |
| 46 void GetNextWord(bool& bIsNumber); | |
| 47 CFX_ByteString ReadString(); | |
| 48 CFX_ByteString ReadHexString(); | |
| 49 bool PositionIsInBounds() const; | |
| 50 | |
| 51 const uint8_t* m_pBuf; | |
| 52 uint32_t m_Size; // Length in bytes of m_pBuf. | |
| 53 uint32_t m_Pos; // Current byte position within m_pBuf. | |
| 54 uint8_t m_WordBuffer[256]; | |
| 55 uint32_t m_WordSize; | |
| 56 std::unique_ptr<CPDF_Object> m_pLastObj; | |
| 57 CFX_WeakPtr<CFX_ByteStringPool> m_pPool; | |
| 58 }; | |
| 59 | |
| 60 #endif // CORE_FPDFAPI_PAGE_CPDF_STREAMPARSER_H_ | |
| OLD | NEW |