summaryrefslogtreecommitdiff
path: root/xfa/fde/xml/cfx_saxreader.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-15 12:48:38 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-15 23:12:43 +0000
commitcfdb5fdd12d47136ad1db9a67fc598a71f6757ff (patch)
tree0af8553fa067d730b62e4b553cf91732d95c5be3 /xfa/fde/xml/cfx_saxreader.cpp
parent972eb5c6843b235e5414c86c41e962151a94870c (diff)
downloadpdfium-cfdb5fdd12d47136ad1db9a67fc598a71f6757ff.tar.xz
remove CFX_ArrayTemplate from fde/xml.
Change-Id: I62499a271e753e44234412fd855fbd8a56763d71 Reviewed-on: https://pdfium-review.googlesource.com/3055 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fde/xml/cfx_saxreader.cpp')
-rw-r--r--xfa/fde/xml/cfx_saxreader.cpp53
1 files changed, 24 insertions, 29 deletions
diff --git a/xfa/fde/xml/cfx_saxreader.cpp b/xfa/fde/xml/cfx_saxreader.cpp
index 458bed52d6..552ec5f5fe 100644
--- a/xfa/fde/xml/cfx_saxreader.cpp
+++ b/xfa/fde/xml/cfx_saxreader.cpp
@@ -10,6 +10,7 @@
#include <utility>
#include "third_party/base/ptr_util.h"
+#include "third_party/base/stl_util.h"
#include "xfa/fxfa/xfa_checksum.h"
enum class CFX_SaxMode {
@@ -147,11 +148,9 @@ CFX_SAXReader::~CFX_SAXReader() {
void CFX_SAXReader::Reset() {
m_File.Reset();
- while (!m_Stack.empty())
- m_Stack.pop();
-
+ m_Stack = std::stack<std::unique_ptr<CFX_SAXItem>>();
m_dwItemID = 0;
- m_SkipStack.RemoveAll();
+ m_SkipStack = std::stack<char>();
m_SkipChar = 0;
m_iDataLength = 0;
m_iEntityStart = -1;
@@ -397,17 +396,17 @@ void CFX_SAXReader::ParseDeclOrComment() {
GetCurrentItem()->m_eNode = CFX_SAXItem::Type::Comment;
if (!m_pCommentContext)
m_pCommentContext = new CFX_SAXCommentContext;
-
m_pCommentContext->m_iHeaderCount = 1;
m_pCommentContext->m_iTailCount = 0;
- } else {
- m_eMode = CFX_SaxMode::DeclNode;
- m_dwDataOffset = m_File.m_dwBufIndex;
- m_SkipChar = '>';
- m_SkipStack.Add('>');
- SkipNode();
+ return;
}
+ m_eMode = CFX_SaxMode::DeclNode;
+ m_dwDataOffset = m_File.m_dwBufIndex;
+ m_SkipChar = '>';
+ m_SkipStack.push('>');
+ SkipNode();
}
+
void CFX_SAXReader::ParseComment() {
m_pCommentContext->m_iHeaderCount = 2;
m_dwNodePos = m_File.m_dwCur + m_File.m_dwBufIndex;
@@ -591,44 +590,41 @@ void CFX_SAXReader::ParseTargetData() {
}
}
void CFX_SAXReader::SkipNode() {
- int32_t iLen = m_SkipStack.GetSize();
if (m_SkipChar == '\'' || m_SkipChar == '\"') {
- if (m_CurByte != m_SkipChar) {
+ if (m_CurByte != m_SkipChar)
return;
- }
- iLen--;
- ASSERT(iLen > -1);
- m_SkipStack.RemoveAt(iLen, 1);
- m_SkipChar = iLen ? m_SkipStack[iLen - 1] : 0;
+
+ ASSERT(!m_SkipStack.empty());
+ m_SkipStack.pop();
+ m_SkipChar = !m_SkipStack.empty() ? m_SkipStack.top() : 0;
return;
}
switch (m_CurByte) {
case '<':
m_SkipChar = '>';
- m_SkipStack.Add('>');
+ m_SkipStack.push('>');
break;
case '[':
m_SkipChar = ']';
- m_SkipStack.Add(']');
+ m_SkipStack.push(']');
break;
case '(':
m_SkipChar = ')';
- m_SkipStack.Add(')');
+ m_SkipStack.push(')');
break;
case '\'':
m_SkipChar = '\'';
- m_SkipStack.Add('\'');
+ m_SkipStack.push('\'');
break;
case '\"':
m_SkipChar = '\"';
- m_SkipStack.Add('\"');
+ m_SkipStack.push('\"');
break;
default:
if (m_CurByte == m_SkipChar) {
- iLen--;
- m_SkipStack.RemoveAt(iLen, 1);
- m_SkipChar = iLen ? m_SkipStack[iLen - 1] : 0;
- if (iLen == 0 && m_CurByte == '>') {
+ m_SkipStack.pop();
+ m_SkipChar = !m_SkipStack.empty() ? m_SkipStack.top() : 0;
+ if (m_SkipStack.empty() && m_CurByte == '>') {
m_iDataLength = m_iDataPos;
m_iDataPos = 0;
if (m_iDataLength >= 9 &&
@@ -653,9 +649,8 @@ void CFX_SAXReader::SkipNode() {
}
break;
}
- if (iLen > 0) {
+ if (!m_SkipStack.empty())
ParseChar(m_CurByte);
- }
}
void CFX_SAXReader::NotifyData() {