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

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

Issue 2072803002: Make code compile with clang_use_chrome_plugin (final) (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: tidy Created 4 years, 6 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
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"
(...skipping 22 matching lines...) Expand all
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 virtual ~CFDE_XMLNode(); 43 ~CFDE_XMLNode() override;
44 44
45 virtual void Release() { delete this; } 45 virtual void Release();
46 virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Unknown; } 46 virtual FDE_XMLNODETYPE GetType() const;
47 virtual int32_t CountChildNodes() const;
48 virtual CFDE_XMLNode* GetChildNode(int32_t index) const;
49 virtual int32_t GetChildNodeIndex(CFDE_XMLNode* pNode) const;
Lei Zhang 2016/06/17 03:10:05 Why are these virtual now?
Wei Li 2016/06/17 21:47:45 Rebase madness :( Thanks for spotting this.
50 virtual CFDE_XMLNode* GetPath(const FX_WCHAR* pPath,
51 int32_t iLength = -1,
52 FX_BOOL bQualifiedName = TRUE) const;
53 virtual int32_t InsertChildNode(CFDE_XMLNode* pNode, int32_t index = -1);
54 virtual void RemoveChildNode(CFDE_XMLNode* pNode);
55 virtual void DeleteChildren();
56 virtual CFDE_XMLNode* GetNodeItem(CFDE_XMLNode::NodeItem eItem) const;
57 virtual int32_t GetNodeLevel() const;
58 virtual FX_BOOL InsertNodeItem(CFDE_XMLNode::NodeItem eItem,
59 CFDE_XMLNode* pNode);
60 virtual CFDE_XMLNode* RemoveNodeItem(CFDE_XMLNode::NodeItem eItem);
47 virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); 61 virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive);
48 62
49 int32_t CountChildNodes() const;
50 CFDE_XMLNode* GetChildNode(int32_t index) const;
51 int32_t GetChildNodeIndex(CFDE_XMLNode* pNode) const;
52 int32_t InsertChildNode(CFDE_XMLNode* pNode, int32_t index = -1);
53 void RemoveChildNode(CFDE_XMLNode* pNode);
54 void DeleteChildren();
55 void CloneChildren(CFDE_XMLNode* pClone); 63 void CloneChildren(CFDE_XMLNode* pClone);
56
57 CFDE_XMLNode* GetPath(const FX_WCHAR* pPath,
58 int32_t iLength = -1,
59 FX_BOOL bQualifiedName = TRUE) const;
60
61 int32_t GetNodeLevel() const;
62 CFDE_XMLNode* GetNodeItem(CFDE_XMLNode::NodeItem eItem) const;
63 FX_BOOL InsertNodeItem(CFDE_XMLNode::NodeItem eItem, CFDE_XMLNode* pNode);
64 CFDE_XMLNode* RemoveNodeItem(CFDE_XMLNode::NodeItem eItem);
65
66 void SaveXMLNode(IFX_Stream* pXMLStream); 64 void SaveXMLNode(IFX_Stream* pXMLStream);
67 65
68 CFDE_XMLNode* m_pParent; 66 CFDE_XMLNode* m_pParent;
69 CFDE_XMLNode* m_pChild; 67 CFDE_XMLNode* m_pChild;
70 CFDE_XMLNode* m_pPrior; 68 CFDE_XMLNode* m_pPrior;
71 CFDE_XMLNode* m_pNext; 69 CFDE_XMLNode* m_pNext;
72 }; 70 };
73 71
74 class CFDE_XMLInstruction : public CFDE_XMLNode { 72 class CFDE_XMLInstruction : public CFDE_XMLNode {
75 public: 73 public:
76 CFDE_XMLInstruction(const CFX_WideString& wsTarget); 74 CFDE_XMLInstruction(const CFX_WideString& wsTarget);
77 ~CFDE_XMLInstruction() override {} 75 ~CFDE_XMLInstruction() override;
78 76
79 // CFDE_XMLNode 77 // CFDE_XMLNode
80 void Release() override { delete this; } 78 void Release() override;
81 FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Instruction; } 79 FDE_XMLNODETYPE GetType() const override;
82 CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; 80 CFDE_XMLNode* Clone(FX_BOOL bRecursive) override;
83 81
84 void GetTargetName(CFX_WideString& wsTarget) const { wsTarget = m_wsTarget; } 82 virtual void GetTargetName(CFX_WideString& wsTarget) const;
Lei Zhang 2016/06/17 03:10:05 Ditto
Wei Li 2016/06/17 21:47:45 Done.
85 int32_t CountAttributes() const; 83 virtual int32_t CountAttributes() const;
86 FX_BOOL GetAttribute(int32_t index, 84 virtual FX_BOOL GetAttribute(int32_t index,
87 CFX_WideString& wsAttriName, 85 CFX_WideString& wsAttriName,
88 CFX_WideString& wsAttriValue) const; 86 CFX_WideString& wsAttriValue) const;
89 FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const; 87 virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const;
90 void GetString(const FX_WCHAR* pwsAttriName, 88 virtual void GetString(const FX_WCHAR* pwsAttriName,
91 CFX_WideString& wsAttriValue, 89 CFX_WideString& wsAttriValue,
92 const FX_WCHAR* pwsDefValue = nullptr) const; 90 const FX_WCHAR* pwsDefValue = nullptr) const;
93 void SetString(const CFX_WideString& wsAttriName, 91 virtual void SetString(const CFX_WideString& wsAttriName,
94 const CFX_WideString& wsAttriValue); 92 const CFX_WideString& wsAttriValue);
95 int32_t GetInteger(const FX_WCHAR* pwsAttriName, int32_t iDefValue = 0) const; 93 virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName,
96 void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue); 94 int32_t iDefValue = 0) const;
97 FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fDefValue = 0) const; 95 virtual void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue);
98 void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue); 96 virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName,
99 void RemoveAttribute(const FX_WCHAR* pwsAttriName); 97 FX_FLOAT fDefValue = 0) const;
100 int32_t CountData() const; 98 virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue);
101 FX_BOOL GetData(int32_t index, CFX_WideString& wsData) const; 99 virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName);
102 void AppendData(const CFX_WideString& wsData); 100 virtual int32_t CountData() const;
103 void RemoveData(int32_t index); 101 virtual FX_BOOL GetData(int32_t index, CFX_WideString& wsData) const;
102 virtual void AppendData(const CFX_WideString& wsData);
103 virtual void RemoveData(int32_t index);
104 104
105 CFX_WideString m_wsTarget; 105 CFX_WideString m_wsTarget;
106 CFX_WideStringArray m_Attributes; 106 CFX_WideStringArray m_Attributes;
107 CFX_WideStringArray m_TargetData; 107 CFX_WideStringArray m_TargetData;
108 }; 108 };
109 109
110 class CFDE_XMLElement : public CFDE_XMLNode { 110 class CFDE_XMLElement : public CFDE_XMLNode {
111 public: 111 public:
112 CFDE_XMLElement(const CFX_WideString& wsTag); 112 CFDE_XMLElement(const CFX_WideString& wsTag);
113 ~CFDE_XMLElement() override; 113 ~CFDE_XMLElement() override;
114 114
115 // CFDE_XMLNode 115 // CFDE_XMLNode
116 void Release() override { delete this; } 116 void Release() override;
117 FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Element; } 117 FDE_XMLNODETYPE GetType() const override;
118 CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; 118 CFDE_XMLNode* Clone(FX_BOOL bRecursive) override;
119 119
120 void GetTagName(CFX_WideString& wsTag) const; 120 virtual void GetTagName(CFX_WideString& wsTag) const;
Lei Zhang 2016/06/17 03:10:05 Ditto ditto, and more below.
Wei Li 2016/06/17 21:47:45 Done.
121 void GetLocalTagName(CFX_WideString& wsTag) const; 121 virtual void GetLocalTagName(CFX_WideString& wsTag) const;
122 122 virtual void GetNamespacePrefix(CFX_WideString& wsPrefix) const;
123 void GetNamespacePrefix(CFX_WideString& wsPrefix) const; 123 virtual void GetNamespaceURI(CFX_WideString& wsNamespace) const;
124 void GetNamespaceURI(CFX_WideString& wsNamespace) const; 124 virtual int32_t CountAttributes() const;
125 125 virtual FX_BOOL GetAttribute(int32_t index,
126 int32_t CountAttributes() const; 126 CFX_WideString& wsAttriName,
127 FX_BOOL GetAttribute(int32_t index, 127 CFX_WideString& wsAttriValue) const;
128 CFX_WideString& wsAttriName, 128 virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const;
129 CFX_WideString& wsAttriValue) const; 129 virtual void GetString(const FX_WCHAR* pwsAttriName,
130 FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const; 130 CFX_WideString& wsAttriValue,
131 void RemoveAttribute(const FX_WCHAR* pwsAttriName); 131 const FX_WCHAR* pwsDefValue = nullptr) const;
132 132 virtual void SetString(const CFX_WideString& wsAttriName,
133 void GetString(const FX_WCHAR* pwsAttriName, 133 const CFX_WideString& wsAttriValue);
134 CFX_WideString& wsAttriValue, 134 virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName,
135 const FX_WCHAR* pwsDefValue = nullptr) const; 135 int32_t iDefValue = 0) const;
136 void SetString(const CFX_WideString& wsAttriName, 136 virtual void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue);
137 const CFX_WideString& wsAttriValue); 137 virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName,
138 138 FX_FLOAT fDefValue = 0) const;
139 int32_t GetInteger(const FX_WCHAR* pwsAttriName, int32_t iDefValue = 0) const; 139 virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue);
140 void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue); 140 virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName);
141 141 virtual void GetTextData(CFX_WideString& wsText) const;
142 FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fDefValue = 0) const; 142 virtual void SetTextData(const CFX_WideString& wsText);
143 void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue);
144
145 void GetTextData(CFX_WideString& wsText) const;
146 void SetTextData(const CFX_WideString& wsText);
147 143
148 CFX_WideString m_wsTag; 144 CFX_WideString m_wsTag;
149 CFX_WideStringArray m_Attributes; 145 CFX_WideStringArray m_Attributes;
150 }; 146 };
151 147
152 class CFDE_XMLText : public CFDE_XMLNode { 148 class CFDE_XMLText : public CFDE_XMLNode {
153 public: 149 public:
154 CFDE_XMLText(const CFX_WideString& wsText); 150 CFDE_XMLText(const CFX_WideString& wsText);
155 ~CFDE_XMLText() override {} 151 ~CFDE_XMLText() override;
156 152
157 // CFDE_XMLNode 153 // CFDE_XMLNode
158 void Release() override { delete this; } 154 void Release() override;
159 FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Text; } 155 FDE_XMLNODETYPE GetType() const override;
160 CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; 156 CFDE_XMLNode* Clone(FX_BOOL bRecursive) override;
161 157
162 void GetText(CFX_WideString& wsText) const { wsText = m_wsText; } 158 virtual void GetText(CFX_WideString& wsText) const;
163 void SetText(const CFX_WideString& wsText) { m_wsText = wsText; } 159 virtual void SetText(const CFX_WideString& wsText);
164 160
165 CFX_WideString m_wsText; 161 CFX_WideString m_wsText;
166 }; 162 };
167 163
168 class CFDE_XMLDeclaration : public CFDE_XMLNode { 164 class CFDE_XMLDeclaration : public CFDE_XMLNode {
169 public: 165 public:
170 CFDE_XMLDeclaration() : CFDE_XMLNode() {} 166 CFDE_XMLDeclaration() : CFDE_XMLNode() {}
171 ~CFDE_XMLDeclaration() override {} 167 ~CFDE_XMLDeclaration() override {}
172 }; 168 };
173 169
174 class CFDE_XMLCharData : public CFDE_XMLDeclaration { 170 class CFDE_XMLCharData : public CFDE_XMLDeclaration {
175 public: 171 public:
176 CFDE_XMLCharData(const CFX_WideString& wsCData); 172 CFDE_XMLCharData(const CFX_WideString& wsCData);
177 ~CFDE_XMLCharData() override {} 173 ~CFDE_XMLCharData() override;
178 174
179 void Release() override { delete this; } 175 // CFDE_XMLNode
180 FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_CharData; } 176 void Release() override;
177 FDE_XMLNODETYPE GetType() const override;
181 CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; 178 CFDE_XMLNode* Clone(FX_BOOL bRecursive) override;
182 179
183 void GetCharData(CFX_WideString& wsCharData) const { 180 virtual void GetCharData(CFX_WideString& wsCharData) const;
184 wsCharData = m_wsCharData; 181 virtual void SetCharData(const CFX_WideString& wsCData);
185 }
186 void SetCharData(const CFX_WideString& wsCData) { m_wsCharData = wsCData; }
187 182
188 CFX_WideString m_wsCharData; 183 CFX_WideString m_wsCharData;
189 }; 184 };
190 185
191 class CFDE_XMLDoc : public CFX_Target { 186 class CFDE_XMLDoc : public CFX_Target {
192 public: 187 public:
193 CFDE_XMLDoc(); 188 CFDE_XMLDoc();
194 ~CFDE_XMLDoc() override; 189 ~CFDE_XMLDoc() override;
195 190
196 void Release() { delete this; } 191 virtual void Release();
197 FX_BOOL LoadXML(CFDE_XMLParser* pXMLParser); 192 virtual FX_BOOL LoadXML(CFDE_XMLParser* pXMLParser);
198 int32_t DoLoad(IFX_Pause* pPause = nullptr); 193 virtual int32_t DoLoad(IFX_Pause* pPause = nullptr);
199 void CloseXML(); 194 virtual void CloseXML();
200 CFDE_XMLNode* GetRoot() const { return m_pRoot; } 195 virtual CFDE_XMLNode* GetRoot() const;
201 void SaveXML(IFX_Stream* pXMLStream = nullptr, FX_BOOL bSaveBOM = TRUE); 196 virtual void SaveXML(IFX_Stream* pXMLStream = NULL, FX_BOOL bSaveBOM = TRUE);
Lei Zhang 2016/06/17 03:10:05 nullptr
Wei Li 2016/06/17 21:47:45 Done.
202 void SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pNode); 197 virtual void SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pNode);
203 198
204 protected: 199 protected:
205 void Reset(FX_BOOL bInitRoot); 200 void Reset(FX_BOOL bInitRoot);
206 void ReleaseParser(); 201 void ReleaseParser();
207 202
208 IFX_Stream* m_pStream; 203 IFX_Stream* m_pStream;
209 int32_t m_iStatus; 204 int32_t m_iStatus;
210 CFDE_XMLNode* m_pRoot; 205 CFDE_XMLNode* m_pRoot;
211 CFDE_XMLSyntaxParser* m_pSyntaxParser; 206 CFDE_XMLSyntaxParser* m_pSyntaxParser;
212 CFDE_XMLParser* m_pXMLParser; 207 CFDE_XMLParser* m_pXMLParser;
213 }; 208 };
214 209
215 class CFDE_XMLParser { 210 class CFDE_XMLParser {
216 public: 211 public:
217 virtual ~CFDE_XMLParser() {} 212 virtual ~CFDE_XMLParser() {}
218 213
219 virtual void Release() = 0; 214 virtual void Release() = 0;
220 virtual int32_t DoParser(IFX_Pause* pPause) = 0; 215 virtual int32_t DoParser(IFX_Pause* pPause) = 0;
221 }; 216 };
222 217
223 class CFDE_BlockBuffer : public CFX_Target { 218 class CFDE_BlockBuffer : public CFX_Target {
224 public: 219 public:
225 CFDE_BlockBuffer(int32_t iAllocStep = 1024 * 1024); 220 CFDE_BlockBuffer(int32_t iAllocStep = 1024 * 1024);
226 ~CFDE_BlockBuffer(); 221 ~CFDE_BlockBuffer() override;
227 222
228 FX_BOOL InitBuffer(int32_t iBufferSize = 1024 * 1024); 223 FX_BOOL InitBuffer(int32_t iBufferSize = 1024 * 1024);
229 FX_BOOL IsInitialized() { return m_iBufferSize / m_iAllocStep >= 1; } 224 FX_BOOL IsInitialized() { return m_iBufferSize / m_iAllocStep >= 1; }
230 void ReleaseBuffer() { delete this; } 225 void ReleaseBuffer() { delete this; }
231 FX_WCHAR* GetAvailableBlock(int32_t& iIndexInBlock); 226 FX_WCHAR* GetAvailableBlock(int32_t& iIndexInBlock);
232 inline int32_t GetAllocStep() const { return m_iAllocStep; } 227 inline int32_t GetAllocStep() const { return m_iAllocStep; }
233 inline int32_t& GetDataLengthRef() { return m_iDataLength; } 228 inline int32_t& GetDataLengthRef() { return m_iDataLength; }
234 inline void Reset(FX_BOOL bReserveData = TRUE) { 229 inline void Reset(FX_BOOL bReserveData = TRUE) {
235 if (!bReserveData) { 230 if (!bReserveData) {
236 m_iStartPosition = 0; 231 m_iStartPosition = 0;
(...skipping 15 matching lines...) Expand all
252 CFX_ArrayTemplate<FX_WCHAR*> m_BlockArray; 247 CFX_ArrayTemplate<FX_WCHAR*> m_BlockArray;
253 int32_t m_iDataLength; 248 int32_t m_iDataLength;
254 int32_t m_iBufferSize; 249 int32_t m_iBufferSize;
255 int32_t m_iAllocStep; 250 int32_t m_iAllocStep;
256 int32_t m_iStartPosition; 251 int32_t m_iStartPosition;
257 }; 252 };
258 253
259 class CFDE_XMLSyntaxParser : public CFX_Target { 254 class CFDE_XMLSyntaxParser : public CFX_Target {
260 public: 255 public:
261 CFDE_XMLSyntaxParser(); 256 CFDE_XMLSyntaxParser();
262 ~CFDE_XMLSyntaxParser(); 257 ~CFDE_XMLSyntaxParser() override;
263 258
264 void Release() { delete this; } 259 void Release() { delete this; }
265 void Init(IFX_Stream* pStream, 260 void Init(IFX_Stream* pStream,
266 int32_t iXMLPlaneSize, 261 int32_t iXMLPlaneSize,
267 int32_t iTextDataSize = 256); 262 int32_t iTextDataSize = 256);
268 263
269 FDE_XmlSyntaxResult DoSyntaxParse(); 264 FDE_XmlSyntaxResult DoSyntaxParse();
270 265
271 int32_t GetStatus() const; 266 int32_t GetStatus() const;
272 int32_t GetCurrentPos() const { 267 int32_t GetCurrentPos() const {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 int32_t m_iTextDataLength; 338 int32_t m_iTextDataLength;
344 FDE_XmlSyntaxResult m_syntaxParserResult; 339 FDE_XmlSyntaxResult m_syntaxParserResult;
345 FDE_XmlSyntaxState m_syntaxParserState; 340 FDE_XmlSyntaxState m_syntaxParserState;
346 FX_WCHAR m_wQuotationMark; 341 FX_WCHAR m_wQuotationMark;
347 int32_t m_iEntityStart; 342 int32_t m_iEntityStart;
348 CFX_DWordStack m_SkipStack; 343 CFX_DWordStack m_SkipStack;
349 FX_WCHAR m_SkipChar; 344 FX_WCHAR m_SkipChar;
350 }; 345 };
351 346
352 #endif // XFA_FDE_XML_FDE_XML_IMP_H_ 347 #endif // XFA_FDE_XML_FDE_XML_IMP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698