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 #include "../../include/fxcrt/fx_xml.h" | 7 #include "../../include/fxcrt/fx_xml.h" |
8 #include "xml_int.h" | 8 #include "xml_int.h" |
9 CXML_Parser::~CXML_Parser() | 9 CXML_Parser::~CXML_Parser() |
10 { | 10 { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 #define FXCRTM_XML_CHARTYPE_Normal 0x00 | 63 #define FXCRTM_XML_CHARTYPE_Normal 0x00 |
64 #define FXCRTM_XML_CHARTYPE_SpaceChar 0x01 | 64 #define FXCRTM_XML_CHARTYPE_SpaceChar 0x01 |
65 #define FXCRTM_XML_CHARTYPE_Letter 0x02 | 65 #define FXCRTM_XML_CHARTYPE_Letter 0x02 |
66 #define FXCRTM_XML_CHARTYPE_Digital 0x04 | 66 #define FXCRTM_XML_CHARTYPE_Digital 0x04 |
67 #define FXCRTM_XML_CHARTYPE_NameIntro 0x08 | 67 #define FXCRTM_XML_CHARTYPE_NameIntro 0x08 |
68 #define FXCRTM_XML_CHARTYPE_NameChar 0x10 | 68 #define FXCRTM_XML_CHARTYPE_NameChar 0x10 |
69 #define FXCRTM_XML_CHARTYPE_HexDigital 0x20 | 69 #define FXCRTM_XML_CHARTYPE_HexDigital 0x20 |
70 #define FXCRTM_XML_CHARTYPE_HexLowerLetter 0x40 | 70 #define FXCRTM_XML_CHARTYPE_HexLowerLetter 0x40 |
71 #define FXCRTM_XML_CHARTYPE_HexUpperLetter 0x60 | 71 #define FXCRTM_XML_CHARTYPE_HexUpperLetter 0x60 |
72 #define FXCRTM_XML_CHARTYPE_HexChar 0x60 | 72 #define FXCRTM_XML_CHARTYPE_HexChar 0x60 |
73 FX_BYTE g_FXCRT_XML_ByteTypes[256] = { | 73 uint8_t g_FXCRT_XML_ByteTypes[256] = { |
74 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01
, 0x01, 0x01, 0x01, | 74 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01
, 0x01, 0x01, 0x01, |
75 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01
, 0x01, 0x01, 0x01, | 75 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01
, 0x01, 0x01, 0x01, |
76 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
, 0x10, 0x10, 0x00, | 76 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
, 0x10, 0x10, 0x00, |
77 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x08, 0x00, 0x00
, 0x00, 0x00, 0x00, | 77 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x08, 0x00, 0x00
, 0x00, 0x00, 0x00, |
78 0x00, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A
, 0x1A, 0x1A, 0x1A, | 78 0x00, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A
, 0x1A, 0x1A, 0x1A, |
79 0x1A, 0x1A, 0x1A, 0x1A, 0x1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 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A
, 0x1A, 0x01, 0x01, |
90 }; | 90 }; |
91 FX_BOOL g_FXCRT_XML_IsWhiteSpace(FX_BYTE ch) | 91 FX_BOOL g_FXCRT_XML_IsWhiteSpace(uint8_t ch) |
92 { | 92 { |
93 return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_SpaceChar) != 0; | 93 return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_SpaceChar) != 0; |
94 } | 94 } |
95 FX_BOOL g_FXCRT_XML_IsLetter(FX_BYTE ch) | 95 FX_BOOL g_FXCRT_XML_IsLetter(uint8_t ch) |
96 { | 96 { |
97 return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_Letter) != 0; | 97 return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_Letter) != 0; |
98 } | 98 } |
99 FX_BOOL g_FXCRT_XML_IsDigital(FX_BYTE ch) | 99 FX_BOOL g_FXCRT_XML_IsDigital(uint8_t ch) |
100 { | 100 { |
101 return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_Digital) != 0; | 101 return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_Digital) != 0; |
102 } | 102 } |
103 FX_BOOL g_FXCRT_XML_IsNameIntro(FX_BYTE ch) | 103 FX_BOOL g_FXCRT_XML_IsNameIntro(uint8_t ch) |
104 { | 104 { |
105 return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_NameIntro) != 0; | 105 return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_NameIntro) != 0; |
106 } | 106 } |
107 FX_BOOL g_FXCRT_XML_IsNameChar(FX_BYTE ch) | 107 FX_BOOL g_FXCRT_XML_IsNameChar(uint8_t ch) |
108 { | 108 { |
109 return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_NameChar) != 0; | 109 return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_NameChar) != 0; |
110 } | 110 } |
111 FX_BOOL g_FXCRT_XML_IsHexChar(FX_BYTE ch) | 111 FX_BOOL g_FXCRT_XML_IsHexChar(uint8_t ch) |
112 { | 112 { |
113 return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_HexChar) != 0; | 113 return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_HexChar) != 0; |
114 } | 114 } |
115 void CXML_Parser::SkipWhiteSpaces() | 115 void CXML_Parser::SkipWhiteSpaces() |
116 { | 116 { |
117 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 117 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
118 if (IsEOF()) { | 118 if (IsEOF()) { |
119 return; | 119 return; |
120 } | 120 } |
121 do { | 121 do { |
122 while (m_dwIndex < m_dwBufferSize && g_FXCRT_XML_IsWhiteSpace(m_pBuffer[
m_dwIndex])) { | 122 while (m_dwIndex < m_dwBufferSize && g_FXCRT_XML_IsWhiteSpace(m_pBuffer[
m_dwIndex])) { |
123 m_dwIndex ++; | 123 m_dwIndex ++; |
124 } | 124 } |
125 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 125 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
126 if (m_dwIndex < m_dwBufferSize || IsEOF()) { | 126 if (m_dwIndex < m_dwBufferSize || IsEOF()) { |
127 break; | 127 break; |
128 } | 128 } |
129 } while (ReadNextBlock()); | 129 } while (ReadNextBlock()); |
130 } | 130 } |
131 void CXML_Parser::GetName(CFX_ByteString &space, CFX_ByteString &name) | 131 void CXML_Parser::GetName(CFX_ByteString &space, CFX_ByteString &name) |
132 { | 132 { |
133 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 133 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
134 if (IsEOF()) { | 134 if (IsEOF()) { |
135 return; | 135 return; |
136 } | 136 } |
137 CFX_ByteTextBuf buf; | 137 CFX_ByteTextBuf buf; |
138 FX_BYTE ch; | 138 uint8_t ch; |
139 do { | 139 do { |
140 while (m_dwIndex < m_dwBufferSize) { | 140 while (m_dwIndex < m_dwBufferSize) { |
141 ch = m_pBuffer[m_dwIndex]; | 141 ch = m_pBuffer[m_dwIndex]; |
142 if (ch == ':') { | 142 if (ch == ':') { |
143 space = buf.GetByteString(); | 143 space = buf.GetByteString(); |
144 buf.Clear(); | 144 buf.Clear(); |
145 } else if (g_FXCRT_XML_IsNameChar(ch)) { | 145 } else if (g_FXCRT_XML_IsNameChar(ch)) { |
146 buf.AppendChar(ch); | 146 buf.AppendChar(ch); |
147 } else { | 147 } else { |
148 break; | 148 break; |
149 } | 149 } |
150 m_dwIndex ++; | 150 m_dwIndex ++; |
151 } | 151 } |
152 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 152 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
153 if (m_dwIndex < m_dwBufferSize || IsEOF()) { | 153 if (m_dwIndex < m_dwBufferSize || IsEOF()) { |
154 break; | 154 break; |
155 } | 155 } |
156 } while (ReadNextBlock()); | 156 } while (ReadNextBlock()); |
157 name = buf.GetByteString(); | 157 name = buf.GetByteString(); |
158 } | 158 } |
159 void CXML_Parser::SkipLiterals(FX_BSTR str) | 159 void CXML_Parser::SkipLiterals(FX_BSTR str) |
160 { | 160 { |
161 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 161 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
162 if (IsEOF()) { | 162 if (IsEOF()) { |
163 return; | 163 return; |
164 } | 164 } |
165 FX_INT32 i = 0, iLen = str.GetLength(); | 165 int32_t i = 0, iLen = str.GetLength(); |
166 do { | 166 do { |
167 while (m_dwIndex < m_dwBufferSize) { | 167 while (m_dwIndex < m_dwBufferSize) { |
168 if (str.GetAt(i) != m_pBuffer[m_dwIndex ++]) { | 168 if (str.GetAt(i) != m_pBuffer[m_dwIndex ++]) { |
169 i = 0; | 169 i = 0; |
170 } else { | 170 } else { |
171 i ++; | 171 i ++; |
172 if (i == iLen) { | 172 if (i == iLen) { |
173 break; | 173 break; |
174 } | 174 } |
175 } | 175 } |
(...skipping 11 matching lines...) Expand all Loading... |
187 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwBufferSize; | 187 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwBufferSize; |
188 } | 188 } |
189 m_dwIndex = m_dwBufferSize; | 189 m_dwIndex = m_dwBufferSize; |
190 } | 190 } |
191 FX_DWORD CXML_Parser::GetCharRef() | 191 FX_DWORD CXML_Parser::GetCharRef() |
192 { | 192 { |
193 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 193 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
194 if (IsEOF()) { | 194 if (IsEOF()) { |
195 return 0; | 195 return 0; |
196 } | 196 } |
197 FX_BYTE ch; | 197 uint8_t ch; |
198 FX_INT32 iState = 0; | 198 int32_t iState = 0; |
199 CFX_ByteTextBuf buf; | 199 CFX_ByteTextBuf buf; |
200 FX_DWORD code = 0; | 200 FX_DWORD code = 0; |
201 do { | 201 do { |
202 while (m_dwIndex < m_dwBufferSize) { | 202 while (m_dwIndex < m_dwBufferSize) { |
203 ch = m_pBuffer[m_dwIndex]; | 203 ch = m_pBuffer[m_dwIndex]; |
204 switch (iState) { | 204 switch (iState) { |
205 case 0: | 205 case 0: |
206 if (ch == '#') { | 206 if (ch == '#') { |
207 m_dwIndex ++; | 207 m_dwIndex ++; |
208 iState = 2; | 208 iState = 2; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 if (g_FXCRT_XML_IsDigital(ch)) { | 245 if (g_FXCRT_XML_IsDigital(ch)) { |
246 code = code * 10 + ch - '0'; | 246 code = code * 10 + ch - '0'; |
247 } | 247 } |
248 break; | 248 break; |
249 case 4: | 249 case 4: |
250 m_dwIndex ++; | 250 m_dwIndex ++; |
251 if (ch == ';') { | 251 if (ch == ';') { |
252 iState = 10; | 252 iState = 10; |
253 break; | 253 break; |
254 } | 254 } |
255 FX_BYTE nHex = g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTY
PE_HexChar; | 255 uint8_t nHex = g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTY
PE_HexChar; |
256 if (nHex) { | 256 if (nHex) { |
257 if (nHex == FXCRTM_XML_CHARTYPE_HexDigital) { | 257 if (nHex == FXCRTM_XML_CHARTYPE_HexDigital) { |
258 code = (code << 4) + ch - '0'; | 258 code = (code << 4) + ch - '0'; |
259 } else if (nHex == FXCRTM_XML_CHARTYPE_HexLowerLetter) { | 259 } else if (nHex == FXCRTM_XML_CHARTYPE_HexLowerLetter) { |
260 code = (code << 4) + ch - 87; | 260 code = (code << 4) + ch - 87; |
261 } else { | 261 } else { |
262 code = (code << 4) + ch - 55; | 262 code = (code << 4) + ch - 55; |
263 } | 263 } |
264 } | 264 } |
265 break; | 265 break; |
266 } | 266 } |
267 if (iState == 10) { | 267 if (iState == 10) { |
268 break; | 268 break; |
269 } | 269 } |
270 } | 270 } |
271 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 271 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
272 if (iState == 10 || m_dwIndex < m_dwBufferSize || IsEOF()) { | 272 if (iState == 10 || m_dwIndex < m_dwBufferSize || IsEOF()) { |
273 break; | 273 break; |
274 } | 274 } |
275 } while (ReadNextBlock()); | 275 } while (ReadNextBlock()); |
276 return code; | 276 return code; |
277 } | 277 } |
278 void CXML_Parser::GetAttrValue(CFX_WideString &value) | 278 void CXML_Parser::GetAttrValue(CFX_WideString &value) |
279 { | 279 { |
280 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 280 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
281 if (IsEOF()) { | 281 if (IsEOF()) { |
282 return; | 282 return; |
283 } | 283 } |
284 CFX_UTF8Decoder decoder; | 284 CFX_UTF8Decoder decoder; |
285 FX_BYTE mark = 0, ch = 0; | 285 uint8_t mark = 0, ch = 0; |
286 do { | 286 do { |
287 while (m_dwIndex < m_dwBufferSize) { | 287 while (m_dwIndex < m_dwBufferSize) { |
288 ch = m_pBuffer[m_dwIndex]; | 288 ch = m_pBuffer[m_dwIndex]; |
289 if (mark == 0) { | 289 if (mark == 0) { |
290 if (ch != '\'' && ch != '"') { | 290 if (ch != '\'' && ch != '"') { |
291 return; | 291 return; |
292 } | 292 } |
293 mark = ch; | 293 mark = ch; |
294 m_dwIndex ++; | 294 m_dwIndex ++; |
295 ch = 0; | 295 ch = 0; |
(...skipping 20 matching lines...) Expand all Loading... |
316 } while (ReadNextBlock()); | 316 } while (ReadNextBlock()); |
317 value = decoder.GetResult(); | 317 value = decoder.GetResult(); |
318 } | 318 } |
319 void CXML_Parser::GetTagName(CFX_ByteString &space, CFX_ByteString &name, FX_BOO
L &bEndTag, FX_BOOL bStartTag) | 319 void CXML_Parser::GetTagName(CFX_ByteString &space, CFX_ByteString &name, FX_BOO
L &bEndTag, FX_BOOL bStartTag) |
320 { | 320 { |
321 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 321 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
322 if (IsEOF()) { | 322 if (IsEOF()) { |
323 return; | 323 return; |
324 } | 324 } |
325 bEndTag = FALSE; | 325 bEndTag = FALSE; |
326 FX_BYTE ch; | 326 uint8_t ch; |
327 FX_INT32 iState = bStartTag ? 1 : 0; | 327 int32_t iState = bStartTag ? 1 : 0; |
328 do { | 328 do { |
329 while (m_dwIndex < m_dwBufferSize) { | 329 while (m_dwIndex < m_dwBufferSize) { |
330 ch = m_pBuffer[m_dwIndex]; | 330 ch = m_pBuffer[m_dwIndex]; |
331 switch (iState) { | 331 switch (iState) { |
332 case 0: | 332 case 0: |
333 m_dwIndex ++; | 333 m_dwIndex ++; |
334 if (ch != '<') { | 334 if (ch != '<') { |
335 break; | 335 break; |
336 } | 336 } |
337 iState = 1; | 337 iState = 1; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 } | 415 } |
416 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 416 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
417 if (m_dwIndex < m_dwBufferSize || IsEOF()) { | 417 if (m_dwIndex < m_dwBufferSize || IsEOF()) { |
418 break; | 418 break; |
419 } | 419 } |
420 } while (ReadNextBlock()); | 420 } while (ReadNextBlock()); |
421 SkipWhiteSpaces(); | 421 SkipWhiteSpaces(); |
422 if (IsEOF()) { | 422 if (IsEOF()) { |
423 return pElement; | 423 return pElement; |
424 } | 424 } |
425 FX_BYTE ch = m_pBuffer[m_dwIndex ++]; | 425 uint8_t ch = m_pBuffer[m_dwIndex ++]; |
426 if (ch == '/') { | 426 if (ch == '/') { |
427 m_dwIndex ++; | 427 m_dwIndex ++; |
428 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 428 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
429 return pElement; | 429 return pElement; |
430 } | 430 } |
431 if (ch != '>') { | 431 if (ch != '>') { |
432 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; | 432 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; |
433 delete pElement; | 433 delete pElement; |
434 return NULL; | 434 return NULL; |
435 } | 435 } |
436 SkipWhiteSpaces(); | 436 SkipWhiteSpaces(); |
437 if (IsEOF()) { | 437 if (IsEOF()) { |
438 return pElement; | 438 return pElement; |
439 } | 439 } |
440 CFX_UTF8Decoder decoder; | 440 CFX_UTF8Decoder decoder; |
441 CFX_WideTextBuf content; | 441 CFX_WideTextBuf content; |
442 FX_BOOL bCDATA = FALSE; | 442 FX_BOOL bCDATA = FALSE; |
443 FX_INT32 iState = 0; | 443 int32_t iState = 0; |
444 do { | 444 do { |
445 while (m_dwIndex < m_dwBufferSize) { | 445 while (m_dwIndex < m_dwBufferSize) { |
446 ch = m_pBuffer[m_dwIndex ++]; | 446 ch = m_pBuffer[m_dwIndex ++]; |
447 switch (iState) { | 447 switch (iState) { |
448 case 0: | 448 case 0: |
449 if (ch == '<') { | 449 if (ch == '<') { |
450 iState = 1; | 450 iState = 1; |
451 } else if (ch == '&') { | 451 } else if (ch == '&') { |
452 decoder.ClearStatus(); | 452 decoder.ClearStatus(); |
453 decoder.AppendChar(GetCharRef()); | 453 decoder.AppendChar(GetCharRef()); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 { | 597 { |
598 Empty(); | 598 Empty(); |
599 } | 599 } |
600 void CXML_Element::Empty() | 600 void CXML_Element::Empty() |
601 { | 601 { |
602 RemoveChildren(); | 602 RemoveChildren(); |
603 } | 603 } |
604 void CXML_Element::RemoveChildren() | 604 void CXML_Element::RemoveChildren() |
605 { | 605 { |
606 for (int i = 0; i < m_Children.GetSize(); i += 2) { | 606 for (int i = 0; i < m_Children.GetSize(); i += 2) { |
607 ChildType type = (ChildType)(FX_UINTPTR)m_Children.GetAt(i); | 607 ChildType type = (ChildType)(uintptr_t)m_Children.GetAt(i); |
608 if (type == Content) { | 608 if (type == Content) { |
609 CXML_Content* content = (CXML_Content*)m_Children.GetAt(i + 1); | 609 CXML_Content* content = (CXML_Content*)m_Children.GetAt(i + 1); |
610 delete content; | 610 delete content; |
611 } else if (type == Element) { | 611 } else if (type == Element) { |
612 CXML_Element* child = (CXML_Element*)m_Children.GetAt(i + 1); | 612 CXML_Element* child = (CXML_Element*)m_Children.GetAt(i + 1); |
613 child->RemoveChildren(); | 613 child->RemoveChildren(); |
614 delete child; | 614 delete child; |
615 } | 615 } |
616 } | 616 } |
617 m_Children.RemoveAll(); | 617 m_Children.RemoveAll(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 FX_DWORD CXML_Element::CountChildren() const | 719 FX_DWORD CXML_Element::CountChildren() const |
720 { | 720 { |
721 return m_Children.GetSize() / 2; | 721 return m_Children.GetSize() / 2; |
722 } | 722 } |
723 CXML_Element::ChildType CXML_Element::GetChildType(FX_DWORD index) const | 723 CXML_Element::ChildType CXML_Element::GetChildType(FX_DWORD index) const |
724 { | 724 { |
725 index <<= 1; | 725 index <<= 1; |
726 if (index >= (FX_DWORD)m_Children.GetSize()) { | 726 if (index >= (FX_DWORD)m_Children.GetSize()) { |
727 return Invalid; | 727 return Invalid; |
728 } | 728 } |
729 return (ChildType)(FX_UINTPTR)m_Children.GetAt(index); | 729 return (ChildType)(uintptr_t)m_Children.GetAt(index); |
730 } | 730 } |
731 CFX_WideString CXML_Element::GetContent(FX_DWORD index) const | 731 CFX_WideString CXML_Element::GetContent(FX_DWORD index) const |
732 { | 732 { |
733 index <<= 1; | 733 index <<= 1; |
734 if (index >= (FX_DWORD)m_Children.GetSize() || | 734 if (index >= (FX_DWORD)m_Children.GetSize() || |
735 (ChildType)(FX_UINTPTR)m_Children.GetAt(index) != Content) { | 735 (ChildType)(uintptr_t)m_Children.GetAt(index) != Content) { |
736 return CFX_WideString(); | 736 return CFX_WideString(); |
737 } | 737 } |
738 CXML_Content* pContent = (CXML_Content*)m_Children.GetAt(index + 1); | 738 CXML_Content* pContent = (CXML_Content*)m_Children.GetAt(index + 1); |
739 if (pContent) { | 739 if (pContent) { |
740 return pContent->m_Content; | 740 return pContent->m_Content; |
741 } | 741 } |
742 return CFX_WideString(); | 742 return CFX_WideString(); |
743 } | 743 } |
744 CXML_Element* CXML_Element::GetElement(FX_DWORD index) const | 744 CXML_Element* CXML_Element::GetElement(FX_DWORD index) const |
745 { | 745 { |
746 index <<= 1; | 746 index <<= 1; |
747 if (index >= (FX_DWORD)m_Children.GetSize() || | 747 if (index >= (FX_DWORD)m_Children.GetSize() || |
748 (ChildType)(FX_UINTPTR)m_Children.GetAt(index) != Element) { | 748 (ChildType)(uintptr_t)m_Children.GetAt(index) != Element) { |
749 return NULL; | 749 return NULL; |
750 } | 750 } |
751 return (CXML_Element*)m_Children.GetAt(index + 1); | 751 return (CXML_Element*)m_Children.GetAt(index + 1); |
752 } | 752 } |
753 FX_DWORD CXML_Element::CountElements(FX_BSTR space, FX_BSTR tag) const | 753 FX_DWORD CXML_Element::CountElements(FX_BSTR space, FX_BSTR tag) const |
754 { | 754 { |
755 int count = 0; | 755 int count = 0; |
756 for (int i = 0; i < m_Children.GetSize(); i += 2) { | 756 for (int i = 0; i < m_Children.GetSize(); i += 2) { |
757 ChildType type = (ChildType)(FX_UINTPTR)m_Children.GetAt(i); | 757 ChildType type = (ChildType)(uintptr_t)m_Children.GetAt(i); |
758 if (type != Element) { | 758 if (type != Element) { |
759 continue; | 759 continue; |
760 } | 760 } |
761 CXML_Element* pKid = (CXML_Element*)m_Children.GetAt(i + 1); | 761 CXML_Element* pKid = (CXML_Element*)m_Children.GetAt(i + 1); |
762 if ((space.IsEmpty() || pKid->m_QSpaceName == space) && pKid->m_TagName
== tag) { | 762 if ((space.IsEmpty() || pKid->m_QSpaceName == space) && pKid->m_TagName
== tag) { |
763 count ++; | 763 count ++; |
764 } | 764 } |
765 } | 765 } |
766 return count; | 766 return count; |
767 } | 767 } |
768 CXML_Element* CXML_Element::GetElement(FX_BSTR space, FX_BSTR tag, int index) co
nst | 768 CXML_Element* CXML_Element::GetElement(FX_BSTR space, FX_BSTR tag, int index) co
nst |
769 { | 769 { |
770 if (index < 0) { | 770 if (index < 0) { |
771 return NULL; | 771 return NULL; |
772 } | 772 } |
773 for (int i = 0; i < m_Children.GetSize(); i += 2) { | 773 for (int i = 0; i < m_Children.GetSize(); i += 2) { |
774 ChildType type = (ChildType)(FX_UINTPTR)m_Children.GetAt(i); | 774 ChildType type = (ChildType)(uintptr_t)m_Children.GetAt(i); |
775 if (type != Element) { | 775 if (type != Element) { |
776 continue; | 776 continue; |
777 } | 777 } |
778 CXML_Element* pKid = (CXML_Element*)m_Children.GetAt(i + 1); | 778 CXML_Element* pKid = (CXML_Element*)m_Children.GetAt(i + 1); |
779 if ((!space.IsEmpty() && pKid->m_QSpaceName != space) || pKid->m_TagName
!= tag) { | 779 if ((!space.IsEmpty() && pKid->m_QSpaceName != space) || pKid->m_TagName
!= tag) { |
780 continue; | 780 continue; |
781 } | 781 } |
782 if (index -- == 0) { | 782 if (index -- == 0) { |
783 return pKid; | 783 return pKid; |
784 } | 784 } |
785 } | 785 } |
786 return NULL; | 786 return NULL; |
787 } | 787 } |
788 FX_DWORD CXML_Element::FindElement(CXML_Element *pChild) const | 788 FX_DWORD CXML_Element::FindElement(CXML_Element *pChild) const |
789 { | 789 { |
790 for (int i = 0; i < m_Children.GetSize(); i += 2) { | 790 for (int i = 0; i < m_Children.GetSize(); i += 2) { |
791 if ((ChildType)(FX_UINTPTR)m_Children.GetAt(i) == Element && | 791 if ((ChildType)(uintptr_t)m_Children.GetAt(i) == Element && |
792 (CXML_Element*)m_Children.GetAt(i + 1) == pChild) { | 792 (CXML_Element*)m_Children.GetAt(i + 1) == pChild) { |
793 return (FX_DWORD)(i >> 1); | 793 return (FX_DWORD)(i >> 1); |
794 } | 794 } |
795 } | 795 } |
796 return (FX_DWORD) - 1; | 796 return (FX_DWORD) - 1; |
797 } | 797 } |
798 const CFX_WideString* CXML_AttrMap::Lookup(FX_BSTR space, FX_BSTR name) const | 798 const CFX_WideString* CXML_AttrMap::Lookup(FX_BSTR space, FX_BSTR name) const |
799 { | 799 { |
800 if (m_pMap == NULL) { | 800 if (m_pMap == NULL) { |
801 return NULL; | 801 return NULL; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 } | 855 } |
856 void CXML_AttrMap::RemoveAll() | 856 void CXML_AttrMap::RemoveAll() |
857 { | 857 { |
858 if (!m_pMap) { | 858 if (!m_pMap) { |
859 return; | 859 return; |
860 } | 860 } |
861 m_pMap->RemoveAll(); | 861 m_pMap->RemoveAll(); |
862 delete m_pMap; | 862 delete m_pMap; |
863 m_pMap = NULL; | 863 m_pMap = NULL; |
864 } | 864 } |
OLD | NEW |