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