Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: xfa/fde/xml/fde_xml_imp.h

Issue 1980223002: Revert of Replace Release() { delete this; } in fde_xml_imp.h (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « testing/libfuzzer/pdf_xml_fuzzer.cc ('k') | xfa/fde/xml/fde_xml_imp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_FDE_XML_IMP_H_ 7 #ifndef XFA_FDE_XML_FDE_XML_IMP_H_
8 #define XFA_FDE_XML_FDE_XML_IMP_H_ 8 #define XFA_FDE_XML_FDE_XML_IMP_H_
9 9
10 #include "core/fxcrt/include/fx_system.h" 10 #include "core/fxcrt/include/fx_system.h"
11 #include "xfa/fde/xml/fde_xml.h" 11 #include "xfa/fde/xml/fde_xml.h"
12 #include "xfa/fgas/crt/fgas_memory.h" 12 #include "xfa/fgas/crt/fgas_memory.h"
13 #include "xfa/fgas/crt/fgas_stream.h" 13 #include "xfa/fgas/crt/fgas_stream.h"
14 14
15 class CFDE_BlockBuffer; 15 class CFDE_BlockBuffer;
16 class CFDE_XMLInstruction; 16 class CFDE_XMLInstruction;
17 class CFDE_XMLElement; 17 class CFDE_XMLElement;
18 class CFDE_XMLText; 18 class CFDE_XMLText;
19 class CFDE_XMLDoc; 19 class CFDE_XMLDoc;
20 class CFDE_XMLDOMParser; 20 class CFDE_XMLDOMParser;
21 class CFDE_XMLParser;
21 class CFDE_XMLSAXParser; 22 class CFDE_XMLSAXParser;
22 class CFDE_XMLSyntaxParser; 23 class CFDE_XMLSyntaxParser;
23 class IFDE_XMLParser;
24 24
25 class CFDE_XMLNode : public CFX_Target { 25 class CFDE_XMLNode : public CFX_Target {
26 public: 26 public:
27 enum NodeItem { 27 enum NodeItem {
28 Root = 0, 28 Root = 0,
29 Parent, 29 Parent,
30 FirstSibling, 30 FirstSibling,
31 PriorSibling, 31 PriorSibling,
32 NextSibling, 32 NextSibling,
33 LastSibling, 33 LastSibling,
34 FirstNeighbor, 34 FirstNeighbor,
35 PriorNeighbor, 35 PriorNeighbor,
36 NextNeighbor, 36 NextNeighbor,
37 LastNeighbor, 37 LastNeighbor,
38 FirstChild, 38 FirstChild,
39 LastChild 39 LastChild
40 }; 40 };
41 41
42 CFDE_XMLNode(); 42 CFDE_XMLNode();
43 ~CFDE_XMLNode() override;
44 43
44 virtual void Release() { delete this; }
45 virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Unknown; } 45 virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Unknown; }
46 virtual int32_t CountChildNodes() const; 46 virtual int32_t CountChildNodes() const;
47 virtual CFDE_XMLNode* GetChildNode(int32_t index) const; 47 virtual CFDE_XMLNode* GetChildNode(int32_t index) const;
48 virtual int32_t GetChildNodeIndex(CFDE_XMLNode* pNode) const; 48 virtual int32_t GetChildNodeIndex(CFDE_XMLNode* pNode) const;
49 virtual CFDE_XMLNode* GetPath(const FX_WCHAR* pPath, 49 virtual CFDE_XMLNode* GetPath(const FX_WCHAR* pPath,
50 int32_t iLength = -1, 50 int32_t iLength = -1,
51 FX_BOOL bQualifiedName = TRUE) const; 51 FX_BOOL bQualifiedName = TRUE) const;
52 virtual int32_t InsertChildNode(CFDE_XMLNode* pNode, int32_t index = -1); 52 virtual int32_t InsertChildNode(CFDE_XMLNode* pNode, int32_t index = -1);
53 virtual void RemoveChildNode(CFDE_XMLNode* pNode); 53 virtual void RemoveChildNode(CFDE_XMLNode* pNode);
54 virtual void DeleteChildren(); 54 virtual void DeleteChildren();
55 virtual CFDE_XMLNode* GetNodeItem(CFDE_XMLNode::NodeItem eItem) const; 55 virtual CFDE_XMLNode* GetNodeItem(CFDE_XMLNode::NodeItem eItem) const;
56 virtual int32_t GetNodeLevel() const; 56 virtual int32_t GetNodeLevel() const;
57 virtual FX_BOOL InsertNodeItem(CFDE_XMLNode::NodeItem eItem, 57 virtual FX_BOOL InsertNodeItem(CFDE_XMLNode::NodeItem eItem,
58 CFDE_XMLNode* pNode); 58 CFDE_XMLNode* pNode);
59 virtual CFDE_XMLNode* RemoveNodeItem(CFDE_XMLNode::NodeItem eItem); 59 virtual CFDE_XMLNode* RemoveNodeItem(CFDE_XMLNode::NodeItem eItem);
60 virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); 60 virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive);
61 virtual void SaveXMLNode(IFX_Stream* pXMLStream); 61 virtual void SaveXMLNode(IFX_Stream* pXMLStream);
62 62
63 public:
64 ~CFDE_XMLNode();
63 void CloneChildren(CFDE_XMLNode* pClone); 65 void CloneChildren(CFDE_XMLNode* pClone);
64
65 CFDE_XMLNode* m_pParent; 66 CFDE_XMLNode* m_pParent;
66 CFDE_XMLNode* m_pChild; 67 CFDE_XMLNode* m_pChild;
67 CFDE_XMLNode* m_pPrior; 68 CFDE_XMLNode* m_pPrior;
68 CFDE_XMLNode* m_pNext; 69 CFDE_XMLNode* m_pNext;
69 }; 70 };
70
71 class CFDE_XMLInstruction : public CFDE_XMLNode { 71 class CFDE_XMLInstruction : public CFDE_XMLNode {
72 public: 72 public:
73 CFDE_XMLInstruction(const CFX_WideString& wsTarget); 73 CFDE_XMLInstruction(const CFX_WideString& wsTarget);
74 ~CFDE_XMLInstruction() override; 74 virtual void Release() { delete this; }
75 75 virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Instruction; }
76 FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Instruction; } 76 virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive);
77 CFDE_XMLNode* Clone(FX_BOOL bRecursive) override;
78
79 virtual void GetTargetName(CFX_WideString& wsTarget) const { 77 virtual void GetTargetName(CFX_WideString& wsTarget) const {
80 wsTarget = m_wsTarget; 78 wsTarget = m_wsTarget;
81 } 79 }
82 virtual int32_t CountAttributes() const; 80 virtual int32_t CountAttributes() const;
83 virtual FX_BOOL GetAttribute(int32_t index, 81 virtual FX_BOOL GetAttribute(int32_t index,
84 CFX_WideString& wsAttriName, 82 CFX_WideString& wsAttriName,
85 CFX_WideString& wsAttriValue) const; 83 CFX_WideString& wsAttriValue) const;
86 virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const; 84 virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const;
87 virtual void GetString(const FX_WCHAR* pwsAttriName, 85 virtual void GetString(const FX_WCHAR* pwsAttriName,
88 CFX_WideString& wsAttriValue, 86 CFX_WideString& wsAttriValue,
89 const FX_WCHAR* pwsDefValue = NULL) const; 87 const FX_WCHAR* pwsDefValue = NULL) const;
90 virtual void SetString(const CFX_WideString& wsAttriName, 88 virtual void SetString(const CFX_WideString& wsAttriName,
91 const CFX_WideString& wsAttriValue); 89 const CFX_WideString& wsAttriValue);
92 virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName, 90 virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName,
93 int32_t iDefValue = 0) const; 91 int32_t iDefValue = 0) const;
94 virtual void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue); 92 virtual void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue);
95 virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, 93 virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName,
96 FX_FLOAT fDefValue = 0) const; 94 FX_FLOAT fDefValue = 0) const;
97 virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue); 95 virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue);
98 virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName); 96 virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName);
99 virtual int32_t CountData() const; 97 virtual int32_t CountData() const;
100 virtual FX_BOOL GetData(int32_t index, CFX_WideString& wsData) const; 98 virtual FX_BOOL GetData(int32_t index, CFX_WideString& wsData) const;
101 virtual void AppendData(const CFX_WideString& wsData); 99 virtual void AppendData(const CFX_WideString& wsData);
102 virtual void RemoveData(int32_t index); 100 virtual void RemoveData(int32_t index);
103 101
102 public:
103 ~CFDE_XMLInstruction() {}
104 CFX_WideString m_wsTarget; 104 CFX_WideString m_wsTarget;
105 CFX_WideStringArray m_Attributes; 105 CFX_WideStringArray m_Attributes;
106 CFX_WideStringArray m_TargetData; 106 CFX_WideStringArray m_TargetData;
107 }; 107 };
108
109 class CFDE_XMLElement : public CFDE_XMLNode { 108 class CFDE_XMLElement : public CFDE_XMLNode {
110 public: 109 public:
111 CFDE_XMLElement(const CFX_WideString& wsTag); 110 CFDE_XMLElement(const CFX_WideString& wsTag);
112 ~CFDE_XMLElement() override; 111 virtual void Release() { delete this; }
113 112 virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Element; }
114 FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Element; } 113 virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive);
115 CFDE_XMLNode* Clone(FX_BOOL bRecursive) override;
116
117 virtual void GetTagName(CFX_WideString& wsTag) const; 114 virtual void GetTagName(CFX_WideString& wsTag) const;
118 virtual void GetLocalTagName(CFX_WideString& wsTag) const; 115 virtual void GetLocalTagName(CFX_WideString& wsTag) const;
119 virtual void GetNamespacePrefix(CFX_WideString& wsPrefix) const; 116 virtual void GetNamespacePrefix(CFX_WideString& wsPrefix) const;
120 virtual void GetNamespaceURI(CFX_WideString& wsNamespace) const; 117 virtual void GetNamespaceURI(CFX_WideString& wsNamespace) const;
121 virtual int32_t CountAttributes() const; 118 virtual int32_t CountAttributes() const;
122 virtual FX_BOOL GetAttribute(int32_t index, 119 virtual FX_BOOL GetAttribute(int32_t index,
123 CFX_WideString& wsAttriName, 120 CFX_WideString& wsAttriName,
124 CFX_WideString& wsAttriValue) const; 121 CFX_WideString& wsAttriValue) const;
125 virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const; 122 virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const;
126 virtual void GetString(const FX_WCHAR* pwsAttriName, 123 virtual void GetString(const FX_WCHAR* pwsAttriName,
127 CFX_WideString& wsAttriValue, 124 CFX_WideString& wsAttriValue,
128 const FX_WCHAR* pwsDefValue = NULL) const; 125 const FX_WCHAR* pwsDefValue = NULL) const;
129 virtual void SetString(const CFX_WideString& wsAttriName, 126 virtual void SetString(const CFX_WideString& wsAttriName,
130 const CFX_WideString& wsAttriValue); 127 const CFX_WideString& wsAttriValue);
131 virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName, 128 virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName,
132 int32_t iDefValue = 0) const; 129 int32_t iDefValue = 0) const;
133 virtual void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue); 130 virtual void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue);
134 virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, 131 virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName,
135 FX_FLOAT fDefValue = 0) const; 132 FX_FLOAT fDefValue = 0) const;
136 virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue); 133 virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue);
137 virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName); 134 virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName);
138 virtual void GetTextData(CFX_WideString& wsText) const; 135 virtual void GetTextData(CFX_WideString& wsText) const;
139 virtual void SetTextData(const CFX_WideString& wsText); 136 virtual void SetTextData(const CFX_WideString& wsText);
140 137
138 public:
139 ~CFDE_XMLElement();
141 CFX_WideString m_wsTag; 140 CFX_WideString m_wsTag;
142 CFX_WideStringArray m_Attributes; 141 CFX_WideStringArray m_Attributes;
143 }; 142 };
144
145 class CFDE_XMLText : public CFDE_XMLNode { 143 class CFDE_XMLText : public CFDE_XMLNode {
146 public: 144 public:
147 CFDE_XMLText(const CFX_WideString& wsText); 145 CFDE_XMLText(const CFX_WideString& wsText);
148 ~CFDE_XMLText() override; 146 virtual void Release() { delete this; }
149 147 virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Text; }
150 FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Text; } 148 virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive);
151 CFDE_XMLNode* Clone(FX_BOOL bRecursive) override;
152
153 virtual void GetText(CFX_WideString& wsText) const { wsText = m_wsText; } 149 virtual void GetText(CFX_WideString& wsText) const { wsText = m_wsText; }
154 virtual void SetText(const CFX_WideString& wsText) { m_wsText = wsText; } 150 virtual void SetText(const CFX_WideString& wsText) { m_wsText = wsText; }
155 151
152 public:
153 ~CFDE_XMLText() {}
156 CFX_WideString m_wsText; 154 CFX_WideString m_wsText;
157 }; 155 };
158
159 class CFDE_XMLDeclaration : public CFDE_XMLNode { 156 class CFDE_XMLDeclaration : public CFDE_XMLNode {
160 public: 157 public:
161 CFDE_XMLDeclaration() : CFDE_XMLNode() {} 158 CFDE_XMLDeclaration() : CFDE_XMLNode() {}
162 }; 159 };
163
164 class CFDE_XMLCharData : public CFDE_XMLDeclaration { 160 class CFDE_XMLCharData : public CFDE_XMLDeclaration {
165 public: 161 public:
166 CFDE_XMLCharData(const CFX_WideString& wsCData); 162 CFDE_XMLCharData(const CFX_WideString& wsCData);
167 ~CFDE_XMLCharData() override;
168 163
169 FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_CharData; } 164 virtual void Release() { delete this; }
170 CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; 165 virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_CharData; }
171 166 virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive);
172 virtual void GetCharData(CFX_WideString& wsCharData) const { 167 virtual void GetCharData(CFX_WideString& wsCharData) const {
173 wsCharData = m_wsCharData; 168 wsCharData = m_wsCharData;
174 } 169 }
175 virtual void SetCharData(const CFX_WideString& wsCData) { 170 virtual void SetCharData(const CFX_WideString& wsCData) {
176 m_wsCharData = wsCData; 171 m_wsCharData = wsCData;
177 } 172 }
178 173
174 public:
175 ~CFDE_XMLCharData() {}
176
179 CFX_WideString m_wsCharData; 177 CFX_WideString m_wsCharData;
180 }; 178 };
181
182 class CFDE_XMLDoc : public CFX_Target { 179 class CFDE_XMLDoc : public CFX_Target {
183 public: 180 public:
184 CFDE_XMLDoc(); 181 CFDE_XMLDoc();
185 ~CFDE_XMLDoc() override; 182 ~CFDE_XMLDoc();
186 183 virtual void Release() { delete this; }
187 virtual FX_BOOL LoadXML(IFX_Stream* pXMLStream, 184 virtual FX_BOOL LoadXML(IFX_Stream* pXMLStream,
188 int32_t iXMLPlaneSize = 8192, 185 int32_t iXMLPlaneSize = 8192,
189 int32_t iTextDataSize = 256, 186 int32_t iTextDataSize = 256,
190 FDE_XMLREADERHANDLER* pHandler = NULL); 187 FDE_XMLREADERHANDLER* pHandler = NULL);
191 virtual FX_BOOL LoadXML(IFDE_XMLParser* pXMLParser); 188 virtual FX_BOOL LoadXML(CFDE_XMLParser* pXMLParser);
192 virtual int32_t DoLoad(IFX_Pause* pPause = NULL); 189 virtual int32_t DoLoad(IFX_Pause* pPause = NULL);
193 virtual void CloseXML(); 190 virtual void CloseXML();
194 virtual CFDE_XMLNode* GetRoot() const { return m_pRoot; } 191 virtual CFDE_XMLNode* GetRoot() const { return m_pRoot; }
195 virtual void SaveXML(IFX_Stream* pXMLStream = NULL, FX_BOOL bSaveBOM = TRUE); 192 virtual void SaveXML(IFX_Stream* pXMLStream = NULL, FX_BOOL bSaveBOM = TRUE);
196 virtual void SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pNode); 193 virtual void SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pNode);
197 194
198 protected: 195 protected:
199 IFX_Stream* m_pStream; 196 IFX_Stream* m_pStream;
200 int32_t m_iStatus; 197 int32_t m_iStatus;
201 CFDE_XMLNode* m_pRoot; 198 CFDE_XMLNode* m_pRoot;
202 CFDE_XMLSyntaxParser* m_pSyntaxParser; 199 CFDE_XMLSyntaxParser* m_pSyntaxParser;
203 IFDE_XMLParser* m_pXMLParser; 200 CFDE_XMLParser* m_pXMLParser;
204 void Reset(FX_BOOL bInitRoot); 201 void Reset(FX_BOOL bInitRoot);
205 void ReleaseParser(); 202 void ReleaseParser();
206 }; 203 };
207 typedef CFX_StackTemplate<CFDE_XMLNode*> CFDE_XMLDOMNodeStack; 204 typedef CFX_StackTemplate<CFDE_XMLNode*> CFDE_XMLDOMNodeStack;
208 205
209 class IFDE_XMLParser { 206 class CFDE_XMLParser {
210 public: 207 public:
211 virtual ~IFDE_XMLParser() {} 208 virtual ~CFDE_XMLParser() {}
212 209
210 virtual void Release() = 0;
213 virtual int32_t DoParser(IFX_Pause* pPause) = 0; 211 virtual int32_t DoParser(IFX_Pause* pPause) = 0;
214 }; 212 };
215 213
216 class CFDE_XMLDOMParser : public IFDE_XMLParser, public CFX_Target { 214 class CFDE_XMLDOMParser : public CFDE_XMLParser, public CFX_Target {
217 public: 215 public:
218 CFDE_XMLDOMParser(CFDE_XMLNode* pRoot, CFDE_XMLSyntaxParser* pParser); 216 CFDE_XMLDOMParser(CFDE_XMLNode* pRoot, CFDE_XMLSyntaxParser* pParser);
219 ~CFDE_XMLDOMParser() override; 217 ~CFDE_XMLDOMParser();
220 218
221 int32_t DoParser(IFX_Pause* pPause) override; 219 virtual void Release() { delete this; }
220 virtual int32_t DoParser(IFX_Pause* pPause);
222 221
223 private: 222 private:
224 CFDE_XMLSyntaxParser* m_pParser; 223 CFDE_XMLSyntaxParser* m_pParser;
225 CFDE_XMLNode* m_pParent; 224 CFDE_XMLNode* m_pParent;
226 CFDE_XMLNode* m_pChild; 225 CFDE_XMLNode* m_pChild;
227 CFDE_XMLDOMNodeStack m_NodeStack; 226 CFDE_XMLDOMNodeStack m_NodeStack;
228 CFX_WideString m_ws1; 227 CFX_WideString m_ws1;
229 CFX_WideString m_ws2; 228 CFX_WideString m_ws2;
230 }; 229 };
231 class CFDE_XMLTAG : public CFX_Target { 230 class CFDE_XMLTAG : public CFX_Target {
232 public: 231 public:
233 CFDE_XMLTAG() : eType(FDE_XMLNODE_Unknown) {} 232 CFDE_XMLTAG() : eType(FDE_XMLNODE_Unknown) {}
234 CFDE_XMLTAG(const CFDE_XMLTAG& src) 233 CFDE_XMLTAG(const CFDE_XMLTAG& src)
235 : wsTagName(src.wsTagName), eType(src.eType) {} 234 : wsTagName(src.wsTagName), eType(src.eType) {}
236 CFX_WideString wsTagName; 235 CFX_WideString wsTagName;
237 FDE_XMLNODETYPE eType; 236 FDE_XMLNODETYPE eType;
238 }; 237 };
239 typedef CFX_ObjectStackTemplate<CFDE_XMLTAG> CFDE_XMLTagStack; 238 typedef CFX_ObjectStackTemplate<CFDE_XMLTAG> CFDE_XMLTagStack;
240 239 class CFDE_XMLSAXParser : public CFDE_XMLParser, public CFX_Target {
241 class CFDE_XMLSAXParser : public IFDE_XMLParser, public CFX_Target {
242 public: 240 public:
243 CFDE_XMLSAXParser(FDE_XMLREADERHANDLER* pHandler, 241 CFDE_XMLSAXParser(FDE_XMLREADERHANDLER* pHandler,
244 CFDE_XMLSyntaxParser* pParser); 242 CFDE_XMLSyntaxParser* pParser);
245 ~CFDE_XMLSAXParser() override; 243 ~CFDE_XMLSAXParser();
246 244
247 int32_t DoParser(IFX_Pause* pPause) override; 245 virtual void Release() { delete this; }
246 virtual int32_t DoParser(IFX_Pause* pPause);
248 247
249 private: 248 private:
250 void Push(const CFDE_XMLTAG& xmlTag); 249 void Push(const CFDE_XMLTAG& xmlTag);
251 void Pop(); 250 void Pop();
252 FDE_XMLREADERHANDLER* m_pHandler; 251 FDE_XMLREADERHANDLER* m_pHandler;
253 CFDE_XMLSyntaxParser* m_pParser; 252 CFDE_XMLSyntaxParser* m_pParser;
254 CFDE_XMLTagStack m_TagStack; 253 CFDE_XMLTagStack m_TagStack;
255 CFDE_XMLTAG* m_pTagTop; 254 CFDE_XMLTAG* m_pTagTop;
256 CFX_WideString m_ws1; 255 CFX_WideString m_ws1;
257 CFX_WideString m_ws2; 256 CFX_WideString m_ws2;
258 }; 257 };
259 258
260 class CFDE_BlockBuffer : public CFX_Target { 259 class CFDE_BlockBuffer : public CFX_Target {
261 public: 260 public:
262 CFDE_BlockBuffer(int32_t iAllocStep = 1024 * 1024); 261 CFDE_BlockBuffer(int32_t iAllocStep = 1024 * 1024);
263 ~CFDE_BlockBuffer() override; 262 ~CFDE_BlockBuffer();
264 263
265 FX_BOOL InitBuffer(int32_t iBufferSize = 1024 * 1024); 264 FX_BOOL InitBuffer(int32_t iBufferSize = 1024 * 1024);
266 FX_BOOL IsInitialized() { return m_iBufferSize / m_iAllocStep >= 1; } 265 FX_BOOL IsInitialized() { return m_iBufferSize / m_iAllocStep >= 1; }
267 266 void ReleaseBuffer() { delete this; }
268 FX_WCHAR* GetAvailableBlock(int32_t& iIndexInBlock); 267 FX_WCHAR* GetAvailableBlock(int32_t& iIndexInBlock);
269 inline int32_t GetAllocStep() const { return m_iAllocStep; } 268 inline int32_t GetAllocStep() const { return m_iAllocStep; }
270 inline int32_t& GetDataLengthRef() { return m_iDataLength; } 269 inline int32_t& GetDataLengthRef() { return m_iDataLength; }
271 inline void Reset(FX_BOOL bReserveData = TRUE) { 270 inline void Reset(FX_BOOL bReserveData = TRUE) {
272 if (!bReserveData) { 271 if (!bReserveData) {
273 m_iStartPosition = 0; 272 m_iStartPosition = 0;
274 } 273 }
275 m_iDataLength = 0; 274 m_iDataLength = 0;
276 } 275 }
277 void SetTextChar(int32_t iIndex, FX_WCHAR ch); 276 void SetTextChar(int32_t iIndex, FX_WCHAR ch);
(...skipping 10 matching lines...) Expand all
288 CFX_ArrayTemplate<FX_WCHAR*> m_BlockArray; 287 CFX_ArrayTemplate<FX_WCHAR*> m_BlockArray;
289 int32_t m_iDataLength; 288 int32_t m_iDataLength;
290 int32_t m_iBufferSize; 289 int32_t m_iBufferSize;
291 int32_t m_iAllocStep; 290 int32_t m_iAllocStep;
292 int32_t m_iStartPosition; 291 int32_t m_iStartPosition;
293 }; 292 };
294 293
295 class CFDE_XMLSyntaxParser : public CFX_Target { 294 class CFDE_XMLSyntaxParser : public CFX_Target {
296 public: 295 public:
297 CFDE_XMLSyntaxParser(); 296 CFDE_XMLSyntaxParser();
298 ~CFDE_XMLSyntaxParser() override; 297 ~CFDE_XMLSyntaxParser();
299 298 void Release() { delete this; }
300 void Init(IFX_Stream* pStream, 299 void Init(IFX_Stream* pStream,
301 int32_t iXMLPlaneSize, 300 int32_t iXMLPlaneSize,
302 int32_t iTextDataSize = 256); 301 int32_t iTextDataSize = 256);
303 FDE_XmlSyntaxResult DoSyntaxParse(); 302 FDE_XmlSyntaxResult DoSyntaxParse();
304 int32_t GetStatus() const; 303 int32_t GetStatus() const;
305 int32_t GetCurrentPos() const { 304 int32_t GetCurrentPos() const {
306 return m_iParsedChars + (m_pStart - m_pBuffer); 305 return m_iParsedChars + (m_pStart - m_pBuffer);
307 } 306 }
308 FX_FILESIZE GetCurrentBinaryPos() const; 307 FX_FILESIZE GetCurrentBinaryPos() const;
309 int32_t GetCurrentNodeNumber() const { return m_iCurrentNodeNum; } 308 int32_t GetCurrentNodeNumber() const { return m_iCurrentNodeNum; }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 FDE_XmlSyntaxResult m_syntaxParserResult; 374 FDE_XmlSyntaxResult m_syntaxParserResult;
376 FDE_XmlSyntaxState m_syntaxParserState; 375 FDE_XmlSyntaxState m_syntaxParserState;
377 FX_WCHAR m_wQuotationMark; 376 FX_WCHAR m_wQuotationMark;
378 int32_t m_iEntityStart; 377 int32_t m_iEntityStart;
379 CFX_DWordStack m_SkipStack; 378 CFX_DWordStack m_SkipStack;
380 FX_WCHAR m_SkipChar; 379 FX_WCHAR m_SkipChar;
381 inline void ParseTextChar(FX_WCHAR ch); 380 inline void ParseTextChar(FX_WCHAR ch);
382 }; 381 };
383 382
384 #endif // XFA_FDE_XML_FDE_XML_IMP_H_ 383 #endif // XFA_FDE_XML_FDE_XML_IMP_H_
OLDNEW
« no previous file with comments | « testing/libfuzzer/pdf_xml_fuzzer.cc ('k') | xfa/fde/xml/fde_xml_imp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698