diff options
author | Ryan Harrison <rharrison@chromium.org> | 2018-01-04 14:43:27 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-01-04 20:19:41 +0000 |
commit | c560a8c11a6f8ee239e570db8c022ae0fd2a4db5 (patch) | |
tree | 0c16389f7e5c5e29c57a9c7f77dd062fa07d8640 /core/fxcrt/widestring.cpp | |
parent | df0a749452d933e4f434e2a33112667f1880db34 (diff) | |
download | pdfium-c560a8c11a6f8ee239e570db8c022ae0fd2a4db5.tar.xz |
Convert usages of pdfium::Optional to Optional
Change-Id: I29769f78eaad10c6a8b79e27524336c4f330377e
Reviewed-on: https://pdfium-review.googlesource.com/22258
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fxcrt/widestring.cpp')
-rw-r--r-- | core/fxcrt/widestring.cpp | 42 |
1 files changed, 20 insertions, 22 deletions
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() { |