OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fde/cfx_chariter.h" | 7 #include "xfa/fde/cfx_chariter.h" |
8 | 8 |
9 CFX_CharIter::CFX_CharIter(const CFX_WideString& wsText) | 9 CFX_CharIter::CFX_CharIter(const CFX_WideString& wsText) |
10 : m_wsText(wsText), m_nIndex(0) { | 10 : m_wsText(wsText), m_nIndex(0) { |
11 ASSERT(!wsText.IsEmpty()); | 11 ASSERT(!wsText.IsEmpty()); |
12 } | 12 } |
13 | 13 |
14 CFX_CharIter::~CFX_CharIter() {} | 14 CFX_CharIter::~CFX_CharIter() {} |
15 | 15 |
16 FX_BOOL CFX_CharIter::Next(FX_BOOL bPrev) { | 16 bool CFX_CharIter::Next(bool bPrev) { |
17 if (bPrev) { | 17 if (bPrev) { |
18 if (m_nIndex <= 0) | 18 if (m_nIndex <= 0) |
19 return FALSE; | 19 return false; |
20 m_nIndex--; | 20 m_nIndex--; |
21 } else { | 21 } else { |
22 if (m_nIndex + 1 >= m_wsText.GetLength()) | 22 if (m_nIndex + 1 >= m_wsText.GetLength()) |
23 return FALSE; | 23 return false; |
24 m_nIndex++; | 24 m_nIndex++; |
25 } | 25 } |
26 return TRUE; | 26 return true; |
27 } | 27 } |
28 | 28 |
29 FX_WCHAR CFX_CharIter::GetChar() { | 29 FX_WCHAR CFX_CharIter::GetChar() { |
30 return m_wsText.GetAt(m_nIndex); | 30 return m_wsText.GetAt(m_nIndex); |
31 } | 31 } |
32 | 32 |
33 void CFX_CharIter::SetAt(int32_t nIndex) { | 33 void CFX_CharIter::SetAt(int32_t nIndex) { |
34 if (nIndex < 0 || nIndex >= m_wsText.GetLength()) | 34 if (nIndex < 0 || nIndex >= m_wsText.GetLength()) |
35 return; | 35 return; |
36 m_nIndex = nIndex; | 36 m_nIndex = nIndex; |
37 } | 37 } |
38 | 38 |
39 int32_t CFX_CharIter::GetAt() const { | 39 int32_t CFX_CharIter::GetAt() const { |
40 return m_nIndex; | 40 return m_nIndex; |
41 } | 41 } |
42 | 42 |
43 FX_BOOL CFX_CharIter::IsEOF(FX_BOOL bTail) const { | 43 bool CFX_CharIter::IsEOF(bool bTail) const { |
44 return bTail ? (m_nIndex + 1 == m_wsText.GetLength()) : (m_nIndex == 0); | 44 return bTail ? (m_nIndex + 1 == m_wsText.GetLength()) : (m_nIndex == 0); |
45 } | 45 } |
46 | 46 |
47 IFX_CharIter* CFX_CharIter::Clone() { | 47 IFX_CharIter* CFX_CharIter::Clone() { |
48 CFX_CharIter* pIter = new CFX_CharIter(m_wsText); | 48 CFX_CharIter* pIter = new CFX_CharIter(m_wsText); |
49 pIter->m_nIndex = m_nIndex; | 49 pIter->m_nIndex = m_nIndex; |
50 return pIter; | 50 return pIter; |
51 } | 51 } |
OLD | NEW |