Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef CORE_FPDFAPI_PARSER_CPDF_SYNTAX_PARSER_H_ | 7 #ifndef CORE_FPDFAPI_PARSER_CPDF_SYNTAX_PARSER_H_ |
| 8 #define CORE_FPDFAPI_PARSER_CPDF_SYNTAX_PARSER_H_ | 8 #define CORE_FPDFAPI_PARSER_CPDF_SYNTAX_PARSER_H_ |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 uint32_t gennum); | 40 uint32_t gennum); |
| 41 CFX_ByteString GetKeyword(); | 41 CFX_ByteString GetKeyword(); |
| 42 | 42 |
| 43 void ToNextLine(); | 43 void ToNextLine(); |
| 44 void ToNextWord(); | 44 void ToNextWord(); |
| 45 | 45 |
| 46 bool SearchWord(const CFX_ByteStringC& word, | 46 bool SearchWord(const CFX_ByteStringC& word, |
| 47 bool bWholeWord, | 47 bool bWholeWord, |
| 48 bool bForward, | 48 bool bForward, |
| 49 FX_FILESIZE limit); | 49 FX_FILESIZE limit); |
| 50 int SearchMultiWord(const CFX_ByteStringC& words, | |
| 51 bool bWholeWord, | |
| 52 FX_FILESIZE limit); | |
| 53 FX_FILESIZE FindTag(const CFX_ByteStringC& tag, FX_FILESIZE limit); | 50 FX_FILESIZE FindTag(const CFX_ByteStringC& tag, FX_FILESIZE limit); |
| 54 | 51 |
| 55 void SetEncrypt(std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler); | 52 void SetEncrypt(std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler); |
| 56 | 53 |
| 57 bool ReadBlock(uint8_t* pBuf, uint32_t size); | 54 bool ReadBlock(uint8_t* pBuf, uint32_t size); |
| 58 bool GetCharAt(FX_FILESIZE pos, uint8_t& ch); | 55 bool GetCharAt(FX_FILESIZE pos, uint8_t& ch); |
| 59 CFX_ByteString GetNextWord(bool* bIsNumber); | 56 CFX_ByteString GetNextWord(bool* bIsNumber); |
| 60 | 57 |
| 61 private: | 58 private: |
| 62 friend class CPDF_Parser; | 59 friend class CPDF_Parser; |
| 63 friend class CPDF_DataAvail; | 60 friend class CPDF_DataAvail; |
| 64 friend class cpdf_syntax_parser_ReadHexString_Test; | 61 friend class cpdf_syntax_parser_ReadHexString_Test; |
| 65 | 62 |
| 66 static const int kParserMaxRecursionDepth = 64; | 63 static const int kParserMaxRecursionDepth = 64; |
| 67 static int s_CurrentRecursionDepth; | 64 static int s_CurrentRecursionDepth; |
| 68 | 65 |
| 69 uint32_t GetDirectNum(); | 66 uint32_t GetDirectNum(); |
| 67 bool ReadChar(FX_FILESIZE read_pos, uint32_t read_size); | |
| 70 bool GetNextChar(uint8_t& ch); | 68 bool GetNextChar(uint8_t& ch); |
| 71 bool GetCharAtBackward(FX_FILESIZE pos, uint8_t& ch); | 69 bool GetCharAtBackward(FX_FILESIZE pos, uint8_t& ch); |
| 72 void GetNextWordInternal(bool* bIsNumber); | 70 void GetNextWordInternal(bool* bIsNumber); |
| 73 bool IsWholeWord(FX_FILESIZE startpos, | 71 bool IsWholeWord(FX_FILESIZE startpos, |
| 74 FX_FILESIZE limit, | 72 FX_FILESIZE limit, |
| 75 const CFX_ByteStringC& tag, | 73 const CFX_ByteStringC& tag, |
| 76 bool checkKeyword); | 74 bool checkKeyword); |
| 77 | 75 |
| 78 CFX_ByteString ReadString(); | 76 CFX_ByteString ReadString(); |
| 79 CFX_ByteString ReadHexString(); | 77 CFX_ByteString ReadHexString(); |
| 80 unsigned int ReadEOLMarkers(FX_FILESIZE pos); | 78 unsigned int ReadEOLMarkers(FX_FILESIZE pos); |
| 81 CPDF_Stream* ReadStream(CPDF_Dictionary* pDict, | 79 CPDF_Stream* ReadStream(CPDF_Dictionary* pDict, |
| 82 uint32_t objnum, | 80 uint32_t objnum, |
| 83 uint32_t gennum); | 81 uint32_t gennum); |
| 84 | 82 |
| 85 CFX_ByteString MaybeIntern(const CFX_ByteString& str); | 83 CFX_ByteString MaybeIntern(const CFX_ByteString& str); |
| 84 inline bool CheckPosition(FX_FILESIZE pos) { | |
|
Lei Zhang
2016/11/03 21:57:35
*shrug* I'm in the "let the compiler figure it out
| |
| 85 return m_BufOffset >= pos || | |
| 86 static_cast<FX_FILESIZE>(m_BufOffset + m_BufSize) <= pos; | |
| 87 } | |
| 86 | 88 |
| 87 FX_FILESIZE m_Pos; | 89 FX_FILESIZE m_Pos; |
| 88 int m_MetadataObjnum; | 90 uint32_t m_MetadataObjnum; |
| 89 IFX_SeekableReadStream* m_pFileAccess; | 91 IFX_SeekableReadStream* m_pFileAccess; |
| 90 FX_FILESIZE m_HeaderOffset; | 92 FX_FILESIZE m_HeaderOffset; |
| 91 FX_FILESIZE m_FileLen; | 93 FX_FILESIZE m_FileLen; |
| 92 uint8_t* m_pFileBuf; | 94 uint8_t* m_pFileBuf; |
| 93 uint32_t m_BufSize; | 95 uint32_t m_BufSize; |
| 94 FX_FILESIZE m_BufOffset; | 96 FX_FILESIZE m_BufOffset; |
| 95 std::unique_ptr<CPDF_CryptoHandler> m_pCryptoHandler; | 97 std::unique_ptr<CPDF_CryptoHandler> m_pCryptoHandler; |
| 96 uint8_t m_WordBuffer[257]; | 98 uint8_t m_WordBuffer[257]; |
| 97 uint32_t m_WordSize; | 99 uint32_t m_WordSize; |
| 98 CFX_WeakPtr<CFX_ByteStringPool> m_pPool; | 100 CFX_WeakPtr<CFX_ByteStringPool> m_pPool; |
| 99 }; | 101 }; |
| 100 | 102 |
| 101 #endif // CORE_FPDFAPI_PARSER_CPDF_SYNTAX_PARSER_H_ | 103 #endif // CORE_FPDFAPI_PARSER_CPDF_SYNTAX_PARSER_H_ |
| OLD | NEW |