diff options
author | dsinclair <dsinclair@chromium.org> | 2016-04-05 11:02:18 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-05 11:02:18 -0700 |
commit | 179bebb9a14dfd3ba91e9e068d4d436657a7c780 (patch) | |
tree | 895a59bfcf85a4730badfb2a6df71cf8679a2249 /core | |
parent | 4cd49e1c6076bd9ef2d18480d893038822668262 (diff) | |
download | pdfium-179bebb9a14dfd3ba91e9e068d4d436657a7c780.tar.xz |
Rename GetCStr and GetPtr to match CFX_ByteString.
This CL updates CFX_ByteStringC to use the more common c_str
and raw_str instead of GetCStr and GetPtr.
Review URL: https://codereview.chromium.org/1857713003
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/fpdf_font/fpdf_font.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_generalstatedata.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp | 12 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_simple_parser.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_simple_parser_unittest.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp | 10 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | 2 | ||||
-rw-r--r-- | core/fpdfdoc/doc_basic.cpp | 26 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_bstring.cpp | 23 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_bstring_unittest.cpp | 10 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_buffer.cpp | 10 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_util.cpp | 6 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_wstring.cpp | 12 | ||||
-rw-r--r-- | core/fxcrt/fx_xml_composer.cpp | 4 | ||||
-rw-r--r-- | core/fxcrt/fxcrt_platforms.cpp | 4 | ||||
-rw-r--r-- | core/fxcrt/fxcrt_posix.cpp | 2 | ||||
-rw-r--r-- | core/fxcrt/fxcrt_windows.cpp | 6 | ||||
-rw-r--r-- | core/fxcrt/include/fx_string.h | 14 | ||||
-rw-r--r-- | core/fxge/android/fpf_skiafontmgr.cpp | 8 |
19 files changed, 80 insertions, 79 deletions
diff --git a/core/fpdfapi/fpdf_font/fpdf_font.cpp b/core/fpdfapi/fpdf_font/fpdf_font.cpp index aff2b72960..9670aa8e7f 100644 --- a/core/fpdfapi/fpdf_font/fpdf_font.cpp +++ b/core/fpdfapi/fpdf_font/fpdf_font.cpp @@ -131,7 +131,7 @@ uint32_t CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) { // Static. uint32_t CPDF_ToUnicodeMap::StringToCode(const CFX_ByteStringC& str) { - const FX_CHAR* buf = str.GetCStr(); + const FX_CHAR* buf = str.c_str(); int len = str.GetLength(); if (len == 0) return 0; @@ -171,7 +171,7 @@ static CFX_WideString StringDataAdd(CFX_WideString str) { // Static. CFX_WideString CPDF_ToUnicodeMap::StringToWideString( const CFX_ByteStringC& str) { - const FX_CHAR* buf = str.GetCStr(); + const FX_CHAR* buf = str.c_str(); int len = str.GetLength(); if (len == 0) return CFX_WideString(); diff --git a/core/fpdfapi/fpdf_page/cpdf_generalstatedata.cpp b/core/fpdfapi/fpdf_page/cpdf_generalstatedata.cpp index 2e4b5e4dff..37ec63fb8b 100644 --- a/core/fpdfapi/fpdf_page/cpdf_generalstatedata.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_generalstatedata.cpp @@ -89,7 +89,7 @@ void CPDF_GeneralStateData::SetBlendMode(const CFX_ByteStringC& blend_mode) { if (blend_mode.GetLength() > 15) { return; } - FXSYS_memcpy(m_BlendMode, blend_mode.GetPtr(), blend_mode.GetLength()); + FXSYS_memcpy(m_BlendMode, blend_mode.raw_str(), blend_mode.GetLength()); m_BlendMode[blend_mode.GetLength()] = 0; m_BlendType = GetBlendTypeInternal(blend_mode); } diff --git a/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp b/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp index 6c1738d5a6..17fd891d1b 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp @@ -34,7 +34,7 @@ void TestArrayAccessors(const CPDF_Array* arr, CPDF_Dictionary* dict_val, CPDF_Stream* stream_val) { EXPECT_STREQ(str_val, arr->GetStringAt(index).c_str()); - EXPECT_STREQ(const_str_val, arr->GetConstStringAt(index).GetCStr()); + EXPECT_STREQ(const_str_val, arr->GetConstStringAt(index).c_str()); EXPECT_EQ(int_val, arr->GetIntegerAt(index)); EXPECT_EQ(float_val, arr->GetNumberAt(index)); EXPECT_EQ(float_val, arr->GetFloatAt(index)); @@ -207,10 +207,10 @@ TEST_F(PDFObjectsTest, GetConstString) { for (size_t i = 0; i < m_DirectObjs.size(); ++i) { if (!direct_obj_results[i]) { EXPECT_EQ(direct_obj_results[i], - m_DirectObjs[i]->GetConstString().GetCStr()); + m_DirectObjs[i]->GetConstString().c_str()); } else { EXPECT_STREQ(direct_obj_results[i], - m_DirectObjs[i]->GetConstString().GetCStr()); + m_DirectObjs[i]->GetConstString().c_str()); } } // Check indirect references. @@ -218,10 +218,10 @@ TEST_F(PDFObjectsTest, GetConstString) { nullptr, nullptr, nullptr}; for (size_t i = 0; i < m_RefObjs.size(); ++i) { if (!indirect_obj_results[i]) { - EXPECT_EQ(nullptr, m_RefObjs[i]->GetConstString().GetCStr()); + EXPECT_EQ(nullptr, m_RefObjs[i]->GetConstString().c_str()); } else { EXPECT_STREQ(indirect_obj_results[i], - m_RefObjs[i]->GetConstString().GetCStr()); + m_RefObjs[i]->GetConstString().c_str()); } } } @@ -677,7 +677,7 @@ TEST(PDFArrayTest, GetTypeAt) { 0, 0, 0, 0, 0, 0, 0}; for (size_t i = 0; i < arr->GetCount(); ++i) { EXPECT_STREQ(expected_str[i], arr->GetStringAt(i).c_str()); - EXPECT_STREQ(expected_cstr[i], arr->GetConstStringAt(i).GetCStr()); + EXPECT_STREQ(expected_cstr[i], arr->GetConstStringAt(i).c_str()); EXPECT_EQ(expected_int[i], arr->GetIntegerAt(i)); EXPECT_EQ(expected_float[i], arr->GetNumberAt(i)); EXPECT_EQ(expected_float[i], arr->GetFloatAt(i)); diff --git a/core/fpdfapi/fpdf_parser/cpdf_simple_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_simple_parser.cpp index e32021e25d..394004dfc4 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_simple_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_simple_parser.cpp @@ -12,7 +12,7 @@ CPDF_SimpleParser::CPDF_SimpleParser(const uint8_t* pData, uint32_t dwSize) : m_pData(pData), m_dwSize(dwSize), m_dwCurPos(0) {} CPDF_SimpleParser::CPDF_SimpleParser(const CFX_ByteStringC& str) - : m_pData(str.GetPtr()), m_dwSize(str.GetLength()), m_dwCurPos(0) {} + : m_pData(str.raw_str()), m_dwSize(str.GetLength()), m_dwCurPos(0) {} void CPDF_SimpleParser::ParseWord(const uint8_t*& pStart, uint32_t& dwSize) { pStart = nullptr; diff --git a/core/fpdfapi/fpdf_parser/cpdf_simple_parser_unittest.cpp b/core/fpdfapi/fpdf_parser/cpdf_simple_parser_unittest.cpp index 67287dfd5a..db3ccf5e3d 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_simple_parser_unittest.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_simple_parser_unittest.cpp @@ -54,7 +54,7 @@ TEST(SimpleParserTest, GetWord) { CFX_ByteStringC word = parser.GetWord(); EXPECT_EQ(std::string(reinterpret_cast<const char*>(data.expected), data.expected_size), - std::string(word.GetCStr(), word.GetLength())) + std::string(word.c_str(), word.GetLength())) << " for case " << i; } } diff --git a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp index d04a682b77..3deecf54ff 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp @@ -662,7 +662,7 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict, // Earlier version of PDF specification doesn't require EOL marker before // 'endstream' keyword. If keyword 'endstream' follows the bytes in // specified length, it signals the end of stream. - if (FXSYS_memcmp(m_WordBuffer, kEndStreamStr.GetPtr(), + if (FXSYS_memcmp(m_WordBuffer, kEndStreamStr.raw_str(), kEndStreamStr.GetLength()) == 0) { bSearchForKeyword = FALSE; } @@ -774,8 +774,8 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict, int numMarkers = ReadEOLMarkers(m_Pos); if (m_WordSize == static_cast<unsigned int>(kEndObjStr.GetLength()) && numMarkers != 0 && - FXSYS_memcmp(m_WordBuffer, kEndObjStr.GetPtr(), kEndObjStr.GetLength()) == - 0) { + FXSYS_memcmp(m_WordBuffer, kEndObjStr.raw_str(), + kEndObjStr.GetLength()) == 0) { m_Pos = streamStartPos; } return pStream; @@ -849,7 +849,7 @@ FX_BOOL CPDF_SyntaxParser::SearchWord(const CFX_ByteStringC& tag, if (!bForward) offset = taglen - 1; - const uint8_t* tag_data = tag.GetPtr(); + const uint8_t* tag_data = tag.raw_str(); uint8_t byte; while (1) { if (bForward) { @@ -921,7 +921,7 @@ int32_t CPDF_SyntaxParser::SearchMultiWord(const CFX_ByteStringC& tags, if (tags[i] == 0) { uint32_t len = i - start; max_len = std::max(len, max_len); - patterns[itag].m_pTag = tags.GetCStr() + start; + patterns[itag].m_pTag = tags.c_str() + start; patterns[itag].m_Len = len; patterns[itag].m_Offset = 0; start = i + 1; diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp index 8228c497e9..31e7388bd7 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp @@ -88,7 +88,7 @@ int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteStringC& key) { CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) { int size = bstr.GetLength(); - const FX_CHAR* pSrc = bstr.GetCStr(); + const FX_CHAR* pSrc = bstr.c_str(); if (!FXSYS_memchr(pSrc, '#', size)) { return bstr; } diff --git a/core/fpdfdoc/doc_basic.cpp b/core/fpdfdoc/doc_basic.cpp index 0c7f895405..ad21db815c 100644 --- a/core/fpdfdoc/doc_basic.cpp +++ b/core/fpdfdoc/doc_basic.cpp @@ -288,23 +288,23 @@ CFX_WideString CPDF_FileSpec::DecodeFileName(const CFX_WideStringC& filepath) { #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ if (filepath.Left(sizeof("/Mac") - 1) == CFX_WideStringC(L"/Mac")) - return ChangeSlashToPlatform(filepath.GetPtr() + 1); - return ChangeSlashToPlatform(filepath.GetPtr()); + return ChangeSlashToPlatform(filepath.raw_str() + 1); + return ChangeSlashToPlatform(filepath.raw_str()); #elif _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ if (filepath.GetAt(0) != '/') - return ChangeSlashToPlatform(filepath.GetPtr()); + return ChangeSlashToPlatform(filepath.raw_str()); if (filepath.GetAt(1) == '/') - return ChangeSlashToPlatform(filepath.GetPtr() + 1); + return ChangeSlashToPlatform(filepath.raw_str() + 1); if (filepath.GetAt(2) == '/') { CFX_WideString result; result += filepath.GetAt(1); result += ':'; - result += ChangeSlashToPlatform(filepath.GetPtr() + 2); + result += ChangeSlashToPlatform(filepath.raw_str() + 2); return result; } CFX_WideString result; result += '\\'; - result += ChangeSlashToPlatform(filepath.GetPtr()); + result += ChangeSlashToPlatform(filepath.raw_str()); return result; #else return filepath; @@ -356,27 +356,27 @@ CFX_WideString CPDF_FileSpec::EncodeFileName(const CFX_WideStringC& filepath) { if (filepath.GetAt(2) != '\\') { result += '/'; } - result += ChangeSlashToPDF(filepath.GetPtr() + 2); + result += ChangeSlashToPDF(filepath.raw_str() + 2); return result; } if (filepath.GetAt(0) == '\\' && filepath.GetAt(1) == '\\') { - return ChangeSlashToPDF(filepath.GetPtr() + 1); + return ChangeSlashToPDF(filepath.raw_str() + 1); } if (filepath.GetAt(0) == '\\') { CFX_WideString result; result = '/'; - result += ChangeSlashToPDF(filepath.GetPtr()); + result += ChangeSlashToPDF(filepath.raw_str()); return result; } - return ChangeSlashToPDF(filepath.GetPtr()); + return ChangeSlashToPDF(filepath.raw_str()); #elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ if (filepath.Left(sizeof("Mac") - 1) == FX_WSTRC(L"Mac")) { CFX_WideString result; result = '/'; - result += ChangeSlashToPDF(filepath.GetPtr()); + result += ChangeSlashToPDF(filepath.raw_str()); return result; } - return ChangeSlashToPDF(filepath.GetPtr()); + return ChangeSlashToPDF(filepath.raw_str()); #else return filepath; #endif @@ -513,5 +513,5 @@ int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const { return -1; } int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { - return GetPageByLabel(PDF_EncodeText(wsLabel.GetPtr()).AsByteStringC()); + return GetPageByLabel(PDF_EncodeText(wsLabel.raw_str()).AsByteStringC()); } diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp index d7bfac690e..aa63edfdc1 100644 --- a/core/fxcrt/fx_basic_bstring.cpp +++ b/core/fxcrt/fx_basic_bstring.cpp @@ -137,8 +137,7 @@ CFX_ByteString::CFX_ByteString(char ch) { CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& stringSrc) { if (!stringSrc.IsEmpty()) { - m_pData.Reset( - StringData::Create(stringSrc.GetCStr(), stringSrc.GetLength())); + m_pData.Reset(StringData::Create(stringSrc.c_str(), stringSrc.GetLength())); } } @@ -149,8 +148,8 @@ CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& str1, return; m_pData.Reset(StringData::Create(nNewLen)); - m_pData->CopyContents(str1.GetCStr(), str1.GetLength()); - m_pData->CopyContentsAt(str1.GetLength(), str2.GetCStr(), str2.GetLength()); + m_pData->CopyContents(str1.c_str(), str1.GetLength()); + m_pData->CopyContentsAt(str1.GetLength(), str2.c_str(), str2.GetLength()); } CFX_ByteString::~CFX_ByteString() {} @@ -168,7 +167,7 @@ const CFX_ByteString& CFX_ByteString::operator=(const CFX_ByteStringC& str) { if (str.IsEmpty()) clear(); else - AssignCopy(str.GetCStr(), str.GetLength()); + AssignCopy(str.c_str(), str.GetLength()); return *this; } @@ -216,7 +215,7 @@ const CFX_ByteString& CFX_ByteString::operator+=(const CFX_ByteString& str) { const CFX_ByteString& CFX_ByteString::operator+=(const CFX_ByteStringC& str) { if (!str.IsEmpty()) - Concat(str.GetCStr(), str.GetLength()); + Concat(str.c_str(), str.GetLength()); return *this; } @@ -237,7 +236,7 @@ bool CFX_ByteString::operator==(const CFX_ByteStringC& str) const { return str.IsEmpty(); return m_pData->m_nDataLength == str.GetLength() && - FXSYS_memcmp(m_pData->m_String, str.GetCStr(), str.GetLength()) == 0; + FXSYS_memcmp(m_pData->m_String, str.c_str(), str.GetLength()) == 0; } bool CFX_ByteString::operator==(const CFX_ByteString& other) const { @@ -261,7 +260,7 @@ bool CFX_ByteString::EqualNoCase(const CFX_ByteStringC& str) const { return false; const uint8_t* pThis = (const uint8_t*)m_pData->m_String; - const uint8_t* pThat = str.GetPtr(); + const uint8_t* pThat = str.raw_str(); for (FX_STRSIZE i = 0; i < len; i++) { if ((*pThis) != (*pThat)) { uint8_t bThis = *pThis; @@ -768,7 +767,7 @@ FX_STRSIZE CFX_ByteString::Find(const CFX_ByteStringC& pSub, const FX_CHAR* pStr = FX_strstr(m_pData->m_String + nStart, m_pData->m_nDataLength - nStart, - pSub.GetCStr(), pSub.GetLength()); + pSub.c_str(), pSub.GetLength()); return pStr ? (int)(pStr - m_pData->m_String) : -1; } @@ -821,7 +820,7 @@ FX_STRSIZE CFX_ByteString::Replace(const CFX_ByteStringC& pOld, FX_CHAR* pEnd = m_pData->m_String + m_pData->m_nDataLength; while (1) { const FX_CHAR* pTarget = FX_strstr(pStart, (FX_STRSIZE)(pEnd - pStart), - pOld.GetCStr(), nSourceLen); + pOld.c_str(), nSourceLen); if (!pTarget) break; @@ -844,10 +843,10 @@ FX_STRSIZE CFX_ByteString::Replace(const CFX_ByteStringC& pOld, FX_CHAR* pDest = pNewData->m_String; for (FX_STRSIZE i = 0; i < nCount; i++) { const FX_CHAR* pTarget = FX_strstr(pStart, (FX_STRSIZE)(pEnd - pStart), - pOld.GetCStr(), nSourceLen); + pOld.c_str(), nSourceLen); FXSYS_memcpy(pDest, pStart, pTarget - pStart); pDest += pTarget - pStart; - FXSYS_memcpy(pDest, pNew.GetCStr(), pNew.GetLength()); + FXSYS_memcpy(pDest, pNew.c_str(), pNew.GetLength()); pDest += pNew.GetLength(); pStart = pTarget + nSourceLen; } diff --git a/core/fxcrt/fx_basic_bstring_unittest.cpp b/core/fxcrt/fx_basic_bstring_unittest.cpp index 1f9d515c38..73235ddf5f 100644 --- a/core/fxcrt/fx_basic_bstring_unittest.cpp +++ b/core/fxcrt/fx_basic_bstring_unittest.cpp @@ -251,7 +251,7 @@ TEST(fxcrt, ByteStringOperatorNE) { TEST(fxcrt, ByteStringCNull) { CFX_ByteStringC null_string; - EXPECT_EQ(null_string.GetPtr(), nullptr); + EXPECT_EQ(null_string.raw_str(), nullptr); EXPECT_EQ(null_string.GetLength(), 0); EXPECT_TRUE(null_string.IsEmpty()); @@ -259,27 +259,27 @@ TEST(fxcrt, ByteStringCNull) { EXPECT_EQ(null_string, another_null_string); CFX_ByteStringC copied_null_string(null_string); - EXPECT_EQ(copied_null_string.GetPtr(), nullptr); + EXPECT_EQ(copied_null_string.raw_str(), nullptr); EXPECT_EQ(copied_null_string.GetLength(), 0); EXPECT_TRUE(copied_null_string.IsEmpty()); EXPECT_EQ(null_string, copied_null_string); CFX_ByteStringC empty_string(""); // Pointer to NUL, not NULL pointer. - EXPECT_NE(empty_string.GetPtr(), nullptr); + EXPECT_NE(empty_string.raw_str(), nullptr); EXPECT_EQ(empty_string.GetLength(), 0); EXPECT_TRUE(empty_string.IsEmpty()); EXPECT_EQ(null_string, empty_string); CFX_ByteStringC assigned_null_string("initially not NULL"); assigned_null_string = null_string; - EXPECT_EQ(assigned_null_string.GetPtr(), nullptr); + EXPECT_EQ(assigned_null_string.raw_str(), nullptr); EXPECT_EQ(assigned_null_string.GetLength(), 0); EXPECT_TRUE(assigned_null_string.IsEmpty()); EXPECT_EQ(null_string, assigned_null_string); CFX_ByteStringC assigned_nullptr_string("initially not NULL"); assigned_nullptr_string = (const FX_CHAR*)nullptr; - EXPECT_EQ(assigned_nullptr_string.GetPtr(), nullptr); + EXPECT_EQ(assigned_nullptr_string.raw_str(), nullptr); EXPECT_EQ(assigned_nullptr_string.GetLength(), 0); EXPECT_TRUE(assigned_nullptr_string.IsEmpty()); EXPECT_EQ(null_string, assigned_nullptr_string); diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp index de7bff2401..9d0397efeb 100644 --- a/core/fxcrt/fx_basic_buffer.cpp +++ b/core/fxcrt/fx_basic_buffer.cpp @@ -105,7 +105,7 @@ CFX_ByteStringC CFX_ByteTextBuf::GetByteString() const { } CFX_ByteTextBuf& CFX_ByteTextBuf::operator<<(const CFX_ByteStringC& lpsz) { - AppendBlock(lpsz.GetPtr(), lpsz.GetLength()); + AppendBlock(lpsz.raw_str(), lpsz.GetLength()); return *this; } @@ -142,7 +142,7 @@ void CFX_WideTextBuf::AppendChar(FX_WCHAR ch) { } CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideStringC& str) { - AppendBlock(str.GetPtr(), str.GetLength() * sizeof(FX_WCHAR)); + AppendBlock(str.raw_str(), str.GetLength() * sizeof(FX_WCHAR)); return *this; } @@ -228,10 +228,10 @@ CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(const CFX_ByteStringC& bstr) { int len = bstr.GetLength(); if (m_pStream) { m_pStream->WriteBlock(&len, sizeof(int)); - m_pStream->WriteBlock(bstr.GetPtr(), len); + m_pStream->WriteBlock(bstr.raw_str(), len); } else { m_SavingBuf.AppendBlock(&len, sizeof(int)); - m_SavingBuf.AppendBlock(bstr.GetPtr(), len); + m_SavingBuf.AppendBlock(bstr.raw_str(), len); } return *this; } @@ -419,7 +419,7 @@ int32_t CFX_FileBufferArchive::AppendDWord(uint32_t i) { } int32_t CFX_FileBufferArchive::AppendString(const CFX_ByteStringC& lpsz) { - return AppendBlock(lpsz.GetPtr(), lpsz.GetLength()); + return AppendBlock(lpsz.raw_str(), lpsz.GetLength()); } void CFX_FileBufferArchive::AttachFile(IFX_StreamWrite* pFile) { diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp index 3791862066..4374dec779 100644 --- a/core/fxcrt/fx_basic_util.cpp +++ b/core/fxcrt/fx_basic_util.cpp @@ -95,10 +95,10 @@ void CFX_PrivateData::ClearAll() { m_DataList.RemoveAll(); } void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) { - if (!FXSYS_memchr(strc.GetPtr(), '.', strc.GetLength())) { + if (!FXSYS_memchr(strc.raw_str(), '.', strc.GetLength())) { bInteger = TRUE; int cc = 0, integer = 0; - const FX_CHAR* str = strc.GetCStr(); + const FX_CHAR* str = strc.c_str(); int len = strc.GetLength(); FX_BOOL bNegative = FALSE; if (str[0] == '+') { @@ -129,7 +129,7 @@ FX_FLOAT FX_atof(const CFX_ByteStringC& strc) { } int cc = 0; FX_BOOL bNegative = FALSE; - const FX_CHAR* str = strc.GetCStr(); + const FX_CHAR* str = strc.c_str(); int len = strc.GetLength(); if (str[0] == '+') { cc++; diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp index 9c17948c34..8940c1a37f 100644 --- a/core/fxcrt/fx_basic_wstring.cpp +++ b/core/fxcrt/fx_basic_wstring.cpp @@ -103,7 +103,7 @@ CFX_WideString::CFX_WideString(const CFX_WideStringC& str) { } m_pData = StringData::Create(str.GetLength()); if (m_pData) { - FXSYS_memcpy(m_pData->m_String, str.GetPtr(), + FXSYS_memcpy(m_pData->m_String, str.raw_str(), str.GetLength() * sizeof(FX_WCHAR)); } } @@ -116,9 +116,9 @@ CFX_WideString::CFX_WideString(const CFX_WideStringC& str1, } m_pData = StringData::Create(nNewLen); if (m_pData) { - FXSYS_memcpy(m_pData->m_String, str1.GetPtr(), + FXSYS_memcpy(m_pData->m_String, str1.raw_str(), str1.GetLength() * sizeof(FX_WCHAR)); - FXSYS_memcpy(m_pData->m_String + str1.GetLength(), str2.GetPtr(), + FXSYS_memcpy(m_pData->m_String + str1.GetLength(), str2.raw_str(), str2.GetLength() * sizeof(FX_WCHAR)); } } @@ -151,7 +151,7 @@ const CFX_WideString& CFX_WideString::operator=( if (stringSrc.IsEmpty()) { Empty(); } else { - AssignCopy(stringSrc.GetLength(), stringSrc.GetPtr()); + AssignCopy(stringSrc.GetLength(), stringSrc.raw_str()); } return *this; } @@ -195,7 +195,7 @@ const CFX_WideString& CFX_WideString::operator+=(const CFX_WideStringC& str) { if (str.IsEmpty()) { return *this; } - ConcatInPlace(str.GetLength(), str.GetPtr()); + ConcatInPlace(str.GetLength(), str.raw_str()); return *this; } bool CFX_WideString::operator==(const wchar_t* ptr) const { @@ -213,7 +213,7 @@ bool CFX_WideString::operator==(const CFX_WideStringC& str) const { return str.IsEmpty(); return str.GetLength() == m_pData->m_nDataLength && - wmemcmp(str.GetPtr(), m_pData->m_String, m_pData->m_nDataLength) == 0; + wmemcmp(str.raw_str(), m_pData->m_String, m_pData->m_nDataLength) == 0; } bool CFX_WideString::operator==(const CFX_WideString& other) const { if (IsEmpty()) diff --git a/core/fxcrt/fx_xml_composer.cpp b/core/fxcrt/fx_xml_composer.cpp index 1af6952fdb..576ff95432 100644 --- a/core/fxcrt/fx_xml_composer.cpp +++ b/core/fxcrt/fx_xml_composer.cpp @@ -23,9 +23,9 @@ void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName, if (iStart >= bsFullName.GetLength()) { bsName = bsFullName; } else { - bsSpace = CFX_ByteStringC(bsFullName.GetCStr(), iStart); + bsSpace = CFX_ByteStringC(bsFullName.c_str(), iStart); iStart++; - bsName = CFX_ByteStringC(bsFullName.GetCStr() + iStart, + bsName = CFX_ByteStringC(bsFullName.c_str() + iStart, bsFullName.GetLength() - iStart); } } diff --git a/core/fxcrt/fxcrt_platforms.cpp b/core/fxcrt/fxcrt_platforms.cpp index 16e1a0976d..8f134c751d 100644 --- a/core/fxcrt/fxcrt_platforms.cpp +++ b/core/fxcrt/fxcrt_platforms.cpp @@ -44,7 +44,7 @@ FX_BOOL CFXCRT_FileAccess_CRT::Open(const CFX_ByteStringC& fileName, } CFX_ByteString strMode; FXCRT_GetFileModeString(dwMode, strMode); - m_hFile = FXSYS_fopen(fileName.GetCStr(), strMode.c_str()); + m_hFile = FXSYS_fopen(fileName.c_str(), strMode.c_str()); return m_hFile != NULL; } FX_BOOL CFXCRT_FileAccess_CRT::Open(const CFX_WideStringC& fileName, @@ -54,7 +54,7 @@ FX_BOOL CFXCRT_FileAccess_CRT::Open(const CFX_WideStringC& fileName, } CFX_WideString strMode; FXCRT_GetFileModeString(dwMode, strMode); - m_hFile = FXSYS_wfopen(fileName.GetPtr(), strMode.c_str()); + m_hFile = FXSYS_wfopen(fileName.raw_str(), strMode.c_str()); return m_hFile != NULL; } void CFXCRT_FileAccess_CRT::Close() { diff --git a/core/fxcrt/fxcrt_posix.cpp b/core/fxcrt/fxcrt_posix.cpp index 0226313934..a18bb69c55 100644 --- a/core/fxcrt/fxcrt_posix.cpp +++ b/core/fxcrt/fxcrt_posix.cpp @@ -40,7 +40,7 @@ FX_BOOL CFXCRT_FileAccess_Posix::Open(const CFX_ByteStringC& fileName, } int32_t nFlags, nMasks; FXCRT_Posix_GetFileMode(dwMode, nFlags, nMasks); - m_nFD = open(fileName.GetCStr(), nFlags, nMasks); + m_nFD = open(fileName.c_str(), nFlags, nMasks); return m_nFD > -1; } FX_BOOL CFXCRT_FileAccess_Posix::Open(const CFX_WideStringC& fileName, diff --git a/core/fxcrt/fxcrt_windows.cpp b/core/fxcrt/fxcrt_windows.cpp index 340d22585f..8c7c0d8176 100644 --- a/core/fxcrt/fxcrt_windows.cpp +++ b/core/fxcrt/fxcrt_windows.cpp @@ -47,8 +47,8 @@ FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_ByteStringC& fileName, } uint32_t dwAccess, dwShare, dwCreation; FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation); - m_hFile = ::CreateFileA(fileName.GetCStr(), dwAccess, dwShare, NULL, - dwCreation, FILE_ATTRIBUTE_NORMAL, NULL); + m_hFile = ::CreateFileA(fileName.c_str(), dwAccess, dwShare, NULL, dwCreation, + FILE_ATTRIBUTE_NORMAL, NULL); if (m_hFile == INVALID_HANDLE_VALUE) { m_hFile = NULL; } @@ -61,7 +61,7 @@ FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_WideStringC& fileName, } uint32_t dwAccess, dwShare, dwCreation; FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation); - m_hFile = ::CreateFileW((LPCWSTR)fileName.GetPtr(), dwAccess, dwShare, NULL, + m_hFile = ::CreateFileW((LPCWSTR)fileName.raw_str(), dwAccess, dwShare, NULL, dwCreation, FILE_ATTRIBUTE_NORMAL, NULL); if (m_hFile == INVALID_HANDLE_VALUE) { m_hFile = NULL; diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h index cbf8c4de2f..d48b26c30f 100644 --- a/core/fxcrt/include/fx_string.h +++ b/core/fxcrt/include/fx_string.h @@ -90,8 +90,10 @@ class CFX_ByteStringC { uint32_t GetID(FX_STRSIZE start_pos = 0) const; - const uint8_t* GetPtr() const { return m_Ptr; } - const FX_CHAR* GetCStr() const { return (const FX_CHAR*)m_Ptr; } + const uint8_t* raw_str() const { return m_Ptr; } + const FX_CHAR* c_str() const { + return reinterpret_cast<const FX_CHAR*>(m_Ptr); + } FX_STRSIZE GetLength() const { return m_Length; } bool IsEmpty() const { return m_Length == 0; } @@ -178,7 +180,7 @@ class CFX_ByteString { : nullptr; } - // Implicit conversiont to uint8_t* -- deprecated. + // Implicit conversion to uint8_t* -- deprecated. operator const uint8_t*() const { return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String) : nullptr; @@ -454,7 +456,7 @@ class CFX_WideStringC { bool operator!=(const wchar_t* ptr) const { return !(*this == ptr); } bool operator!=(const CFX_WideStringC& str) const { return !(*this == str); } - const FX_WCHAR* GetPtr() const { return m_Ptr; } + const FX_WCHAR* raw_str() const { return m_Ptr; } FX_STRSIZE GetLength() const { return m_Length; } bool IsEmpty() const { return m_Length == 0; } @@ -752,7 +754,7 @@ inline bool operator!=(const CFX_WideStringC& lhs, const CFX_WideString& rhs) { CFX_ByteString FX_UTF8Encode(const FX_WCHAR* pwsStr, FX_STRSIZE len); inline CFX_ByteString FX_UTF8Encode(const CFX_WideStringC& wsStr) { - return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength()); + return FX_UTF8Encode(wsStr.raw_str(), wsStr.GetLength()); } inline CFX_ByteString FX_UTF8Encode(const CFX_WideString& wsStr) { return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()); @@ -760,7 +762,7 @@ inline CFX_ByteString FX_UTF8Encode(const CFX_WideString& wsStr) { FX_FLOAT FX_atof(const CFX_ByteStringC& str); inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { - return FX_atof(FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength()).c_str()); + return FX_atof(FX_UTF8Encode(wsStr.raw_str(), wsStr.GetLength()).c_str()); } void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData); FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); diff --git a/core/fxge/android/fpf_skiafontmgr.cpp b/core/fxge/android/fpf_skiafontmgr.cpp index c9748da859..7d0d2de9e2 100644 --- a/core/fxge/android/fpf_skiafontmgr.cpp +++ b/core/fxge/android/fpf_skiafontmgr.cpp @@ -176,7 +176,7 @@ static uint32_t FPF_SkiaGetCharset(uint8_t uCharset) { static uint32_t FPF_SKIANormalizeFontName(const CFX_ByteStringC& bsfamily) { uint32_t dwHash = 0; int32_t iLength = bsfamily.GetLength(); - const FX_CHAR* pBuffer = bsfamily.GetCStr(); + const FX_CHAR* pBuffer = bsfamily.c_str(); for (int32_t i = 0; i < iLength; i++) { FX_CHAR ch = pBuffer[i]; if (ch == ' ' || ch == '-' || ch == ',') { @@ -372,7 +372,7 @@ FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const CFX_ByteStringC& bsFile, } FXFT_Open_Args args; args.flags = FT_OPEN_PATHNAME; - args.pathname = (FT_String*)bsFile.GetCStr(); + args.pathname = static_cast<FT_String*>(bsFile.c_str()); FXFT_Face face; if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) { return FALSE; @@ -401,7 +401,7 @@ FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const uint8_t* pBuffer, return face; } void CFPF_SkiaFontMgr::ScanPath(const CFX_ByteStringC& path) { - void* handle = FX_OpenFolder(path.GetCStr()); + void* handle = FX_OpenFolder(path.c_str()); if (!handle) { return; } @@ -434,7 +434,7 @@ void CFPF_SkiaFontMgr::ScanFile(const CFX_ByteStringC& file) { FXFT_Face face = GetFontFace(file); if (face) { CFPF_SkiaPathFont* pFontDesc = new CFPF_SkiaPathFont; - pFontDesc->SetPath(file.GetCStr()); + pFontDesc->SetPath(file.c_str()); ReportFace(face, pFontDesc); m_FontFaces.push_back(pFontDesc); FXFT_Done_Face(face); |