| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CORE_FPDFAPI_PARSER_CPDF_STREAM_H_ | 7 #ifndef CORE_FPDFAPI_PARSER_CPDF_STREAM_H_ |
| 8 #define CORE_FPDFAPI_PARSER_CPDF_STREAM_H_ | 8 #define CORE_FPDFAPI_PARSER_CPDF_STREAM_H_ |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 uint32_t GetRawSize() const { return m_dwSize; } | 37 uint32_t GetRawSize() const { return m_dwSize; } |
| 38 uint8_t* GetRawData() const { return m_pDataBuf.get(); } | 38 uint8_t* GetRawData() const { return m_pDataBuf.get(); } |
| 39 | 39 |
| 40 // Does not takes onwership of |pData|, copies into internally-owned buffer. | 40 // Does not takes onwership of |pData|, copies into internally-owned buffer. |
| 41 void SetData(const uint8_t* pData, uint32_t size); | 41 void SetData(const uint8_t* pData, uint32_t size); |
| 42 | 42 |
| 43 void InitStream(const uint8_t* pData, | 43 void InitStream(const uint8_t* pData, |
| 44 uint32_t size, | 44 uint32_t size, |
| 45 std::unique_ptr<CPDF_Dictionary> pDict); | 45 std::unique_ptr<CPDF_Dictionary> pDict); |
| 46 void InitStreamFromFile(IFX_SeekableReadStream* pFile, | 46 void InitStreamFromFile(const CFX_RetainPtr<IFX_SeekableReadStream>& pFile, |
| 47 std::unique_ptr<CPDF_Dictionary> pDict); | 47 std::unique_ptr<CPDF_Dictionary> pDict); |
| 48 | 48 |
| 49 bool ReadRawData(FX_FILESIZE start_pos, | 49 bool ReadRawData(FX_FILESIZE start_pos, |
| 50 uint8_t* pBuf, | 50 uint8_t* pBuf, |
| 51 uint32_t buf_size) const; | 51 uint32_t buf_size) const; |
| 52 | 52 |
| 53 bool IsMemoryBased() const { return m_bMemoryBased; } | 53 bool IsMemoryBased() const { return m_bMemoryBased; } |
| 54 bool HasFilter() const; | 54 bool HasFilter() const; |
| 55 | 55 |
| 56 protected: | 56 protected: |
| 57 std::unique_ptr<CPDF_Object> CloneNonCyclic( | 57 std::unique_ptr<CPDF_Object> CloneNonCyclic( |
| 58 bool bDirect, | 58 bool bDirect, |
| 59 std::set<const CPDF_Object*>* pVisited) const override; | 59 std::set<const CPDF_Object*>* pVisited) const override; |
| 60 | 60 |
| 61 bool m_bMemoryBased = true; | 61 bool m_bMemoryBased = true; |
| 62 uint32_t m_dwSize = 0; | 62 uint32_t m_dwSize = 0; |
| 63 std::unique_ptr<CPDF_Dictionary> m_pDict; | 63 std::unique_ptr<CPDF_Dictionary> m_pDict; |
| 64 std::unique_ptr<uint8_t, FxFreeDeleter> m_pDataBuf; | 64 std::unique_ptr<uint8_t, FxFreeDeleter> m_pDataBuf; |
| 65 IFX_SeekableReadStream* m_pFile = nullptr; | 65 CFX_RetainPtr<IFX_SeekableReadStream> m_pFile; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 inline CPDF_Stream* ToStream(CPDF_Object* obj) { | 68 inline CPDF_Stream* ToStream(CPDF_Object* obj) { |
| 69 return obj ? obj->AsStream() : nullptr; | 69 return obj ? obj->AsStream() : nullptr; |
| 70 } | 70 } |
| 71 | 71 |
| 72 inline const CPDF_Stream* ToStream(const CPDF_Object* obj) { | 72 inline const CPDF_Stream* ToStream(const CPDF_Object* obj) { |
| 73 return obj ? obj->AsStream() : nullptr; | 73 return obj ? obj->AsStream() : nullptr; |
| 74 } | 74 } |
| 75 | 75 |
| 76 inline std::unique_ptr<CPDF_Stream> ToStream(std::unique_ptr<CPDF_Object> obj) { | 76 inline std::unique_ptr<CPDF_Stream> ToStream(std::unique_ptr<CPDF_Object> obj) { |
| 77 CPDF_Stream* pStream = ToStream(obj.get()); | 77 CPDF_Stream* pStream = ToStream(obj.get()); |
| 78 if (!pStream) | 78 if (!pStream) |
| 79 return nullptr; | 79 return nullptr; |
| 80 obj.release(); | 80 obj.release(); |
| 81 return std::unique_ptr<CPDF_Stream>(pStream); | 81 return std::unique_ptr<CPDF_Stream>(pStream); |
| 82 } | 82 } |
| 83 | 83 |
| 84 #endif // CORE_FPDFAPI_PARSER_CPDF_STREAM_H_ | 84 #endif // CORE_FPDFAPI_PARSER_CPDF_STREAM_H_ |
| OLD | NEW |