| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 XFA_FDE_XML_CFX_SAXREADER_H_ | 7 #ifndef XFA_FDE_XML_CFX_SAXREADER_H_ |
| 8 #define XFA_FDE_XML_CFX_SAXREADER_H_ | 8 #define XFA_FDE_XML_CFX_SAXREADER_H_ |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <stack> | 11 #include <stack> |
| 12 | 12 |
| 13 #include "core/fxcrt/fx_basic.h" | 13 #include "core/fxcrt/fx_basic.h" |
| 14 | 14 |
| 15 class CXFA_SAXContext; | 15 class CXFA_SAXContext; |
| 16 | 16 |
| 17 class CFX_SAXItem { | 17 class CFX_SAXItem { |
| 18 public: | 18 public: |
| 19 enum class Type { | 19 enum class Type { |
| 20 Unknown = 0, | 20 Unknown = 0, |
| 21 Instruction, | 21 Instruction, |
| 22 Declaration, | 22 Declaration, |
| 23 Comment, | 23 Comment, |
| 24 Tag, | 24 Tag, |
| 25 Text, | 25 Text, |
| 26 CharData, | 26 CharData, |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 explicit CFX_SAXItem(uint32_t id) | 29 explicit CFX_SAXItem(uint32_t id) |
| 30 : m_pNode(nullptr), m_eNode(Type::Unknown), m_dwID(id), m_bSkip(FALSE) {} | 30 : m_pNode(nullptr), m_eNode(Type::Unknown), m_dwID(id), m_bSkip(false) {} |
| 31 | 31 |
| 32 CXFA_SAXContext* m_pNode; | 32 CXFA_SAXContext* m_pNode; |
| 33 Type m_eNode; | 33 Type m_eNode; |
| 34 const uint32_t m_dwID; | 34 const uint32_t m_dwID; |
| 35 FX_BOOL m_bSkip; | 35 bool m_bSkip; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 class CFX_SAXFile { | 38 class CFX_SAXFile { |
| 39 public: | 39 public: |
| 40 CFX_SAXFile(); | 40 CFX_SAXFile(); |
| 41 FX_BOOL StartFile(IFX_SeekableReadStream* pFile, | 41 bool StartFile(IFX_SeekableReadStream* pFile, |
| 42 uint32_t dwStart, | 42 uint32_t dwStart, |
| 43 uint32_t dwLen); | 43 uint32_t dwLen); |
| 44 FX_BOOL ReadNextBlock(); | 44 bool ReadNextBlock(); |
| 45 void Reset(); | 45 void Reset(); |
| 46 IFX_SeekableReadStream* m_pFile; | 46 IFX_SeekableReadStream* m_pFile; |
| 47 uint32_t m_dwStart; | 47 uint32_t m_dwStart; |
| 48 uint32_t m_dwEnd; | 48 uint32_t m_dwEnd; |
| 49 uint32_t m_dwCur; | 49 uint32_t m_dwCur; |
| 50 uint8_t* m_pBuf; | 50 uint8_t* m_pBuf; |
| 51 uint32_t m_dwBufSize; | 51 uint32_t m_dwBufSize; |
| 52 uint32_t m_dwBufIndex; | 52 uint32_t m_dwBufIndex; |
| 53 }; | 53 }; |
| 54 | 54 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 void ParseMaybeClose(); | 95 void ParseMaybeClose(); |
| 96 void ParseTagClose(); | 96 void ParseTagClose(); |
| 97 void ParseTagEnd(); | 97 void ParseTagEnd(); |
| 98 void ParseTargetData(); | 98 void ParseTargetData(); |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 void Reset(); | 101 void Reset(); |
| 102 void Push(); | 102 void Push(); |
| 103 void Pop(); | 103 void Pop(); |
| 104 CFX_SAXItem* GetCurrentItem() const; | 104 CFX_SAXItem* GetCurrentItem() const; |
| 105 FX_BOOL SkipSpace(uint8_t ch); | 105 bool SkipSpace(uint8_t ch); |
| 106 void SkipNode(); | 106 void SkipNode(); |
| 107 void NotifyData(); | 107 void NotifyData(); |
| 108 void NotifyEnter(); | 108 void NotifyEnter(); |
| 109 void NotifyAttribute(); | 109 void NotifyAttribute(); |
| 110 void NotifyBreak(); | 110 void NotifyBreak(); |
| 111 void NotifyClose(); | 111 void NotifyClose(); |
| 112 void NotifyEnd(); | 112 void NotifyEnd(); |
| 113 void NotifyTargetData(); | 113 void NotifyTargetData(); |
| 114 void ReallocDataBuffer(); | 114 void ReallocDataBuffer(); |
| 115 void ReallocNameBuffer(); | 115 void ReallocNameBuffer(); |
| 116 void ParseChar(uint8_t ch); | 116 void ParseChar(uint8_t ch); |
| 117 | 117 |
| 118 CFX_SAXFile m_File; | 118 CFX_SAXFile m_File; |
| 119 CXFA_SAXReaderHandler* m_pHandler; | 119 CXFA_SAXReaderHandler* m_pHandler; |
| 120 int32_t m_iState; | 120 int32_t m_iState; |
| 121 std::stack<std::unique_ptr<CFX_SAXItem>> m_Stack; | 121 std::stack<std::unique_ptr<CFX_SAXItem>> m_Stack; |
| 122 uint32_t m_dwItemID; | 122 uint32_t m_dwItemID; |
| 123 CFX_SaxMode m_eMode; | 123 CFX_SaxMode m_eMode; |
| 124 CFX_SaxMode m_ePrevMode; | 124 CFX_SaxMode m_ePrevMode; |
| 125 FX_BOOL m_bCharData; | 125 bool m_bCharData; |
| 126 uint8_t m_CurByte; | 126 uint8_t m_CurByte; |
| 127 uint32_t m_dwDataOffset; | 127 uint32_t m_dwDataOffset; |
| 128 CFX_ByteArray m_SkipStack; | 128 CFX_ByteArray m_SkipStack; |
| 129 uint8_t m_SkipChar; | 129 uint8_t m_SkipChar; |
| 130 uint32_t m_dwNodePos; | 130 uint32_t m_dwNodePos; |
| 131 uint8_t* m_pszData; | 131 uint8_t* m_pszData; |
| 132 int32_t m_iDataSize; | 132 int32_t m_iDataSize; |
| 133 int32_t m_iDataLength; | 133 int32_t m_iDataLength; |
| 134 int32_t m_iEntityStart; | 134 int32_t m_iEntityStart; |
| 135 int32_t m_iDataPos; | 135 int32_t m_iDataPos; |
| 136 uint8_t* m_pszName; | 136 uint8_t* m_pszName; |
| 137 int32_t m_iNameSize; | 137 int32_t m_iNameSize; |
| 138 int32_t m_iNameLength; | 138 int32_t m_iNameLength; |
| 139 uint32_t m_dwParseMode; | 139 uint32_t m_dwParseMode; |
| 140 CFX_SAXCommentContext* m_pCommentContext; | 140 CFX_SAXCommentContext* m_pCommentContext; |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 #endif // XFA_FDE_XML_CFX_SAXREADER_H_ | 143 #endif // XFA_FDE_XML_CFX_SAXREADER_H_ |
| OLD | NEW |