Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Side by Side Diff: xfa/fde/xml/fde_xml_imp.cpp

Issue 2555373002: Use unique_ptr for CXFA_XMLParser. (Closed)
Patch Set: Alphabetize class Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fde/xml/fde_xml_imp.h ('k') | xfa/fxfa/parser/cxfa_simple_parser.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fde/xml/fde_xml_imp.h" 7 #include "xfa/fde/xml/fde_xml_imp.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility>
10 11
11 #include "core/fxcrt/fx_ext.h" 12 #include "core/fxcrt/fx_ext.h"
12 #include "core/fxcrt/fx_safe_types.h" 13 #include "core/fxcrt/fx_safe_types.h"
13 #include "xfa/fgas/crt/fgas_codepage.h" 14 #include "xfa/fgas/crt/fgas_codepage.h"
14 15
15 namespace { 16 namespace {
16 17
17 const uint32_t kMaxCharRange = 0x10ffff; 18 const uint32_t kMaxCharRange = 0x10ffff;
18 19
19 const uint16_t g_XMLValidCharRange[][2] = {{0x09, 0x09}, 20 const uint16_t g_XMLValidCharRange[][2] = {{0x09, 0x09},
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 } else { 951 } else {
951 if (m_pRoot) { 952 if (m_pRoot) {
952 m_pRoot->Release(); 953 m_pRoot->Release();
953 m_pRoot = nullptr; 954 m_pRoot = nullptr;
954 } 955 }
955 } 956 }
956 ReleaseParser(); 957 ReleaseParser();
957 } 958 }
958 959
959 void CFDE_XMLDoc::ReleaseParser() { 960 void CFDE_XMLDoc::ReleaseParser() {
960 if (m_pXMLParser) { 961 m_pXMLParser.reset();
961 m_pXMLParser->Release();
962 m_pXMLParser = nullptr;
963 }
964 if (m_pSyntaxParser) { 962 if (m_pSyntaxParser) {
965 m_pSyntaxParser->Release(); 963 m_pSyntaxParser->Release();
966 m_pSyntaxParser = nullptr; 964 m_pSyntaxParser = nullptr;
967 } 965 }
968 } 966 }
969 967
970 bool CFDE_XMLDoc::LoadXML(CFDE_XMLParser* pXMLParser) { 968 bool CFDE_XMLDoc::LoadXML(std::unique_ptr<IFDE_XMLParser> pXMLParser) {
971 if (!pXMLParser) 969 if (!pXMLParser)
972 return false; 970 return false;
973 971
974 Reset(true); 972 Reset(true);
975 m_pXMLParser = pXMLParser; 973 m_pXMLParser = std::move(pXMLParser);
976 return !!m_pXMLParser; 974 return true;
977 } 975 }
978 976
979 int32_t CFDE_XMLDoc::DoLoad(IFX_Pause* pPause) { 977 int32_t CFDE_XMLDoc::DoLoad(IFX_Pause* pPause) {
980 if (m_iStatus >= 100) 978 if (m_iStatus < 100)
981 return m_iStatus; 979 m_iStatus = m_pXMLParser->DoParser(pPause);
982 return m_iStatus = m_pXMLParser->DoParser(pPause); 980
981 return m_iStatus;
983 } 982 }
984 983
985 void CFDE_XMLDoc::CloseXML() { 984 void CFDE_XMLDoc::CloseXML() {
986 ReleaseParser(); 985 ReleaseParser();
987 } 986 }
988 987
989 void CFDE_XMLDoc::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream, 988 void CFDE_XMLDoc::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream,
990 CFDE_XMLNode* pINode) { 989 CFDE_XMLNode* pINode) {
991 CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode; 990 CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode;
992 switch (pNode->GetType()) { 991 switch (pNode->GetType()) {
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 m_BlockBuffer.DeleteTextChars(m_iDataLength - m_iEntityStart, false); 1909 m_BlockBuffer.DeleteTextChars(m_iDataLength - m_iEntityStart, false);
1911 m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); 1910 m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
1912 m_iEntityStart = -1; 1911 m_iEntityStart = -1;
1913 } else { 1912 } else {
1914 if (m_iEntityStart < 0 && character == L'&') { 1913 if (m_iEntityStart < 0 && character == L'&') {
1915 m_iEntityStart = m_iDataLength - 1; 1914 m_iEntityStart = m_iDataLength - 1;
1916 } 1915 }
1917 } 1916 }
1918 m_pStart++; 1917 m_pStart++;
1919 } 1918 }
OLDNEW
« no previous file with comments | « xfa/fde/xml/fde_xml_imp.h ('k') | xfa/fxfa/parser/cxfa_simple_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698