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

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

Issue 1886263003: Rename CFX_ByteTextBuf::GetByteString() to AsStringC(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; 125 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
126 if (IsEOF()) { 126 if (IsEOF()) {
127 return; 127 return;
128 } 128 }
129 CFX_ByteTextBuf buf; 129 CFX_ByteTextBuf buf;
130 uint8_t ch; 130 uint8_t ch;
131 do { 131 do {
132 while (m_dwIndex < m_dwBufferSize) { 132 while (m_dwIndex < m_dwBufferSize) {
133 ch = m_pBuffer[m_dwIndex]; 133 ch = m_pBuffer[m_dwIndex];
134 if (ch == ':') { 134 if (ch == ':') {
135 space = buf.GetByteString(); 135 space = buf.AsStringC();
136 buf.Clear(); 136 buf.Clear();
137 } else if (g_FXCRT_XML_IsNameChar(ch)) { 137 } else if (g_FXCRT_XML_IsNameChar(ch)) {
138 buf.AppendChar(ch); 138 buf.AppendChar(ch);
139 } else { 139 } else {
140 break; 140 break;
141 } 141 }
142 m_dwIndex++; 142 m_dwIndex++;
143 } 143 }
144 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; 144 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
145 if (m_dwIndex < m_dwBufferSize || IsEOF()) { 145 if (m_dwIndex < m_dwBufferSize || IsEOF()) {
146 break; 146 break;
147 } 147 }
148 } while (ReadNextBlock()); 148 } while (ReadNextBlock());
149 name = buf.GetByteString(); 149 name = buf.AsStringC();
150 } 150 }
151 void CXML_Parser::SkipLiterals(const CFX_ByteStringC& str) { 151 void CXML_Parser::SkipLiterals(const CFX_ByteStringC& str) {
152 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; 152 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
153 if (IsEOF()) { 153 if (IsEOF()) {
154 return; 154 return;
155 } 155 }
156 int32_t i = 0, iLen = str.GetLength(); 156 int32_t i = 0, iLen = str.GetLength();
157 do { 157 do {
158 while (m_dwIndex < m_dwBufferSize) { 158 while (m_dwIndex < m_dwBufferSize) {
159 if (str.GetAt(i) != m_pBuffer[m_dwIndex++]) { 159 if (str.GetAt(i) != m_pBuffer[m_dwIndex++]) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 case 0: 195 case 0:
196 if (ch == '#') { 196 if (ch == '#') {
197 m_dwIndex++; 197 m_dwIndex++;
198 iState = 2; 198 iState = 2;
199 break; 199 break;
200 } 200 }
201 iState = 1; 201 iState = 1;
202 case 1: 202 case 1:
203 m_dwIndex++; 203 m_dwIndex++;
204 if (ch == ';') { 204 if (ch == ';') {
205 CFX_ByteStringC ref = buf.GetByteString(); 205 CFX_ByteStringC ref = buf.AsStringC();
206 if (ref == "gt") { 206 if (ref == "gt") {
207 code = '>'; 207 code = '>';
208 } else if (ref == "lt") { 208 } else if (ref == "lt") {
209 code = '<'; 209 code = '<';
210 } else if (ref == "amp") { 210 } else if (ref == "amp") {
211 code = '&'; 211 code = '&';
212 } else if (ref == "apos") { 212 } else if (ref == "apos") {
213 code = '\''; 213 code = '\'';
214 } else if (ref == "quot") { 214 } else if (ref == "quot") {
215 code = '"'; 215 code = '"';
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 SkipWhiteSpaces(); 450 SkipWhiteSpaces();
451 iState = 0; 451 iState = 0;
452 } else if (ch == '/') { 452 } else if (ch == '/') {
453 CFX_ByteString space, name; 453 CFX_ByteString space, name;
454 GetName(space, name); 454 GetName(space, name);
455 SkipWhiteSpaces(); 455 SkipWhiteSpaces();
456 m_dwIndex++; 456 m_dwIndex++;
457 iState = 10; 457 iState = 10;
458 } else { 458 } else {
459 content << decoder.GetResult(); 459 content << decoder.GetResult();
460 CFX_WideString dataStr = content.GetWideString(); 460 CFX_WideString dataStr = content.AsStringC();
461 if (!bCDATA && !m_bSaveSpaceChars) { 461 if (!bCDATA && !m_bSaveSpaceChars) {
462 dataStr.TrimRight(L" \t\r\n"); 462 dataStr.TrimRight(L" \t\r\n");
463 } 463 }
464 InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement); 464 InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement);
465 content.Clear(); 465 content.Clear();
466 decoder.Clear(); 466 decoder.Clear();
467 bCDATA = FALSE; 467 bCDATA = FALSE;
468 iState = 0; 468 iState = 0;
469 m_dwIndex--; 469 m_dwIndex--;
470 CXML_Element* pSubElement = ParseElement(pElement, TRUE); 470 CXML_Element* pSubElement = ParseElement(pElement, TRUE);
(...skipping 23 matching lines...) Expand all
494 if (iState == 10) { 494 if (iState == 10) {
495 break; 495 break;
496 } 496 }
497 } 497 }
498 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; 498 m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
499 if (iState == 10 || m_dwIndex < m_dwBufferSize || IsEOF()) { 499 if (iState == 10 || m_dwIndex < m_dwBufferSize || IsEOF()) {
500 break; 500 break;
501 } 501 }
502 } while (ReadNextBlock()); 502 } while (ReadNextBlock());
503 content << decoder.GetResult(); 503 content << decoder.GetResult();
504 CFX_WideString dataStr = content.GetWideString(); 504 CFX_WideString dataStr = content.AsStringC();
505 if (!m_bSaveSpaceChars) { 505 if (!m_bSaveSpaceChars) {
506 dataStr.TrimRight(L" \t\r\n"); 506 dataStr.TrimRight(L" \t\r\n");
507 } 507 }
508 InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement); 508 InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement);
509 content.Clear(); 509 content.Clear();
510 decoder.Clear(); 510 decoder.Clear();
511 bCDATA = FALSE; 511 bCDATA = FALSE;
512 return pElement; 512 return pElement;
513 } 513 }
514 void CXML_Parser::InsertContentSegment(FX_BOOL bCDATA, 514 void CXML_Parser::InsertContentSegment(FX_BOOL bCDATA,
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 m_pMap->push_back({space, name, value}); 787 m_pMap->push_back({space, name, value});
788 } 788 }
789 789
790 int CXML_AttrMap::GetSize() const { 790 int CXML_AttrMap::GetSize() const {
791 return m_pMap ? pdfium::CollectionSize<int>(*m_pMap) : 0; 791 return m_pMap ? pdfium::CollectionSize<int>(*m_pMap) : 0;
792 } 792 }
793 793
794 CXML_AttrItem& CXML_AttrMap::GetAt(int index) const { 794 CXML_AttrItem& CXML_AttrMap::GetAt(int index) const {
795 return (*m_pMap)[index]; 795 return (*m_pMap)[index];
796 } 796 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698