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

Side by Side Diff: core/fxcrt/fx_xml_parser.cpp

Issue 1862123003: Rename both As{Byte,Wide}StringC() helpers to AsStringC(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, fix new usage. Created 4 years, 8 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 | « core/fxcrt/fx_basic_buffer.cpp ('k') | core/fxcrt/fxcrt_posix.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 #include "core/fxcrt/xml_int.h" 7 #include "core/fxcrt/xml_int.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 return nullptr; 364 return nullptr;
365 } 365 }
366 CFX_ByteString tag_name, tag_space; 366 CFX_ByteString tag_name, tag_space;
367 FX_BOOL bEndTag; 367 FX_BOOL bEndTag;
368 GetTagName(tag_space, tag_name, bEndTag, bStartTag); 368 GetTagName(tag_space, tag_name, bEndTag, bStartTag);
369 if (tag_name.IsEmpty() || bEndTag) { 369 if (tag_name.IsEmpty() || bEndTag) {
370 return nullptr; 370 return nullptr;
371 } 371 }
372 CXML_Element* pElement = new CXML_Element; 372 CXML_Element* pElement = new CXML_Element;
373 pElement->m_pParent = pParent; 373 pElement->m_pParent = pParent;
374 pElement->SetTag(tag_space.AsByteStringC(), tag_name.AsByteStringC()); 374 pElement->SetTag(tag_space.AsStringC(), tag_name.AsStringC());
375 do { 375 do {
376 CFX_ByteString attr_space, attr_name; 376 CFX_ByteString attr_space, attr_name;
377 while (m_dwIndex < m_dwBufferSize) { 377 while (m_dwIndex < m_dwBufferSize) {
378 SkipWhiteSpaces(); 378 SkipWhiteSpaces();
379 if (IsEOF()) { 379 if (IsEOF()) {
380 break; 380 break;
381 } 381 }
382 if (!g_FXCRT_XML_IsNameIntro(m_pBuffer[m_dwIndex])) { 382 if (!g_FXCRT_XML_IsNameIntro(m_pBuffer[m_dwIndex])) {
383 break; 383 break;
384 } 384 }
385 GetName(attr_space, attr_name); 385 GetName(attr_space, attr_name);
386 SkipWhiteSpaces(); 386 SkipWhiteSpaces();
387 if (IsEOF()) { 387 if (IsEOF()) {
388 break; 388 break;
389 } 389 }
390 if (m_pBuffer[m_dwIndex] != '=') { 390 if (m_pBuffer[m_dwIndex] != '=') {
391 break; 391 break;
392 } 392 }
393 m_dwIndex++; 393 m_dwIndex++;
394 SkipWhiteSpaces(); 394 SkipWhiteSpaces();
395 if (IsEOF()) { 395 if (IsEOF()) {
396 break; 396 break;
397 } 397 }
398 CFX_WideString attr_value; 398 CFX_WideString attr_value;
399 GetAttrValue(attr_value); 399 GetAttrValue(attr_value);
400 pElement->m_AttrMap.SetAt(attr_space.AsByteStringC(), 400 pElement->m_AttrMap.SetAt(attr_space.AsStringC(), attr_name.AsStringC(),
401 attr_name.AsByteStringC(), 401 attr_value.AsStringC());
402 attr_value.AsWideStringC());
403 } 402 }
404 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; 403 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
405 if (m_dwIndex < m_dwBufferSize || IsEOF()) { 404 if (m_dwIndex < m_dwBufferSize || IsEOF()) {
406 break; 405 break;
407 } 406 }
408 } while (ReadNextBlock()); 407 } while (ReadNextBlock());
409 SkipWhiteSpaces(); 408 SkipWhiteSpaces();
410 if (IsEOF()) { 409 if (IsEOF()) {
411 return pElement; 410 return pElement;
412 } 411 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 GetName(space, name); 454 GetName(space, name);
456 SkipWhiteSpaces(); 455 SkipWhiteSpaces();
457 m_dwIndex++; 456 m_dwIndex++;
458 iState = 10; 457 iState = 10;
459 } else { 458 } else {
460 content << decoder.GetResult(); 459 content << decoder.GetResult();
461 CFX_WideString dataStr = content.GetWideString(); 460 CFX_WideString dataStr = content.GetWideString();
462 if (!bCDATA && !m_bSaveSpaceChars) { 461 if (!bCDATA && !m_bSaveSpaceChars) {
463 dataStr.TrimRight(L" \t\r\n"); 462 dataStr.TrimRight(L" \t\r\n");
464 } 463 }
465 InsertContentSegment(bCDATA, dataStr.AsWideStringC(), pElement); 464 InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement);
466 content.Clear(); 465 content.Clear();
467 decoder.Clear(); 466 decoder.Clear();
468 bCDATA = FALSE; 467 bCDATA = FALSE;
469 iState = 0; 468 iState = 0;
470 m_dwIndex--; 469 m_dwIndex--;
471 CXML_Element* pSubElement = ParseElement(pElement, TRUE); 470 CXML_Element* pSubElement = ParseElement(pElement, TRUE);
472 if (!pSubElement) { 471 if (!pSubElement) {
473 break; 472 break;
474 } 473 }
475 pSubElement->m_pParent = pElement; 474 pSubElement->m_pParent = pElement;
(...skipping 23 matching lines...) Expand all
499 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; 498 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
500 if (iState == 10 || m_dwIndex < m_dwBufferSize || IsEOF()) { 499 if (iState == 10 || m_dwIndex < m_dwBufferSize || IsEOF()) {
501 break; 500 break;
502 } 501 }
503 } while (ReadNextBlock()); 502 } while (ReadNextBlock());
504 content << decoder.GetResult(); 503 content << decoder.GetResult();
505 CFX_WideString dataStr = content.GetWideString(); 504 CFX_WideString dataStr = content.GetWideString();
506 if (!m_bSaveSpaceChars) { 505 if (!m_bSaveSpaceChars) {
507 dataStr.TrimRight(L" \t\r\n"); 506 dataStr.TrimRight(L" \t\r\n");
508 } 507 }
509 InsertContentSegment(bCDATA, dataStr.AsWideStringC(), pElement); 508 InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement);
510 content.Clear(); 509 content.Clear();
511 decoder.Clear(); 510 decoder.Clear();
512 bCDATA = FALSE; 511 bCDATA = FALSE;
513 return pElement; 512 return pElement;
514 } 513 }
515 void CXML_Parser::InsertContentSegment(FX_BOOL bCDATA, 514 void CXML_Parser::InsertContentSegment(FX_BOOL bCDATA,
516 const CFX_WideStringC& content, 515 const CFX_WideStringC& content,
517 CXML_Element* pElement) { 516 CXML_Element* pElement) {
518 if (content.IsEmpty()) { 517 if (content.IsEmpty()) {
519 return; 518 return;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 } 594 }
596 CFX_ByteString bsTag = m_QSpaceName; 595 CFX_ByteString bsTag = m_QSpaceName;
597 bsTag += ":"; 596 bsTag += ":";
598 bsTag += m_TagName; 597 bsTag += m_TagName;
599 return bsTag; 598 return bsTag;
600 } 599 }
601 CFX_ByteString CXML_Element::GetNamespace(FX_BOOL bQualified) const { 600 CFX_ByteString CXML_Element::GetNamespace(FX_BOOL bQualified) const {
602 if (bQualified) { 601 if (bQualified) {
603 return m_QSpaceName; 602 return m_QSpaceName;
604 } 603 }
605 return GetNamespaceURI(m_QSpaceName.AsByteStringC()); 604 return GetNamespaceURI(m_QSpaceName.AsStringC());
606 } 605 }
607 CFX_ByteString CXML_Element::GetNamespaceURI( 606 CFX_ByteString CXML_Element::GetNamespaceURI(
608 const CFX_ByteStringC& qName) const { 607 const CFX_ByteStringC& qName) const {
609 const CFX_WideString* pwsSpace; 608 const CFX_WideString* pwsSpace;
610 const CXML_Element* pElement = this; 609 const CXML_Element* pElement = this;
611 do { 610 do {
612 if (qName.IsEmpty()) { 611 if (qName.IsEmpty()) {
613 pwsSpace = pElement->m_AttrMap.Lookup("", "xmlns"); 612 pwsSpace = pElement->m_AttrMap.Lookup("", "xmlns");
614 } else { 613 } else {
615 pwsSpace = pElement->m_AttrMap.Lookup("xmlns", qName); 614 pwsSpace = pElement->m_AttrMap.Lookup("xmlns", qName);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 m_pMap->push_back({space, name, value}); 787 m_pMap->push_back({space, name, value});
789 } 788 }
790 789
791 int CXML_AttrMap::GetSize() const { 790 int CXML_AttrMap::GetSize() const {
792 return m_pMap ? pdfium::CollectionSize<int>(*m_pMap) : 0; 791 return m_pMap ? pdfium::CollectionSize<int>(*m_pMap) : 0;
793 } 792 }
794 793
795 CXML_AttrItem& CXML_AttrMap::GetAt(int index) const { 794 CXML_AttrItem& CXML_AttrMap::GetAt(int index) const {
796 return (*m_pMap)[index]; 795 return (*m_pMap)[index];
797 } 796 }
OLDNEW
« no previous file with comments | « core/fxcrt/fx_basic_buffer.cpp ('k') | core/fxcrt/fxcrt_posix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698