summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfdoc/doc_basic_unittest.cpp18
-rw-r--r--core/fpdfdoc/doc_formcontrol.cpp2
-rw-r--r--core/fxcrt/fx_basic_bstring.cpp28
-rw-r--r--core/fxcrt/fx_basic_wstring.cpp28
-rw-r--r--core/fxcrt/include/fx_string.h40
5 files changed, 44 insertions, 72 deletions
diff --git a/core/fpdfdoc/doc_basic_unittest.cpp b/core/fpdfdoc/doc_basic_unittest.cpp
index a84f334ebb..0ab70c9304 100644
--- a/core/fpdfdoc/doc_basic_unittest.cpp
+++ b/core/fpdfdoc/doc_basic_unittest.cpp
@@ -52,10 +52,10 @@ TEST(doc_basic_filespec, EncodeDecodeFileName) {
};
for (const auto& data : test_data) {
CFX_WideString encoded_str = CPDF_FileSpec::EncodeFileName(data.input);
- EXPECT_TRUE(encoded_str.Equal(data.expected));
+ EXPECT_TRUE(encoded_str == data.expected);
// DecodeFileName is the reverse procedure of EncodeFileName.
CFX_WideString decoded_str = CPDF_FileSpec::DecodeFileName(data.expected);
- EXPECT_TRUE(decoded_str.Equal(data.input));
+ EXPECT_TRUE(decoded_str == data.input);
}
}
@@ -78,7 +78,7 @@ TEST(doc_basic_filespec, GetFileName) {
CPDF_FileSpec file_spec(str_obj.get());
CFX_WideString file_name;
EXPECT_TRUE(file_spec.GetFileName(&file_name));
- EXPECT_TRUE(file_name.Equal(test_data.expected));
+ EXPECT_TRUE(file_name == test_data.expected);
}
{
// Dictionary object.
@@ -111,14 +111,14 @@ TEST(doc_basic_filespec, GetFileName) {
for (int i = 0; i < 5; ++i) {
dict_obj->SetAt(keywords[i], new CPDF_String(test_data[i].input));
EXPECT_TRUE(file_spec.GetFileName(&file_name));
- EXPECT_TRUE(file_name.Equal(test_data[i].expected));
+ EXPECT_TRUE(file_name == test_data[i].expected);
}
// With all the former fields and 'FS' field suggests 'URL' type.
dict_obj->SetAtString("FS", "URL");
EXPECT_TRUE(file_spec.GetFileName(&file_name));
// Url string is not decoded.
- EXPECT_TRUE(file_name.Equal(test_data[4].input));
+ EXPECT_TRUE(file_name == test_data[4].input);
}
{
// Invalid object.
@@ -152,7 +152,7 @@ TEST(doc_basic_filespec, SetFileName) {
// Check we can get the file name back.
CFX_WideString file_name;
EXPECT_TRUE(file_spec1.GetFileName(&file_name));
- EXPECT_TRUE(file_name.Equal(test_data.input));
+ EXPECT_TRUE(file_name == test_data.input);
// Dictionary object.
ScopedDict dict_obj(new CPDF_Dictionary);
@@ -160,10 +160,10 @@ TEST(doc_basic_filespec, SetFileName) {
file_spec2.SetFileName(test_data.input);
// Check internal object value.
file_name = dict_obj->GetUnicodeTextBy("F");
- EXPECT_TRUE(file_name.Equal(test_data.expected));
+ EXPECT_TRUE(file_name == test_data.expected);
file_name = dict_obj->GetUnicodeTextBy("UF");
- EXPECT_TRUE(file_name.Equal(test_data.expected));
+ EXPECT_TRUE(file_name == test_data.expected);
// Check we can get the file name back.
EXPECT_TRUE(file_spec2.GetFileName(&file_name));
- EXPECT_TRUE(file_name.Equal(test_data.input));
+ EXPECT_TRUE(file_name == test_data.input);
}
diff --git a/core/fpdfdoc/doc_formcontrol.cpp b/core/fpdfdoc/doc_formcontrol.cpp
index 255b5e9a70..1fcc4a386b 100644
--- a/core/fpdfdoc/doc_formcontrol.cpp
+++ b/core/fpdfdoc/doc_formcontrol.cpp
@@ -190,7 +190,7 @@ CPDF_FormControl::HighlightingMode CPDF_FormControl::GetHighlightingMode() {
}
CFX_ByteString csH = m_pWidgetDict->GetStringBy("H", "I");
for (int i = 0; g_sHighlightingMode[i]; ++i) {
- if (csH.Equal(g_sHighlightingMode[i]))
+ if (csH == g_sHighlightingMode[i])
return static_cast<HighlightingMode>(i);
}
return Invert;
diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp
index 10bc05bcc5..08f5dca664 100644
--- a/core/fxcrt/fx_basic_bstring.cpp
+++ b/core/fxcrt/fx_basic_bstring.cpp
@@ -217,30 +217,30 @@ const CFX_ByteString& CFX_ByteString::operator+=(const CFX_ByteStringC& str) {
ConcatInPlace(str.GetLength(), str.GetCStr());
return *this;
}
-bool CFX_ByteString::Equal(const char* ptr) const {
- if (!m_pData) {
- return !ptr || ptr[0] == '\0';
- }
- if (!ptr) {
+bool CFX_ByteString::operator==(const char* ptr) const {
+ if (!m_pData)
+ return !ptr || !ptr[0];
+
+ if (!ptr)
return m_pData->m_nDataLength == 0;
- }
+
return FXSYS_strlen(ptr) == m_pData->m_nDataLength &&
FXSYS_memcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
}
-bool CFX_ByteString::Equal(const CFX_ByteStringC& str) const {
- if (!m_pData) {
+bool CFX_ByteString::operator==(const CFX_ByteStringC& str) const {
+ if (!m_pData)
return str.IsEmpty();
- }
+
return m_pData->m_nDataLength == str.GetLength() &&
FXSYS_memcmp(m_pData->m_String, str.GetCStr(), str.GetLength()) == 0;
}
-bool CFX_ByteString::Equal(const CFX_ByteString& other) const {
- if (IsEmpty()) {
+bool CFX_ByteString::operator==(const CFX_ByteString& other) const {
+ if (IsEmpty())
return other.IsEmpty();
- }
- if (other.IsEmpty()) {
+
+ if (other.IsEmpty())
return false;
- }
+
return other.m_pData->m_nDataLength == m_pData->m_nDataLength &&
FXSYS_memcmp(other.m_pData->m_String, m_pData->m_String,
m_pData->m_nDataLength) == 0;
diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp
index 642b75eafe..9c17948c34 100644
--- a/core/fxcrt/fx_basic_wstring.cpp
+++ b/core/fxcrt/fx_basic_wstring.cpp
@@ -198,30 +198,30 @@ const CFX_WideString& CFX_WideString::operator+=(const CFX_WideStringC& str) {
ConcatInPlace(str.GetLength(), str.GetPtr());
return *this;
}
-bool CFX_WideString::Equal(const wchar_t* ptr) const {
- if (!m_pData) {
- return !ptr || ptr[0] == L'\0';
- }
- if (!ptr) {
+bool CFX_WideString::operator==(const wchar_t* ptr) const {
+ if (!m_pData)
+ return !ptr || !ptr[0];
+
+ if (!ptr)
return m_pData->m_nDataLength == 0;
- }
+
return wcslen(ptr) == static_cast<size_t>(m_pData->m_nDataLength) &&
wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
}
-bool CFX_WideString::Equal(const CFX_WideStringC& str) const {
- if (!m_pData) {
+bool CFX_WideString::operator==(const CFX_WideStringC& str) const {
+ if (!m_pData)
return str.IsEmpty();
- }
+
return str.GetLength() == m_pData->m_nDataLength &&
wmemcmp(str.GetPtr(), m_pData->m_String, m_pData->m_nDataLength) == 0;
}
-bool CFX_WideString::Equal(const CFX_WideString& other) const {
- if (IsEmpty()) {
+bool CFX_WideString::operator==(const CFX_WideString& other) const {
+ if (IsEmpty())
return other.IsEmpty();
- }
- if (other.IsEmpty()) {
+
+ if (other.IsEmpty())
return false;
- }
+
return other.m_pData->m_nDataLength == m_pData->m_nDataLength &&
wmemcmp(other.m_pData->m_String, m_pData->m_String,
m_pData->m_nDataLength) == 0;
diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h
index 0aa34171c2..26000dd6c1 100644
--- a/core/fxcrt/include/fx_string.h
+++ b/core/fxcrt/include/fx_string.h
@@ -194,16 +194,11 @@ class CFX_ByteString {
bool IsEmpty() const { return !GetLength(); }
int Compare(const CFX_ByteStringC& str) const;
-
- bool Equal(const char* ptr) const;
- bool Equal(const CFX_ByteStringC& str) const;
- bool Equal(const CFX_ByteString& other) const;
-
bool EqualNoCase(const CFX_ByteStringC& str) const;
- bool operator==(const char* ptr) const { return Equal(ptr); }
- bool operator==(const CFX_ByteStringC& str) const { return Equal(str); }
- bool operator==(const CFX_ByteString& other) const { return Equal(other); }
+ bool operator==(const char* ptr) const;
+ bool operator==(const CFX_ByteStringC& str) const;
+ bool operator==(const CFX_ByteString& other) const;
bool operator!=(const char* ptr) const { return !(*this == ptr); }
bool operator!=(const CFX_ByteStringC& str) const { return !(*this == str); }
@@ -588,26 +583,20 @@ class CFX_WideString {
void Empty();
bool IsEmpty() const { return !GetLength(); }
-
FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
const CFX_WideString& operator=(const FX_WCHAR* str);
-
const CFX_WideString& operator=(const CFX_WideString& stringSrc);
-
const CFX_WideString& operator=(const CFX_WideStringC& stringSrc);
const CFX_WideString& operator+=(const FX_WCHAR* str);
-
const CFX_WideString& operator+=(FX_WCHAR ch);
-
const CFX_WideString& operator+=(const CFX_WideString& str);
-
const CFX_WideString& operator+=(const CFX_WideStringC& str);
- bool operator==(const wchar_t* ptr) const { return Equal(ptr); }
- bool operator==(const CFX_WideStringC& str) const { return Equal(str); }
- bool operator==(const CFX_WideString& other) const { return Equal(other); }
+ bool operator==(const wchar_t* ptr) const;
+ bool operator==(const CFX_WideStringC& str) const;
+ bool operator==(const CFX_WideString& other) const;
bool operator!=(const wchar_t* ptr) const { return !(*this == ptr); }
bool operator!=(const CFX_WideStringC& str) const { return !(*this == str); }
@@ -632,51 +621,34 @@ class CFX_WideString {
void SetAt(FX_STRSIZE nIndex, FX_WCHAR ch);
int Compare(const FX_WCHAR* str) const;
-
int Compare(const CFX_WideString& str) const;
-
int CompareNoCase(const FX_WCHAR* str) const;
- bool Equal(const wchar_t* ptr) const;
- bool Equal(const CFX_WideStringC& str) const;
- bool Equal(const CFX_WideString& other) const;
CFX_WideString Mid(FX_STRSIZE first) const;
-
CFX_WideString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
-
CFX_WideString Left(FX_STRSIZE count) const;
-
CFX_WideString Right(FX_STRSIZE count) const;
FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch);
-
FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
void Format(const FX_WCHAR* lpszFormat, ...);
-
void FormatV(const FX_WCHAR* lpszFormat, va_list argList);
void MakeLower();
-
void MakeUpper();
void TrimRight();
-
void TrimRight(FX_WCHAR chTarget);
-
void TrimRight(const FX_WCHAR* lpszTargets);
void TrimLeft();
-
void TrimLeft(FX_WCHAR chTarget);
-
void TrimLeft(const FX_WCHAR* lpszTargets);
void Reserve(FX_STRSIZE len);
-
FX_WCHAR* GetBuffer(FX_STRSIZE len);
-
void ReleaseBuffer(FX_STRSIZE len = -1);
int GetInteger() const;