From 875e98c581952478f3a3ccef9b2f2e3ed06c5346 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Wed, 27 Sep 2017 10:53:11 -0400 Subject: Remove FX_STRSIZE and replace with size_t BUG=pdfium:828 Change-Id: I5c40237433ebabaeabdb43aec9cdf783e41dfe16 Reviewed-on: https://pdfium-review.googlesource.com/13230 Reviewed-by: dsinclair Commit-Queue: Ryan Harrison --- core/fxcrt/bytestring.h | 65 +++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 34 deletions(-) (limited to 'core/fxcrt/bytestring.h') diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h index eba9744402..2b01bc19aa 100644 --- a/core/fxcrt/bytestring.h +++ b/core/fxcrt/bytestring.h @@ -46,8 +46,8 @@ class ByteString { // NOLINTNEXTLINE(runtime/explicit) ByteString(wchar_t) = delete; - ByteString(const char* ptr, FX_STRSIZE len); - ByteString(const uint8_t* ptr, FX_STRSIZE len); + ByteString(const char* ptr, size_t len); + ByteString(const uint8_t* ptr, size_t len); explicit ByteString(const ByteStringView& bstrc); ByteString(const ByteStringView& bstrc1, const ByteStringView& bstrc2); @@ -91,13 +91,13 @@ class ByteString { return const_reverse_iterator(begin()); } - FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } - FX_STRSIZE GetStringLength() const { + size_t GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } + size_t GetStringLength() const { return m_pData ? FXSYS_strlen(m_pData->m_String) : 0; } bool IsEmpty() const { return !GetLength(); } - bool IsValidIndex(FX_STRSIZE index) const { return index < GetLength(); } - bool IsValidLength(FX_STRSIZE length) const { return length <= GetLength(); } + bool IsValidIndex(size_t index) const { return index < GetLength(); } + bool IsValidLength(size_t length) const { return length <= GetLength(); } int Compare(const ByteStringView& str) const; bool EqualNoCase(const ByteStringView& str) const; @@ -121,7 +121,7 @@ class ByteString { const ByteString& operator+=(const ByteString& str); const ByteString& operator+=(const ByteStringView& bstrc); - CharType operator[](const FX_STRSIZE index) const { + CharType operator[](const size_t index) const { ASSERT(IsValidIndex(index)); return m_pData ? m_pData->m_String[index] : 0; } @@ -129,34 +129,34 @@ class ByteString { CharType First() const { return GetLength() ? (*this)[0] : 0; } CharType Last() const { return GetLength() ? (*this)[GetLength() - 1] : 0; } - void SetAt(FX_STRSIZE index, char c); + void SetAt(size_t index, char c); - FX_STRSIZE Insert(FX_STRSIZE index, char ch); - FX_STRSIZE InsertAtFront(char ch) { return Insert(0, ch); } - FX_STRSIZE InsertAtBack(char ch) { return Insert(GetLength(), ch); } - FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1); + size_t Insert(size_t index, char ch); + size_t InsertAtFront(char ch) { return Insert(0, ch); } + size_t InsertAtBack(char ch) { return Insert(GetLength(), ch); } + size_t Delete(size_t index, size_t count = 1); void Format(const char* lpszFormat, ...); void FormatV(const char* lpszFormat, va_list argList); - void Reserve(FX_STRSIZE len); - char* GetBuffer(FX_STRSIZE len); - void ReleaseBuffer(FX_STRSIZE len); + void Reserve(size_t len); + char* GetBuffer(size_t len); + void ReleaseBuffer(size_t len); - ByteString Mid(FX_STRSIZE first, FX_STRSIZE count) const; - ByteString Left(FX_STRSIZE count) const; - ByteString Right(FX_STRSIZE count) const; + ByteString Mid(size_t first, size_t count) const; + ByteString Left(size_t count) const; + ByteString Right(size_t count) const; - pdfium::Optional Find(const ByteStringView& lpszSub, - FX_STRSIZE start = 0) const; - pdfium::Optional Find(char ch, FX_STRSIZE start = 0) const; - pdfium::Optional ReverseFind(char ch) const; + pdfium::Optional Find(const ByteStringView& lpszSub, + size_t start = 0) const; + pdfium::Optional Find(char ch, size_t start = 0) const; + pdfium::Optional ReverseFind(char ch) const; - bool Contains(const ByteStringView& lpszSub, FX_STRSIZE start = 0) const { + bool Contains(const ByteStringView& lpszSub, size_t start = 0) const { return Find(lpszSub, start).has_value(); } - bool Contains(char ch, FX_STRSIZE start = 0) const { + bool Contains(char ch, size_t start = 0) const { return Find(ch, start).has_value(); } @@ -171,10 +171,9 @@ class ByteString { void TrimLeft(char chTarget); void TrimLeft(const ByteStringView& lpszTargets); - FX_STRSIZE Replace(const ByteStringView& lpszOld, - const ByteStringView& lpszNew); + size_t Replace(const ByteStringView& lpszOld, const ByteStringView& lpszNew); - FX_STRSIZE Remove(char ch); + size_t Remove(char ch); WideString UTF8Decode() const; @@ -186,13 +185,11 @@ class ByteString { protected: using StringData = StringDataTemplate; - void ReallocBeforeWrite(FX_STRSIZE nNewLen); - void AllocBeforeWrite(FX_STRSIZE nNewLen); - void AllocCopy(ByteString& dest, - FX_STRSIZE nCopyLen, - FX_STRSIZE nCopyIndex) const; - void AssignCopy(const char* pSrcData, FX_STRSIZE nSrcLen); - void Concat(const char* lpszSrcData, FX_STRSIZE nSrcLen); + void ReallocBeforeWrite(size_t nNewLen); + void AllocBeforeWrite(size_t nNewLen); + void AllocCopy(ByteString& dest, size_t nCopyLen, size_t nCopyIndex) const; + void AssignCopy(const char* pSrcData, size_t nSrcLen); + void Concat(const char* lpszSrcData, size_t nSrcLen); RetainPtr m_pData; -- cgit v1.2.3