summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-22 13:01:10 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-22 20:25:33 +0000
commit3ae3033bff2582029984f91f40f4a8b748a30c96 (patch)
treed2f22825c4eb2f0f54492536e1f7db1f9222bcb0 /xfa
parent2fbfb84aedccefbd1c1a7bb2c5b2a723b3f3dd77 (diff)
downloadpdfium-3ae3033bff2582029984f91f40f4a8b748a30c96.tar.xz
Use unique_ptr for CFDE_XMLDoc::m_pRoot
Remove some less helpful helper methods. Change-Id: Id027e31b6584156263c4aa0c2888e91fa44e4b0b Reviewed-on: https://pdfium-review.googlesource.com/3150 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fde/xml/fde_xml_imp.cpp37
-rw-r--r--xfa/fde/xml/fde_xml_imp.h11
2 files changed, 13 insertions, 35 deletions
diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp
index 28384451e4..ade8fc0557 100644
--- a/xfa/fde/xml/fde_xml_imp.cpp
+++ b/xfa/fde/xml/fde_xml_imp.cpp
@@ -11,6 +11,7 @@
#include "core/fxcrt/fx_ext.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
#include "xfa/fgas/crt/fgas_codepage.h"
@@ -909,40 +910,20 @@ CFDE_XMLNode* CFDE_XMLCharData::Clone(bool bRecursive) {
CFDE_XMLCharData::~CFDE_XMLCharData() {}
-CFDE_XMLDoc::CFDE_XMLDoc() : m_pRoot(nullptr) {
- Reset(true);
- CFDE_XMLInstruction* pXML = new CFDE_XMLInstruction(L"xml");
- m_pRoot->InsertChildNode(pXML);
+CFDE_XMLDoc::CFDE_XMLDoc()
+ : m_iStatus(0), m_pRoot(pdfium::MakeUnique<CFDE_XMLNode>()) {
+ m_pRoot->InsertChildNode(new CFDE_XMLInstruction(L"xml"));
}
-CFDE_XMLDoc::~CFDE_XMLDoc() {
- Reset(false);
-}
-
-void CFDE_XMLDoc::Reset(bool bInitRoot) {
- m_iStatus = 0;
- m_pStream = nullptr;
- if (bInitRoot) {
- if (m_pRoot)
- m_pRoot->DeleteChildren();
- else
- m_pRoot = new CFDE_XMLNode;
- } else {
- delete m_pRoot;
- m_pRoot = nullptr;
- }
- ReleaseParser();
-}
-
-void CFDE_XMLDoc::ReleaseParser() {
- m_pXMLParser.reset();
-}
+CFDE_XMLDoc::~CFDE_XMLDoc() {}
bool CFDE_XMLDoc::LoadXML(std::unique_ptr<IFDE_XMLParser> pXMLParser) {
if (!pXMLParser)
return false;
- Reset(true);
+ m_iStatus = 0;
+ m_pStream.Reset();
+ m_pRoot->DeleteChildren();
m_pXMLParser = std::move(pXMLParser);
return true;
}
@@ -955,7 +936,7 @@ int32_t CFDE_XMLDoc::DoLoad(IFX_Pause* pPause) {
}
void CFDE_XMLDoc::CloseXML() {
- ReleaseParser();
+ m_pXMLParser.reset();
}
void CFDE_XMLDoc::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream,
diff --git a/xfa/fde/xml/fde_xml_imp.h b/xfa/fde/xml/fde_xml_imp.h
index 687a0cd416..ad2ccc467c 100644
--- a/xfa/fde/xml/fde_xml_imp.h
+++ b/xfa/fde/xml/fde_xml_imp.h
@@ -194,19 +194,16 @@ class CFDE_XMLDoc {
bool LoadXML(std::unique_ptr<IFDE_XMLParser> pXMLParser);
int32_t DoLoad(IFX_Pause* pPause = nullptr);
void CloseXML();
- CFDE_XMLNode* GetRoot() const { return m_pRoot; }
+ CFDE_XMLNode* GetRoot() const { return m_pRoot.get(); }
void SaveXML(CFX_RetainPtr<IFGAS_Stream>& pXMLStream, bool bSaveBOM = true);
void SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream,
CFDE_XMLNode* pNode);
- protected:
- void Reset(bool bInitRoot);
- void ReleaseParser();
-
- CFX_RetainPtr<IFGAS_Stream> m_pStream;
+ private:
int32_t m_iStatus;
- CFDE_XMLNode* m_pRoot;
+ std::unique_ptr<CFDE_XMLNode> m_pRoot;
std::unique_ptr<IFDE_XMLParser> m_pXMLParser;
+ CFX_RetainPtr<IFGAS_Stream> m_pStream;
};
class IFDE_XMLParser {