From 8f0bf890b4b15148a149bf9bbeead4eed6675e8a Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 17 Apr 2017 14:14:01 -0700 Subject: Add iterators for Byte/WideStringCs. Change-Id: I40ec07c0da54bcf36c83fa26ff457cd4b98a91cf Reviewed-on: https://pdfium-review.googlesource.com/4261 Commit-Queue: Tom Sepez Reviewed-by: Lei Zhang --- core/fxcrt/cfx_bytestring.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'core/fxcrt/cfx_bytestring.h') diff --git a/core/fxcrt/cfx_bytestring.h b/core/fxcrt/cfx_bytestring.h index b9ebd8a83c..0ffe92936a 100644 --- a/core/fxcrt/cfx_bytestring.h +++ b/core/fxcrt/cfx_bytestring.h @@ -23,6 +23,7 @@ class CFX_WideString; class CFX_ByteString { public: using CharType = char; + using const_iterator = const CharType*; CFX_ByteString(); CFX_ByteString(const CFX_ByteString& other); @@ -65,6 +66,12 @@ class CFX_ByteString { return CFX_ByteStringC(raw_str(), GetLength()); } + // Note: Any subsequent modification of |this| will invalidate iterators. + const_iterator begin() const { return m_pData ? m_pData->m_String : nullptr; } + const_iterator end() const { + return m_pData ? m_pData->m_String + m_pData->m_nDataLength : nullptr; + } + FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } bool IsEmpty() const { return !GetLength(); } -- cgit v1.2.3