diff options
author | weili <weili@chromium.org> | 2016-06-14 17:21:14 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-14 17:21:14 -0700 |
commit | f4bb580add3824196dc49cd7de2f7d051019ede8 (patch) | |
tree | 15c1db6fb7000330d48c105c66acf1d468ba56bd /core/fxcrt/fx_xml_parser.cpp | |
parent | ee2abec93f22bd10522181dc0362f24d389fc66b (diff) | |
download | pdfium-f4bb580add3824196dc49cd7de2f7d051019ede8.tar.xz |
Make code compile with clang_use_chrome_plugin (part II)
This change contains files in core directory which were not covered
in part I. This is part of the efforts to make PDFium code compilable
by Clang chromium style plugins.
The changes are mainly the following:
-- move inline constructor/destructor of complex class/struct out-of-line;
-- add constructor/destructor of complex class/struct if not
explicitly defined;
-- add explicit out-of-line copy constructor when needed;
-- move inline virtual functions out-of-line;
-- Properly mark virtual functions with 'override';
-- some minor cleanups;
BUG=pdfium:469
Review-Url: https://codereview.chromium.org/2060913003
Diffstat (limited to 'core/fxcrt/fx_xml_parser.cpp')
-rw-r--r-- | core/fxcrt/fx_xml_parser.cpp | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp index 6017bd8fda..9412cdde04 100644 --- a/core/fxcrt/fx_xml_parser.cpp +++ b/core/fxcrt/fx_xml_parser.cpp @@ -12,11 +12,121 @@ #include "core/fxcrt/include/fx_xml.h" #include "third_party/base/stl_util.h" +CXML_DataBufAcc::CXML_DataBufAcc(const uint8_t* pBuffer, size_t size) + : m_pBuffer(pBuffer), m_dwSize(size), m_dwCurPos(0) {} + +CXML_DataBufAcc::~CXML_DataBufAcc() {} + +void CXML_DataBufAcc::Release() { + delete this; +} + +FX_BOOL CXML_DataBufAcc::IsEOF() { + return m_dwCurPos >= m_dwSize; +} + +FX_FILESIZE CXML_DataBufAcc::GetPosition() { + return (FX_FILESIZE)m_dwCurPos; +} + +size_t CXML_DataBufAcc::ReadBlock(void* buffer, size_t size) { + return 0; +} + +FX_BOOL CXML_DataBufAcc::ReadNextBlock(FX_BOOL bRestart) { + if (bRestart) { + m_dwCurPos = 0; + } + if (m_dwCurPos < m_dwSize) { + m_dwCurPos = m_dwSize; + return TRUE; + } + return FALSE; +} + +const uint8_t* CXML_DataBufAcc::GetBlockBuffer() { + return m_pBuffer; +} + +size_t CXML_DataBufAcc::GetBlockSize() { + return m_dwSize; +} + +FX_FILESIZE CXML_DataBufAcc::GetBlockOffset() { + return 0; +} + +CXML_DataStmAcc::CXML_DataStmAcc(IFX_FileRead* pFileRead) + : m_pFileRead(pFileRead), m_pBuffer(nullptr), m_nStart(0), m_dwSize(0) { + ASSERT(m_pFileRead); +} + +CXML_DataStmAcc::~CXML_DataStmAcc() { + FX_Free(m_pBuffer); +} + +void CXML_DataStmAcc::Release() { + delete this; +} + +FX_BOOL CXML_DataStmAcc::IsEOF() { + return m_nStart + (FX_FILESIZE)m_dwSize >= m_pFileRead->GetSize(); +} + +FX_FILESIZE CXML_DataStmAcc::GetPosition() { + return m_nStart + (FX_FILESIZE)m_dwSize; +} + +size_t CXML_DataStmAcc::ReadBlock(void* buffer, size_t size) { + return 0; +} + +FX_BOOL CXML_DataStmAcc::ReadNextBlock(FX_BOOL bRestart) { + if (bRestart) { + m_nStart = 0; + } + FX_FILESIZE nLength = m_pFileRead->GetSize(); + m_nStart += (FX_FILESIZE)m_dwSize; + if (m_nStart >= nLength) { + return FALSE; + } + static const FX_FILESIZE FX_XMLDATASTREAM_BufferSize = 32 * 1024; + m_dwSize = static_cast<size_t>( + std::min(FX_XMLDATASTREAM_BufferSize, nLength - m_nStart)); + if (!m_pBuffer) { + m_pBuffer = FX_Alloc(uint8_t, m_dwSize); + } + return m_pFileRead->ReadBlock(m_pBuffer, m_nStart, m_dwSize); +} + +const uint8_t* CXML_DataStmAcc::GetBlockBuffer() { + return (const uint8_t*)m_pBuffer; +} + +size_t CXML_DataStmAcc::GetBlockSize() { + return m_dwSize; +} + +FX_FILESIZE CXML_DataStmAcc::GetBlockOffset() { + return m_nStart; +} + +CXML_Parser::CXML_Parser() + : m_pDataAcc(nullptr), + m_bOwnedStream(FALSE), + m_nOffset(0), + m_bSaveSpaceChars(FALSE), + m_pBuffer(nullptr), + m_dwBufferSize(0), + m_nBufferOffset(0), + m_dwIndex(0) {} + CXML_Parser::~CXML_Parser() { if (m_bOwnedStream) { m_pDataAcc->Release(); } } + FX_BOOL CXML_Parser::Init(uint8_t* pBuffer, size_t size) { m_pDataAcc = new CXML_DataBufAcc(pBuffer, size); return Init(TRUE); @@ -764,6 +874,10 @@ bool CXML_AttrItem::Matches(const CFX_ByteString& space, return (space.IsEmpty() || m_QSpaceName == space) && m_AttrName == name; } +CXML_AttrMap::CXML_AttrMap() {} + +CXML_AttrMap::~CXML_AttrMap() {} + const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteString& space, const CFX_ByteString& name) const { if (!m_pMap) |