From 9a785afee976e60fa2bd3d462cdcb1c3636d97dd Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 3 Mar 2017 10:54:15 -0800 Subject: remove CFX_StackTemplate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I1112d18e0d18514227d363b3010eb8f90fb0ffe4 Reviewed-on: https://pdfium-review.googlesource.com/2910 Reviewed-by: Nicolás Peña Commit-Queue: Tom Sepez --- xfa/fxfa/parser/cxfa_xml_parser.cpp | 33 +++++++++++++-------------------- xfa/fxfa/parser/cxfa_xml_parser.h | 8 ++++---- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/xfa/fxfa/parser/cxfa_xml_parser.cpp b/xfa/fxfa/parser/cxfa_xml_parser.cpp index b202022516..ebde399931 100644 --- a/xfa/fxfa/parser/cxfa_xml_parser.cpp +++ b/xfa/fxfa/parser/cxfa_xml_parser.cpp @@ -6,28 +6,22 @@ #include "xfa/fxfa/parser/cxfa_xml_parser.h" -CXFA_XMLParser::CXFA_XMLParser(CFDE_XMLNode* pRoot, +CXFA_XMLParser::CXFA_XMLParser(CFDE_XMLNode* pParent, const CFX_RetainPtr& pStream) : m_nElementStart(0), m_dwCheckStatus(0), m_dwCurrentCheckStatus(0), - m_pRoot(pRoot), m_pStream(pStream), m_pParser(new CFDE_XMLSyntaxParser), - m_pParent(pRoot), + m_pParent(pParent), m_pChild(nullptr), - m_NodeStack(16), m_syntaxParserResult(FDE_XmlSyntaxResult::None) { ASSERT(m_pParent && m_pStream); - m_NodeStack.Push(m_pParent); + m_NodeStack.push(m_pParent); m_pParser->Init(m_pStream, 32 * 1024, 1024 * 1024); } -CXFA_XMLParser::~CXFA_XMLParser() { - m_NodeStack.RemoveAll(false); - m_ws1.clear(); - m_ws2.clear(); -} +CXFA_XMLParser::~CXFA_XMLParser() {} int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error) @@ -51,9 +45,8 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { m_pChild = m_pParent; break; case FDE_XmlSyntaxResult::ElementOpen: - if (m_dwCheckStatus != 0x03 && m_NodeStack.GetSize() == 2) { + if (m_dwCheckStatus != 0x03 && m_NodeStack.size() == 2) m_nElementStart = m_pParser->GetCurrentPos() - 1; - } break; case FDE_XmlSyntaxResult::ElementBreak: break; @@ -68,18 +61,18 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { m_syntaxParserResult = FDE_XmlSyntaxResult::Error; break; } - m_NodeStack.Pop(); - if (m_NodeStack.GetSize() < 1) { + if (!m_NodeStack.empty()) + m_NodeStack.pop(); + if (m_NodeStack.empty()) { m_syntaxParserResult = FDE_XmlSyntaxResult::Error; break; - } else if (m_dwCurrentCheckStatus != 0 && m_NodeStack.GetSize() == 2) { + } else if (m_dwCurrentCheckStatus != 0 && m_NodeStack.size() == 2) { m_nSize[m_dwCurrentCheckStatus - 1] = m_pParser->GetCurrentBinaryPos() - m_nStart[m_dwCurrentCheckStatus - 1]; m_dwCurrentCheckStatus = 0; } - - m_pParent = static_cast(*m_NodeStack.GetTopElement()); + m_pParent = m_NodeStack.top(); m_pChild = m_pParent; iCount++; break; @@ -97,10 +90,10 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { m_pParser->GetTagName(m_ws1); m_pChild = new CFDE_XMLElement(m_ws1); m_pParent->InsertChildNode(m_pChild); - m_NodeStack.Push(m_pChild); + m_NodeStack.push(m_pChild); m_pParent = m_pChild; - if (m_dwCheckStatus != 0x03 && m_NodeStack.GetSize() == 3) { + if (m_dwCheckStatus != 0x03 && m_NodeStack.size() == 3) { CFX_WideString wsTag; static_cast(m_pChild)->GetLocalTagName(wsTag); if (wsTag == L"template") { @@ -166,7 +159,7 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { } } return (m_syntaxParserResult == FDE_XmlSyntaxResult::Error || - m_NodeStack.GetSize() != 1) + m_NodeStack.size() != 1) ? -1 : m_pParser->GetStatus(); } diff --git a/xfa/fxfa/parser/cxfa_xml_parser.h b/xfa/fxfa/parser/cxfa_xml_parser.h index 9393b7e597..a631df02dc 100644 --- a/xfa/fxfa/parser/cxfa_xml_parser.h +++ b/xfa/fxfa/parser/cxfa_xml_parser.h @@ -8,6 +8,7 @@ #define XFA_FXFA_PARSER_CXFA_XML_PARSER_H_ #include +#include #include "xfa/fde/xml/fde_xml_imp.h" @@ -16,7 +17,7 @@ class IFX_Pause; class CXFA_XMLParser : public IFDE_XMLParser { public: - CXFA_XMLParser(CFDE_XMLNode* pRoot, + CXFA_XMLParser(CFDE_XMLNode* pParent, const CFX_RetainPtr& pStream); ~CXFA_XMLParser() override; @@ -29,13 +30,12 @@ class CXFA_XMLParser : public IFDE_XMLParser { uint16_t m_dwCheckStatus; uint16_t m_dwCurrentCheckStatus; - protected: - CFDE_XMLNode* m_pRoot; + private: CFX_RetainPtr m_pStream; std::unique_ptr m_pParser; CFDE_XMLNode* m_pParent; CFDE_XMLNode* m_pChild; - CFX_StackTemplate m_NodeStack; + std::stack m_NodeStack; CFX_WideString m_ws1; CFX_WideString m_ws2; FDE_XmlSyntaxResult m_syntaxParserResult; -- cgit v1.2.3