diff options
author | tsepez <tsepez@chromium.org> | 2016-12-07 19:01:56 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-12-07 19:01:56 -0800 |
commit | 64f4e25304dfd93651ac5c9d5379ed2fffbb993f (patch) | |
tree | 67f755611451432631bd27c494236b8b6ee418b4 /xfa/fde/xml/fde_xml_imp.cpp | |
parent | 1306b180a6a8e306a7d00db9cdaa983784c354ed (diff) | |
download | pdfium-64f4e25304dfd93651ac5c9d5379ed2fffbb993f.tar.xz |
Use unique_ptr for CXFA_XMLParser.
Also rename CFDE_XMLParser to IFDE_XMLParser since its an interface.
Review-Url: https://codereview.chromium.org/2555373002
Diffstat (limited to 'xfa/fde/xml/fde_xml_imp.cpp')
-rw-r--r-- | xfa/fde/xml/fde_xml_imp.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp index f333b4fcda..7880804367 100644 --- a/xfa/fde/xml/fde_xml_imp.cpp +++ b/xfa/fde/xml/fde_xml_imp.cpp @@ -7,6 +7,7 @@ #include "xfa/fde/xml/fde_xml_imp.h" #include <algorithm> +#include <utility> #include "core/fxcrt/fx_ext.h" #include "core/fxcrt/fx_safe_types.h" @@ -957,29 +958,27 @@ void CFDE_XMLDoc::Reset(bool bInitRoot) { } void CFDE_XMLDoc::ReleaseParser() { - if (m_pXMLParser) { - m_pXMLParser->Release(); - m_pXMLParser = nullptr; - } + m_pXMLParser.reset(); if (m_pSyntaxParser) { m_pSyntaxParser->Release(); m_pSyntaxParser = nullptr; } } -bool CFDE_XMLDoc::LoadXML(CFDE_XMLParser* pXMLParser) { +bool CFDE_XMLDoc::LoadXML(std::unique_ptr<IFDE_XMLParser> pXMLParser) { if (!pXMLParser) return false; Reset(true); - m_pXMLParser = pXMLParser; - return !!m_pXMLParser; + m_pXMLParser = std::move(pXMLParser); + return true; } int32_t CFDE_XMLDoc::DoLoad(IFX_Pause* pPause) { - if (m_iStatus >= 100) - return m_iStatus; - return m_iStatus = m_pXMLParser->DoParser(pPause); + if (m_iStatus < 100) + m_iStatus = m_pXMLParser->DoParser(pPause); + + return m_iStatus; } void CFDE_XMLDoc::CloseXML() { |