From d912f6ba083fed382a13c47aa06299e86d0b8c6b Mon Sep 17 00:00:00 2001 From: tsepez Date: Thu, 1 Dec 2016 14:51:52 -0800 Subject: Make concrete stream classes private to .cpp, part 2 Fix naming to say "Stream" Review-Url: https://codereview.chromium.org/2543043002 --- core/fxcrt/fx_stream.h | 2 +- core/fxcrt/fx_xml.h | 2 +- core/fxcrt/fx_xml_parser.cpp | 49 +++++++++++++++++++++++++++++++++++++++++--- core/fxcrt/xml_int.h | 47 ++---------------------------------------- xfa/fgas/crt/fgas_stream.cpp | 17 +++++++-------- 5 files changed, 59 insertions(+), 58 deletions(-) diff --git a/core/fxcrt/fx_stream.h b/core/fxcrt/fx_stream.h index fe92c939d9..e938ec18df 100644 --- a/core/fxcrt/fx_stream.h +++ b/core/fxcrt/fx_stream.h @@ -151,7 +151,7 @@ class IFX_MemoryStream : public IFX_SeekableStream { virtual void DetachBuffer() = 0; }; -class IFX_BufferRead : public IFX_ReadStream { +class IFX_BufferedReadStream : public IFX_ReadStream { public: // IFX_ReadStream: void Release() override = 0; diff --git a/core/fxcrt/fx_xml.h b/core/fxcrt/fx_xml.h index a7375b9e90..03337d0142 100644 --- a/core/fxcrt/fx_xml.h +++ b/core/fxcrt/fx_xml.h @@ -61,7 +61,7 @@ class CXML_Element { static CXML_Element* Parse(IFX_SeekableReadStream* pFile, bool bSaveSpaceChars = false, FX_FILESIZE* pParsedSize = nullptr); - static CXML_Element* Parse(IFX_BufferRead* pBuffer, + static CXML_Element* Parse(IFX_BufferedReadStream* pBuffer, bool bSaveSpaceChars = false, FX_FILESIZE* pParsedSize = nullptr); diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp index 3391086e90..803ba597e5 100644 --- a/core/fxcrt/fx_xml_parser.cpp +++ b/core/fxcrt/fx_xml_parser.cpp @@ -68,7 +68,26 @@ bool g_FXCRT_XML_IsNameChar(uint8_t ch) { return !!(g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_NameChar); } -} // namespace +class CXML_DataBufAcc : public IFX_BufferedReadStream { + public: + CXML_DataBufAcc(const uint8_t* pBuffer, size_t size); + ~CXML_DataBufAcc() override; + + // IFX_BufferedReadStream + void Release() override; + bool IsEOF() override; + FX_FILESIZE GetPosition() override; + size_t ReadBlock(void* buffer, size_t size) override; + bool ReadNextBlock(bool bRestart) override; + const uint8_t* GetBlockBuffer() override; + size_t GetBlockSize() override; + FX_FILESIZE GetBlockOffset() override; + + private: + const uint8_t* m_pBuffer; + size_t m_dwSize; + size_t m_dwCurPos; +}; CXML_DataBufAcc::CXML_DataBufAcc(const uint8_t* pBuffer, size_t size) : m_pBuffer(pBuffer), m_dwSize(size), m_dwCurPos(0) {} @@ -114,6 +133,28 @@ FX_FILESIZE CXML_DataBufAcc::GetBlockOffset() { return 0; } +class CXML_DataStmAcc : public IFX_BufferedReadStream { + public: + explicit CXML_DataStmAcc(IFX_SeekableReadStream* pFileRead); + ~CXML_DataStmAcc() override; + + // IFX_BufferedReadStream + void Release() override; + bool IsEOF() override; + FX_FILESIZE GetPosition() override; + size_t ReadBlock(void* buffer, size_t size) override; + bool ReadNextBlock(bool bRestart) override; + const uint8_t* GetBlockBuffer() override; + size_t GetBlockSize() override; + FX_FILESIZE GetBlockOffset() override; + + private: + IFX_SeekableReadStream* m_pFileRead; + uint8_t* m_pBuffer; + FX_FILESIZE m_nStart; + size_t m_dwSize; +}; + CXML_DataStmAcc::CXML_DataStmAcc(IFX_SeekableReadStream* pFileRead) : m_pFileRead(pFileRead), m_pBuffer(nullptr), m_nStart(0), m_dwSize(0) { ASSERT(m_pFileRead); @@ -169,6 +210,8 @@ FX_FILESIZE CXML_DataStmAcc::GetBlockOffset() { return m_nStart; } +} // namespace + CXML_Parser::CXML_Parser() : m_pDataAcc(nullptr), m_bOwnedStream(false), @@ -195,7 +238,7 @@ bool CXML_Parser::Init(IFX_SeekableReadStream* pFileRead) { return Init(true); } -bool CXML_Parser::Init(IFX_BufferRead* pBuffer) { +bool CXML_Parser::Init(IFX_BufferedReadStream* pBuffer) { if (!pBuffer) return false; @@ -667,7 +710,7 @@ CXML_Element* CXML_Element::Parse(IFX_SeekableReadStream* pFile, } return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); } -CXML_Element* CXML_Element::Parse(IFX_BufferRead* pBuffer, +CXML_Element* CXML_Element::Parse(IFX_BufferedReadStream* pBuffer, bool bSaveSpaceChars, FX_FILESIZE* pParsedSize) { CXML_Parser parser; diff --git a/core/fxcrt/xml_int.h b/core/fxcrt/xml_int.h index d65fdad58c..f5beaef9ae 100644 --- a/core/fxcrt/xml_int.h +++ b/core/fxcrt/xml_int.h @@ -14,49 +14,6 @@ class CFX_UTF8Decoder; class CXML_Element; -class CXML_DataBufAcc : public IFX_BufferRead { - public: - CXML_DataBufAcc(const uint8_t* pBuffer, size_t size); - ~CXML_DataBufAcc() override; - - // IFX_BufferRead - void Release() override; - bool IsEOF() override; - FX_FILESIZE GetPosition() override; - size_t ReadBlock(void* buffer, size_t size) override; - bool ReadNextBlock(bool bRestart = false) override; - const uint8_t* GetBlockBuffer() override; - size_t GetBlockSize() override; - FX_FILESIZE GetBlockOffset() override; - - protected: - const uint8_t* m_pBuffer; - size_t m_dwSize; - size_t m_dwCurPos; -}; - -class CXML_DataStmAcc : public IFX_BufferRead { - public: - explicit CXML_DataStmAcc(IFX_SeekableReadStream* pFileRead); - ~CXML_DataStmAcc() override; - - // IFX_BufferRead - void Release() override; - bool IsEOF() override; - FX_FILESIZE GetPosition() override; - size_t ReadBlock(void* buffer, size_t size) override; - bool ReadNextBlock(bool bRestart = false) override; - const uint8_t* GetBlockBuffer() override; - size_t GetBlockSize() override; - FX_FILESIZE GetBlockOffset() override; - - protected: - IFX_SeekableReadStream* m_pFileRead; - uint8_t* m_pBuffer; - FX_FILESIZE m_nStart; - size_t m_dwSize; -}; - class CXML_Parser { public: CXML_Parser(); @@ -64,7 +21,7 @@ class CXML_Parser { bool Init(uint8_t* pBuffer, size_t size); bool Init(IFX_SeekableReadStream* pFileRead); - bool Init(IFX_BufferRead* pBuffer); + bool Init(IFX_BufferedReadStream* pBuffer); bool Init(bool bOwndedStream); bool ReadNextBlock(); bool IsEOF(); @@ -84,7 +41,7 @@ class CXML_Parser { CXML_Element* pElement); void InsertCDATASegment(CFX_UTF8Decoder& decoder, CXML_Element* pElement); - IFX_BufferRead* m_pDataAcc; + IFX_BufferedReadStream* m_pDataAcc; bool m_bOwnedStream; FX_FILESIZE m_nOffset; bool m_bSaveSpaceChars; diff --git a/xfa/fgas/crt/fgas_stream.cpp b/xfa/fgas/crt/fgas_stream.cpp index 73d3d0b661..485d229282 100644 --- a/xfa/fgas/crt/fgas_stream.cpp +++ b/xfa/fgas/crt/fgas_stream.cpp @@ -129,7 +129,7 @@ class CFX_BufferReadStreamImp : public IFX_StreamImp { CFX_BufferReadStreamImp(); ~CFX_BufferReadStreamImp() override; - bool LoadBufferRead(IFX_BufferRead* pBufferRead, + bool LoadBufferRead(IFX_BufferedReadStream* pBufferRead, int32_t iFileSize, uint32_t dwAccess, bool bReleaseBufferRead); @@ -151,7 +151,7 @@ class CFX_BufferReadStreamImp : public IFX_StreamImp { bool SetLength(int32_t iLength) override { return false; } private: - IFX_BufferRead* m_pBufferRead; + IFX_BufferedReadStream* m_pBufferRead; bool m_bReleaseBufferRead; int32_t m_iPosition; int32_t m_iBufferSize; @@ -200,7 +200,7 @@ class CFX_Stream : public IFX_Stream { bool LoadBuffer(uint8_t* pData, int32_t iTotalSize, uint32_t dwAccess); bool LoadFileRead(IFX_SeekableReadStream* pFileRead, uint32_t dwAccess); bool LoadFileWrite(IFX_SeekableWriteStream* pFileWrite, uint32_t dwAccess); - bool LoadBufferRead(IFX_BufferRead* pBufferRead, + bool LoadBufferRead(IFX_BufferedReadStream* pBufferRead, int32_t iFileSize, uint32_t dwAccess, bool bReleaseBufferRead); @@ -608,10 +608,11 @@ CFX_BufferReadStreamImp::~CFX_BufferReadStreamImp() { m_pBufferRead->Release(); } } -bool CFX_BufferReadStreamImp::LoadBufferRead(IFX_BufferRead* pBufferRead, - int32_t iFileSize, - uint32_t dwAccess, - bool bReleaseBufferRead) { +bool CFX_BufferReadStreamImp::LoadBufferRead( + IFX_BufferedReadStream* pBufferRead, + int32_t iFileSize, + uint32_t dwAccess, + bool bReleaseBufferRead) { ASSERT(!m_pBufferRead && pBufferRead); if (dwAccess & FX_STREAMACCESS_Write) { return false; @@ -1195,7 +1196,7 @@ bool CFX_Stream::LoadBuffer(uint8_t* pData, return true; } -bool CFX_Stream::LoadBufferRead(IFX_BufferRead* pBufferRead, +bool CFX_Stream::LoadBufferRead(IFX_BufferedReadStream* pBufferRead, int32_t iFileSize, uint32_t dwAccess, bool bReleaseBufferRead) { -- cgit v1.2.3