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