summaryrefslogtreecommitdiff
path: root/core/fxcrt/cfx_chariter.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-03-30 14:01:31 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-03-30 18:35:59 +0000
commitddb7016e69d99bb9355420b49a0ee864e2b7fe15 (patch)
tree03017f5f00da434b73d4ecc9e0823f9a609084fd /core/fxcrt/cfx_chariter.cpp
parent677329c9fa9f4f9e1a06f15e8d33d8a734cc5349 (diff)
downloadpdfium-ddb7016e69d99bb9355420b49a0ee864e2b7fe15.tar.xz
Move CFX files into fxcrt
This Cl moves more of the CFX classes defined in the xfa/ directory to the core/fxcrt directory and conditionally builds them. Change-Id: I811e6c6acd31dfbe75b49880be43661f78334013 Reviewed-on: https://pdfium-review.googlesource.com/3372 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/cfx_chariter.cpp')
-rw-r--r--core/fxcrt/cfx_chariter.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/core/fxcrt/cfx_chariter.cpp b/core/fxcrt/cfx_chariter.cpp
new file mode 100644
index 0000000000..c14db2f322
--- /dev/null
+++ b/core/fxcrt/cfx_chariter.cpp
@@ -0,0 +1,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 "core/fxcrt/cfx_chariter.h"
+
+CFX_CharIter::CFX_CharIter(const CFX_WideString& wsText)
+ : m_wsText(wsText), m_nIndex(0) {
+ ASSERT(!wsText.IsEmpty());
+}
+
+CFX_CharIter::~CFX_CharIter() {}
+
+bool CFX_CharIter::Next(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;
+}
+
+wchar_t 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;
+}
+
+bool CFX_CharIter::IsEOF(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;
+}