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/fxcrt | |
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/fxcrt')
-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 |
10 files changed, 46 insertions, 45 deletions
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); |