OLD | NEW |
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 "core/fxcrt/xml_int.h" | 7 #include "core/fxcrt/xml_int.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 } | 50 } |
51 | 51 |
52 size_t CXML_DataBufAcc::GetBlockSize() { | 52 size_t CXML_DataBufAcc::GetBlockSize() { |
53 return m_dwSize; | 53 return m_dwSize; |
54 } | 54 } |
55 | 55 |
56 FX_FILESIZE CXML_DataBufAcc::GetBlockOffset() { | 56 FX_FILESIZE CXML_DataBufAcc::GetBlockOffset() { |
57 return 0; | 57 return 0; |
58 } | 58 } |
59 | 59 |
60 CXML_DataStmAcc::CXML_DataStmAcc(IFX_FileRead* pFileRead) | 60 CXML_DataStmAcc::CXML_DataStmAcc(IFX_SeekableReadStream* pFileRead) |
61 : m_pFileRead(pFileRead), m_pBuffer(nullptr), m_nStart(0), m_dwSize(0) { | 61 : m_pFileRead(pFileRead), m_pBuffer(nullptr), m_nStart(0), m_dwSize(0) { |
62 ASSERT(m_pFileRead); | 62 ASSERT(m_pFileRead); |
63 } | 63 } |
64 | 64 |
65 CXML_DataStmAcc::~CXML_DataStmAcc() { | 65 CXML_DataStmAcc::~CXML_DataStmAcc() { |
66 FX_Free(m_pBuffer); | 66 FX_Free(m_pBuffer); |
67 } | 67 } |
68 | 68 |
69 void CXML_DataStmAcc::Release() { | 69 void CXML_DataStmAcc::Release() { |
70 delete this; | 70 delete this; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 CXML_Parser::~CXML_Parser() { | 125 CXML_Parser::~CXML_Parser() { |
126 if (m_bOwnedStream) { | 126 if (m_bOwnedStream) { |
127 m_pDataAcc->Release(); | 127 m_pDataAcc->Release(); |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 FX_BOOL CXML_Parser::Init(uint8_t* pBuffer, size_t size) { | 131 FX_BOOL CXML_Parser::Init(uint8_t* pBuffer, size_t size) { |
132 m_pDataAcc = new CXML_DataBufAcc(pBuffer, size); | 132 m_pDataAcc = new CXML_DataBufAcc(pBuffer, size); |
133 return Init(TRUE); | 133 return Init(TRUE); |
134 } | 134 } |
135 FX_BOOL CXML_Parser::Init(IFX_FileRead* pFileRead) { | 135 FX_BOOL CXML_Parser::Init(IFX_SeekableReadStream* pFileRead) { |
136 m_pDataAcc = new CXML_DataStmAcc(pFileRead); | 136 m_pDataAcc = new CXML_DataStmAcc(pFileRead); |
137 return Init(TRUE); | 137 return Init(TRUE); |
138 } | 138 } |
139 FX_BOOL CXML_Parser::Init(IFX_BufferRead* pBuffer) { | 139 FX_BOOL CXML_Parser::Init(IFX_BufferRead* pBuffer) { |
140 if (!pBuffer) { | 140 if (!pBuffer) { |
141 return FALSE; | 141 return FALSE; |
142 } | 142 } |
143 m_pDataAcc = pBuffer; | 143 m_pDataAcc = pBuffer; |
144 return Init(FALSE); | 144 return Init(FALSE); |
145 } | 145 } |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 CXML_Element* CXML_Element::Parse(const void* pBuffer, | 644 CXML_Element* CXML_Element::Parse(const void* pBuffer, |
645 size_t size, | 645 size_t size, |
646 FX_BOOL bSaveSpaceChars, | 646 FX_BOOL bSaveSpaceChars, |
647 FX_FILESIZE* pParsedSize) { | 647 FX_FILESIZE* pParsedSize) { |
648 CXML_Parser parser; | 648 CXML_Parser parser; |
649 if (!parser.Init((uint8_t*)pBuffer, size)) { | 649 if (!parser.Init((uint8_t*)pBuffer, size)) { |
650 return nullptr; | 650 return nullptr; |
651 } | 651 } |
652 return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); | 652 return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); |
653 } | 653 } |
654 CXML_Element* CXML_Element::Parse(IFX_FileRead* pFile, | 654 CXML_Element* CXML_Element::Parse(IFX_SeekableReadStream* pFile, |
655 FX_BOOL bSaveSpaceChars, | 655 FX_BOOL bSaveSpaceChars, |
656 FX_FILESIZE* pParsedSize) { | 656 FX_FILESIZE* pParsedSize) { |
657 CXML_Parser parser; | 657 CXML_Parser parser; |
658 if (!parser.Init(pFile)) { | 658 if (!parser.Init(pFile)) { |
659 return nullptr; | 659 return nullptr; |
660 } | 660 } |
661 return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); | 661 return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); |
662 } | 662 } |
663 CXML_Element* CXML_Element::Parse(IFX_BufferRead* pBuffer, | 663 CXML_Element* CXML_Element::Parse(IFX_BufferRead* pBuffer, |
664 FX_BOOL bSaveSpaceChars, | 664 FX_BOOL bSaveSpaceChars, |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 m_pMap->push_back({space, name, CFX_WideString(value)}); | 907 m_pMap->push_back({space, name, CFX_WideString(value)}); |
908 } | 908 } |
909 | 909 |
910 int CXML_AttrMap::GetSize() const { | 910 int CXML_AttrMap::GetSize() const { |
911 return m_pMap ? pdfium::CollectionSize<int>(*m_pMap) : 0; | 911 return m_pMap ? pdfium::CollectionSize<int>(*m_pMap) : 0; |
912 } | 912 } |
913 | 913 |
914 CXML_AttrItem& CXML_AttrMap::GetAt(int index) const { | 914 CXML_AttrItem& CXML_AttrMap::GetAt(int index) const { |
915 return (*m_pMap)[index]; | 915 return (*m_pMap)[index]; |
916 } | 916 } |
OLD | NEW |