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_SRC_FPDFAPI_FPDF_PARSER_CPDF_SYNTAX_PARSER_H_ | |
| 8 #define CORE_SRC_FPDFAPI_FPDF_PARSER_CPDF_SYNTAX_PARSER_H_ | |
| 9 | |
| 10 #include <memory> | |
| 11 | |
| 12 #include "core/include/fxcrt/fx_basic.h" | |
| 13 | |
| 14 class CPDF_CryptoHandler; | |
| 15 class CPDF_IndirectObjectHolder; | |
| 16 class CPDF_Object; | |
| 17 class CPDF_Dictionary; | |
| 18 class CPDF_Stream; | |
| 19 class IFX_FileRead; | |
| 20 | |
| 21 class CPDF_SyntaxParser { | |
| 22 public: | |
| 23 CPDF_SyntaxParser(); | |
| 24 ~CPDF_SyntaxParser(); | |
| 25 | |
| 26 void InitParser(IFX_FileRead* pFileAccess, FX_DWORD HeaderOffset); | |
| 27 | |
| 28 FX_FILESIZE SavePos() const { return m_Pos; } | |
| 29 void RestorePos(FX_FILESIZE pos) { m_Pos = pos; } | |
| 30 | |
| 31 CPDF_Object* GetObject(CPDF_IndirectObjectHolder* pObjList, | |
| 32 FX_DWORD objnum, | |
| 33 FX_DWORD gennum, | |
| 34 FX_BOOL bDecrypt); | |
| 35 CPDF_Object* GetObjectByStrict(CPDF_IndirectObjectHolder* pObjList, | |
| 36 FX_DWORD objnum, | |
| 37 FX_DWORD gennum); | |
| 38 CFX_ByteString GetKeyword(); | |
| 39 | |
| 40 void ToNextLine(); | |
| 41 void ToNextWord(); | |
| 42 | |
| 43 FX_BOOL SearchWord(const CFX_ByteStringC& word, | |
| 44 FX_BOOL bWholeWord, | |
| 45 FX_BOOL bForward, | |
| 46 FX_FILESIZE limit); | |
| 47 int SearchMultiWord(const CFX_ByteStringC& words, | |
| 48 FX_BOOL bWholeWord, | |
| 49 FX_FILESIZE limit); | |
| 50 FX_FILESIZE FindTag(const CFX_ByteStringC& tag, FX_FILESIZE limit); | |
| 51 | |
| 52 void SetEncrypt(std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler); | |
| 53 | |
| 54 FX_BOOL ReadBlock(uint8_t* pBuf, FX_DWORD size); | |
| 55 FX_BOOL GetCharAt(FX_FILESIZE pos, uint8_t& ch); | |
| 56 CFX_ByteString GetNextWord(bool* bIsNumber); | |
| 57 | |
| 58 private: | |
| 59 friend class CPDF_Parser; | |
| 60 friend class CPDF_DataAvail; | |
| 61 friend class fpdf_parser_parser_ReadHexString_Test; | |
| 62 | |
| 63 static const int kParserMaxRecursionDepth = 64; | |
|
dsinclair
2016/03/08 01:15:05
Can these move into the .cpp file now as they will
Tom Sepez
2016/03/08 19:35:42
probably.
| |
| 64 static int s_CurrentRecursionDepth; | |
| 65 | |
| 66 uint32_t GetDirectNum(); | |
| 67 | |
| 68 FX_BOOL GetNextChar(uint8_t& ch); | |
| 69 FX_BOOL GetCharAtBackward(FX_FILESIZE pos, uint8_t& ch); | |
| 70 void GetNextWordInternal(bool* bIsNumber); | |
| 71 bool IsWholeWord(FX_FILESIZE startpos, | |
| 72 FX_FILESIZE limit, | |
| 73 const CFX_ByteStringC& tag, | |
| 74 FX_BOOL checkKeyword); | |
| 75 | |
| 76 CFX_ByteString ReadString(); | |
| 77 CFX_ByteString ReadHexString(); | |
| 78 unsigned int ReadEOLMarkers(FX_FILESIZE pos); | |
| 79 CPDF_Stream* ReadStream(CPDF_Dictionary* pDict, | |
| 80 FX_DWORD objnum, | |
| 81 FX_DWORD gennum); | |
| 82 | |
| 83 FX_FILESIZE m_Pos; | |
| 84 int m_MetadataObjnum; | |
| 85 IFX_FileRead* m_pFileAccess; | |
| 86 FX_DWORD m_HeaderOffset; | |
| 87 FX_FILESIZE m_FileLen; | |
| 88 uint8_t* m_pFileBuf; | |
| 89 FX_DWORD m_BufSize; | |
| 90 FX_FILESIZE m_BufOffset; | |
| 91 std::unique_ptr<CPDF_CryptoHandler> m_pCryptoHandler; | |
| 92 uint8_t m_WordBuffer[257]; | |
| 93 FX_DWORD m_WordSize; | |
| 94 }; | |
| 95 | |
| 96 #endif // CORE_SRC_FPDFAPI_FPDF_PARSER_CPDF_SYNTAX_PARSER_H_ | |
| OLD | NEW |