1 // Copyright 2016 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef CORE_FPDFAPI_PARSER_CPDF_STREAM_ACC_H_ 8 #define CORE_FPDFAPI_PARSER_CPDF_STREAM_ACC_H_ 9 10 #include <memory> 11 12 #include "core/fpdfapi/parser/cpdf_dictionary.h" 13 #include "core/fpdfapi/parser/cpdf_stream.h" 14 #include "core/fxcrt/fx_string.h" 15 #include "core/fxcrt/fx_system.h" 16 #include "core/fxcrt/retain_ptr.h" 17 18 class CPDF_StreamAcc : public Retainable { 19 public: 20 template <typename T, typename... Args> 21 friend RetainPtr<T> pdfium::MakeRetain(Args&&... args); 22 23 CPDF_StreamAcc(const CPDF_StreamAcc&) = delete; 24 CPDF_StreamAcc& operator=(const CPDF_StreamAcc&) = delete; 25 26 void LoadAllData(bool bRawAccess, uint32_t estimated_size, bool bImageAcc); 27 void LoadAllDataFiltered(); 28 void LoadAllDataRaw(); 29 GetStream()30 const CPDF_Stream* GetStream() const { return m_pStream.Get(); } 31 CPDF_Dictionary* GetDict() const; 32 33 const uint8_t* GetData() const; 34 uint8_t* GetData(); 35 uint32_t GetSize() const; GetImageDecoder()36 const ByteString& GetImageDecoder() const { return m_ImageDecoder; } GetImageParam()37 const CPDF_Dictionary* GetImageParam() const { return m_pImageParam; } 38 std::unique_ptr<uint8_t, FxFreeDeleter> DetachData(); 39 40 protected: 41 explicit CPDF_StreamAcc(const CPDF_Stream* pStream); 42 ~CPDF_StreamAcc() override; 43 44 private: 45 uint8_t* GetDataHelper() const; 46 47 uint8_t* m_pData = nullptr; 48 uint32_t m_dwSize = 0; 49 bool m_bNewBuf = false; 50 ByteString m_ImageDecoder; 51 CPDF_Dictionary* m_pImageParam = nullptr; 52 UnownedPtr<const CPDF_Stream> const m_pStream; 53 uint8_t* m_pSrcData = nullptr; 54 }; 55 56 #endif // CORE_FPDFAPI_PARSER_CPDF_STREAM_ACC_H_ 57