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

Side by Side Diff: core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp

Issue 1977093002: Make CFX_ByteString(const CFX_ByteStringC&) explicit. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, nit 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
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/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" 7 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 #include <utility> 10 #include <utility>
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex) { 521 CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex) {
522 CFX_ByteTextBuf result; 522 CFX_ByteTextBuf result;
523 int srclen = src.GetLength(); 523 int srclen = src.GetLength();
524 if (bHex) { 524 if (bHex) {
525 result.AppendChar('<'); 525 result.AppendChar('<');
526 for (int i = 0; i < srclen; i++) { 526 for (int i = 0; i < srclen; i++) {
527 result.AppendChar("0123456789ABCDEF"[src[i] / 16]); 527 result.AppendChar("0123456789ABCDEF"[src[i] / 16]);
528 result.AppendChar("0123456789ABCDEF"[src[i] % 16]); 528 result.AppendChar("0123456789ABCDEF"[src[i] % 16]);
529 } 529 }
530 result.AppendChar('>'); 530 result.AppendChar('>');
531 return result.AsStringC(); 531 return result.MakeString();
532 } 532 }
533 result.AppendChar('('); 533 result.AppendChar('(');
534 for (int i = 0; i < srclen; i++) { 534 for (int i = 0; i < srclen; i++) {
535 uint8_t ch = src[i]; 535 uint8_t ch = src[i];
536 if (ch == ')' || ch == '\\' || ch == '(') { 536 if (ch == ')' || ch == '\\' || ch == '(') {
537 result.AppendChar('\\'); 537 result.AppendChar('\\');
538 } else if (ch == 0x0a) { 538 } else if (ch == 0x0a) {
539 result << "\\n"; 539 result << "\\n";
540 continue; 540 continue;
541 } else if (ch == 0x0d) { 541 } else if (ch == 0x0d) {
542 result << "\\r"; 542 result << "\\r";
543 continue; 543 continue;
544 } 544 }
545 result.AppendChar(ch); 545 result.AppendChar(ch);
546 } 546 }
547 result.AppendChar(')'); 547 result.AppendChar(')');
548 return result.AsStringC(); 548 return result.MakeString();
549 } 549 }
550 550
551 void FlateEncode(const uint8_t* src_buf, 551 void FlateEncode(const uint8_t* src_buf,
552 uint32_t src_size, 552 uint32_t src_size,
553 uint8_t*& dest_buf, 553 uint8_t*& dest_buf,
554 uint32_t& dest_size) { 554 uint32_t& dest_size) {
555 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); 555 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule();
556 if (pEncoders) { 556 if (pEncoders) {
557 pEncoders->GetFlateModule()->Encode(src_buf, src_size, dest_buf, dest_size); 557 pEncoders->GetFlateModule()->Encode(src_buf, src_size, dest_buf, dest_size);
558 } 558 }
(...skipping 19 matching lines...) Expand all
578 uint32_t src_size, 578 uint32_t src_size,
579 uint8_t*& dest_buf, 579 uint8_t*& dest_buf,
580 uint32_t& dest_size) { 580 uint32_t& dest_size) {
581 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); 581 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule();
582 if (pEncoders) { 582 if (pEncoders) {
583 return pEncoders->GetFlateModule()->FlateOrLZWDecode( 583 return pEncoders->GetFlateModule()->FlateOrLZWDecode(
584 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); 584 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size);
585 } 585 }
586 return 0; 586 return 0;
587 } 587 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp ('k') | core/fpdfapi/fpdf_parser/fpdf_parser_utility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698