From f172290a8dc527cd8bc73b0d0ad59e78797968c1 Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 8 Apr 2016 12:13:50 -0700 Subject: Remove CFX_ByteString::Load() and operator= for CFX_ByteTextBuf The few places these are called are better served by explicit calls to CFX_ByteString() itself. This helps make Byte and Wide strings more similar. Also prevents fx_string.h from having any knowledge of fx_basic.h's ByteTextBuf class. Review URL: https://codereview.chromium.org/1870043003 --- core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.cpp | 4 ++-- core/fxcodec/codec/fx_codec_png.cpp | 6 +++--- core/fxcrt/fx_basic_bstring.cpp | 14 -------------- core/fxcrt/include/fx_string.h | 4 ---- 4 files changed, 5 insertions(+), 23 deletions(-) diff --git a/core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.cpp b/core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.cpp index 46384244e8..6bfe1b60b3 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.cpp @@ -20,9 +20,9 @@ void IPDF_CryptoHandler::Decrypt(uint32_t objnum, CFX_ByteString& str) { CFX_BinaryBuf dest_buf; void* context = DecryptStart(objnum, gennum); - DecryptStream(context, (const uint8_t*)str, str.GetLength(), dest_buf); + DecryptStream(context, str.raw_str(), str.GetLength(), dest_buf); DecryptFinish(context, dest_buf); - str = dest_buf; + str = CFX_ByteString(dest_buf.GetBuffer(), dest_buf.GetSize()); } void CPDF_StandardCryptoHandler::CryptBlock(FX_BOOL bEncrypt, diff --git a/core/fxcodec/codec/fx_codec_png.cpp b/core/fxcodec/codec/fx_codec_png.cpp index fd56c93393..29ea794b5d 100644 --- a/core/fxcodec/codec/fx_codec_png.cpp +++ b/core/fxcodec/codec/fx_codec_png.cpp @@ -82,9 +82,9 @@ static void _png_load_bmp_attribute(png_structp png_ptr, } else { buf = "Author"; if (!FXSYS_memcmp(buf, text[i].key, std::min(len, FXSYS_strlen(buf)))) { - pAttribute->m_strAuthor.Empty(); - pAttribute->m_strAuthor.Load((uint8_t*)text[i].text, - (FX_STRSIZE)text[i].text_length); + pAttribute->m_strAuthor = + CFX_ByteString(reinterpret_cast(text[i].text), + static_cast(text[i].text_length)); } } } diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp index cc0dfe2341..34abe1e067 100644 --- a/core/fxcrt/fx_basic_bstring.cpp +++ b/core/fxcrt/fx_basic_bstring.cpp @@ -141,20 +141,6 @@ const CFX_ByteString& CFX_ByteString::operator=( return *this; } -const CFX_ByteString& CFX_ByteString::operator=(const CFX_BinaryBuf& buf) { - Load(buf.GetBuffer(), buf.GetSize()); - return *this; -} - -void CFX_ByteString::Load(const uint8_t* buf, FX_STRSIZE len) { - if (!len) { - clear(); - return; - } - - m_pData.Reset(StringData::Create(reinterpret_cast(buf), len)); -} - const CFX_ByteString& CFX_ByteString::operator+=(const FX_CHAR* pStr) { if (pStr) Concat(pStr, FXSYS_strlen(pStr)); diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h index 8a0b3ff3db..6e2954fcbb 100644 --- a/core/fxcrt/include/fx_string.h +++ b/core/fxcrt/include/fx_string.h @@ -15,7 +15,6 @@ #include "core/fxcrt/include/fx_memory.h" #include "core/fxcrt/include/fx_system.h" -class CFX_BinaryBuf; class CFX_ByteString; class CFX_WideString; @@ -218,9 +217,6 @@ class CFX_ByteString { const CFX_ByteString& operator=(const FX_CHAR* str); const CFX_ByteString& operator=(const CFX_ByteStringC& bstrc); const CFX_ByteString& operator=(const CFX_ByteString& stringSrc); - const CFX_ByteString& operator=(const CFX_BinaryBuf& buf); - - void Load(const uint8_t* str, FX_STRSIZE len); const CFX_ByteString& operator+=(FX_CHAR ch); const CFX_ByteString& operator+=(const FX_CHAR* str); -- cgit v1.2.3