summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/bytestring.cpp32
-rw-r--r--core/fxcrt/bytestring.h7
-rw-r--r--core/fxcrt/bytestring_unittest.cpp6
-rw-r--r--core/fxcrt/string_view_template.h5
-rw-r--r--core/fxcrt/widestring.cpp42
-rw-r--r--core/fxcrt/widestring.h5
-rw-r--r--core/fxcrt/widestring_unittest.cpp4
7 files changed, 47 insertions, 54 deletions
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp
index 4c4bd57393..3e4861ae60 100644
--- a/core/fxcrt/bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -549,46 +549,44 @@ size_t ByteString::Insert(size_t location, char ch) {
return new_length;
}
-pdfium::Optional<size_t> ByteString::Find(char ch, size_t start) const {
+Optional<size_t> ByteString::Find(char ch, size_t start) const {
if (!m_pData)
- return pdfium::Optional<size_t>();
+ return Optional<size_t>();
if (!IsValidIndex(start))
- return pdfium::Optional<size_t>();
+ return Optional<size_t>();
const char* pStr = static_cast<const char*>(
memchr(m_pData->m_String + start, ch, m_pData->m_nDataLength - start));
- return pStr ? pdfium::Optional<size_t>(
- static_cast<size_t>(pStr - m_pData->m_String))
- : pdfium::Optional<size_t>();
+ return pStr ? Optional<size_t>(static_cast<size_t>(pStr - m_pData->m_String))
+ : Optional<size_t>();
}
-pdfium::Optional<size_t> ByteString::Find(const ByteStringView& subStr,
- size_t start) const {
+Optional<size_t> ByteString::Find(const ByteStringView& subStr,
+ size_t start) const {
if (!m_pData)
- return pdfium::Optional<size_t>();
+ return Optional<size_t>();
if (!IsValidIndex(start))
- return pdfium::Optional<size_t>();
+ return Optional<size_t>();
const char* pStr =
FX_strstr(m_pData->m_String + start, m_pData->m_nDataLength - start,
subStr.unterminated_c_str(), subStr.GetLength());
- return pStr ? pdfium::Optional<size_t>(
- static_cast<size_t>(pStr - m_pData->m_String))
- : pdfium::Optional<size_t>();
+ return pStr ? Optional<size_t>(static_cast<size_t>(pStr - m_pData->m_String))
+ : Optional<size_t>();
}
-pdfium::Optional<size_t> ByteString::ReverseFind(char ch) const {
+Optional<size_t> ByteString::ReverseFind(char ch) const {
if (!m_pData)
- return pdfium::Optional<size_t>();
+ return Optional<size_t>();
size_t nLength = m_pData->m_nDataLength;
while (nLength--) {
if (m_pData->m_String[nLength] == ch)
- return pdfium::Optional<size_t>(nLength);
+ return Optional<size_t>(nLength);
}
- return pdfium::Optional<size_t>();
+ return Optional<size_t>();
}
void ByteString::MakeLower() {
diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h
index 916820656d..70f10dcaba 100644
--- a/core/fxcrt/bytestring.h
+++ b/core/fxcrt/bytestring.h
@@ -152,10 +152,9 @@ class ByteString {
ByteString Left(size_t count) const;
ByteString Right(size_t count) const;
- pdfium::Optional<size_t> Find(const ByteStringView& lpszSub,
- size_t start = 0) const;
- pdfium::Optional<size_t> Find(char ch, size_t start = 0) const;
- pdfium::Optional<size_t> ReverseFind(char ch) const;
+ Optional<size_t> Find(const ByteStringView& lpszSub, size_t start = 0) const;
+ Optional<size_t> Find(char ch, size_t start = 0) const;
+ Optional<size_t> ReverseFind(char ch) const;
bool Contains(const ByteStringView& lpszSub, size_t start = 0) const {
return Find(lpszSub, start).has_value();
diff --git a/core/fxcrt/bytestring_unittest.cpp b/core/fxcrt/bytestring_unittest.cpp
index b45ee0fd5e..ce1512b4cf 100644
--- a/core/fxcrt/bytestring_unittest.cpp
+++ b/core/fxcrt/bytestring_unittest.cpp
@@ -615,7 +615,7 @@ TEST(ByteString, Find) {
EXPECT_FALSE(empty_string.Find('a').has_value());
EXPECT_FALSE(empty_string.Find('\0').has_value());
- pdfium::Optional<size_t> result;
+ Optional<size_t> result;
ByteString single_string("a");
result = single_string.Find('a');
ASSERT_TRUE(result.has_value());
@@ -664,7 +664,7 @@ TEST(ByteString, ReverseFind) {
EXPECT_FALSE(empty_string.ReverseFind('a').has_value());
EXPECT_FALSE(empty_string.ReverseFind('\0').has_value());
- pdfium::Optional<size_t> result;
+ Optional<size_t> result;
ByteString single_string("a");
result = single_string.ReverseFind('a');
ASSERT_TRUE(result.has_value());
@@ -1111,7 +1111,7 @@ TEST(ByteStringView, Find) {
EXPECT_FALSE(empty_string.Find('a').has_value());
EXPECT_FALSE(empty_string.Find('\0').has_value());
- pdfium::Optional<size_t> result;
+ Optional<size_t> result;
ByteStringView single_string("a");
result = single_string.Find('a');
ASSERT_TRUE(result.has_value());
diff --git a/core/fxcrt/string_view_template.h b/core/fxcrt/string_view_template.h
index fa33858a68..cd3614b34f 100644
--- a/core/fxcrt/string_view_template.h
+++ b/core/fxcrt/string_view_template.h
@@ -149,12 +149,11 @@ class StringViewTemplate {
return static_cast<CharType>(m_Ptr.Get()[index]);
}
- pdfium::Optional<size_t> Find(CharType ch) const {
+ Optional<size_t> Find(CharType ch) const {
const auto* found = reinterpret_cast<const UnsignedType*>(FXSYS_chr(
reinterpret_cast<const CharType*>(m_Ptr.Get()), ch, m_Length));
- return found ? pdfium::Optional<size_t>(found - m_Ptr.Get())
- : pdfium::Optional<size_t>();
+ return found ? Optional<size_t>(found - m_Ptr.Get()) : Optional<size_t>();
}
bool Contains(CharType ch) const { return Find(ch).has_value(); }
diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp
index 3b72c8fa94..158c67409b 100644
--- a/core/fxcrt/widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -57,8 +57,8 @@ const wchar_t* FX_wcsstr(const wchar_t* haystack,
return nullptr;
}
-pdfium::Optional<size_t> GuessSizeForVSWPrintf(const wchar_t* pFormat,
- va_list argList) {
+Optional<size_t> GuessSizeForVSWPrintf(const wchar_t* pFormat,
+ va_list argList) {
size_t nMaxLen = 0;
for (const wchar_t* pStr = pFormat; *pStr != 0; pStr++) {
if (*pStr != '%' || *(pStr = pStr + 1) == '%') {
@@ -82,7 +82,7 @@ pdfium::Optional<size_t> GuessSizeForVSWPrintf(const wchar_t* pFormat,
++pStr;
}
if (nWidth < 0 || nWidth > 128 * 1024)
- return pdfium::Optional<size_t>();
+ return Optional<size_t>();
int nPrecision = 0;
if (*pStr == '.') {
pStr++;
@@ -96,7 +96,7 @@ pdfium::Optional<size_t> GuessSizeForVSWPrintf(const wchar_t* pFormat,
}
}
if (nPrecision < 0 || nPrecision > 128 * 1024)
- return pdfium::Optional<size_t>();
+ return Optional<size_t>();
int nModifier = 0;
if (*pStr == L'I' && *(pStr + 1) == L'6' && *(pStr + 2) == L'4') {
pStr += 3;
@@ -245,13 +245,13 @@ pdfium::Optional<size_t> GuessSizeForVSWPrintf(const wchar_t* pFormat,
nMaxLen += nItemLen;
}
nMaxLen += 32; // Fudge factor.
- return pdfium::Optional<size_t>(nMaxLen);
+ return Optional<size_t>(nMaxLen);
}
// Returns string unless we ran out of space.
-pdfium::Optional<WideString> TryVSWPrintf(size_t size,
- const wchar_t* pFormat,
- va_list argList) {
+Optional<WideString> TryVSWPrintf(size_t size,
+ const wchar_t* pFormat,
+ va_list argList) {
WideString str;
wchar_t* buffer = str.GetBuffer(size);
@@ -330,7 +330,7 @@ WideString WideString::FormatV(const wchar_t* format, va_list argList) {
while (maxLen < 32 * 1024) {
va_copy(argListCopy, argList);
- pdfium::Optional<WideString> ret =
+ Optional<WideString> ret =
TryVSWPrintf(static_cast<size_t>(maxLen), format, argListCopy);
va_end(argListCopy);
@@ -731,34 +731,32 @@ size_t WideString::Insert(size_t location, wchar_t ch) {
return new_length;
}
-pdfium::Optional<size_t> WideString::Find(wchar_t ch, size_t start) const {
+Optional<size_t> WideString::Find(wchar_t ch, size_t start) const {
if (!m_pData)
- return pdfium::Optional<size_t>();
+ return Optional<size_t>();
if (!IsValidIndex(start))
- return pdfium::Optional<size_t>();
+ return Optional<size_t>();
const wchar_t* pStr =
wmemchr(m_pData->m_String + start, ch, m_pData->m_nDataLength - start);
- return pStr ? pdfium::Optional<size_t>(
- static_cast<size_t>(pStr - m_pData->m_String))
- : pdfium::Optional<size_t>();
+ return pStr ? Optional<size_t>(static_cast<size_t>(pStr - m_pData->m_String))
+ : Optional<size_t>();
}
-pdfium::Optional<size_t> WideString::Find(const WideStringView& subStr,
- size_t start) const {
+Optional<size_t> WideString::Find(const WideStringView& subStr,
+ size_t start) const {
if (!m_pData)
- return pdfium::Optional<size_t>();
+ return Optional<size_t>();
if (!IsValidIndex(start))
- return pdfium::Optional<size_t>();
+ return Optional<size_t>();
const wchar_t* pStr =
FX_wcsstr(m_pData->m_String + start, m_pData->m_nDataLength - start,
subStr.unterminated_c_str(), subStr.GetLength());
- return pStr ? pdfium::Optional<size_t>(
- static_cast<size_t>(pStr - m_pData->m_String))
- : pdfium::Optional<size_t>();
+ return pStr ? Optional<size_t>(static_cast<size_t>(pStr - m_pData->m_String))
+ : Optional<size_t>();
}
void WideString::MakeLower() {
diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h
index 728ab35090..30a423d9aa 100644
--- a/core/fxcrt/widestring.h
+++ b/core/fxcrt/widestring.h
@@ -169,9 +169,8 @@ class WideString {
int GetInteger() const;
float GetFloat() const;
- pdfium::Optional<size_t> Find(const WideStringView& pSub,
- size_t start = 0) const;
- pdfium::Optional<size_t> Find(wchar_t ch, size_t start = 0) const;
+ Optional<size_t> Find(const WideStringView& pSub, size_t start = 0) const;
+ Optional<size_t> Find(wchar_t ch, size_t start = 0) const;
bool Contains(const WideStringView& lpszSub, size_t start = 0) const {
return Find(lpszSub, start).has_value();
diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp
index 1673c8f069..2fb9e8c8b4 100644
--- a/core/fxcrt/widestring_unittest.cpp
+++ b/core/fxcrt/widestring_unittest.cpp
@@ -575,7 +575,7 @@ TEST(WideString, Find) {
EXPECT_FALSE(empty_string.Find(L'a').has_value());
EXPECT_FALSE(empty_string.Find(L'\0').has_value());
- pdfium::Optional<size_t> result;
+ Optional<size_t> result;
WideString single_string(L"a");
result = single_string.Find(L'a');
ASSERT_TRUE(result.has_value());
@@ -1146,7 +1146,7 @@ TEST(WideStringView, Find) {
EXPECT_FALSE(empty_string.Find(L'a').has_value());
EXPECT_FALSE(empty_string.Find(L'\0').has_value());
- pdfium::Optional<size_t> result;
+ Optional<size_t> result;
WideStringView single_string(L"a");
result = single_string.Find(L'a');
ASSERT_TRUE(result.has_value());