summaryrefslogtreecommitdiff
path: root/core/include/fpdfapi/cpdf_stream.h
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-03-10 14:10:38 -0800
committerTom Sepez <tsepez@chromium.org>2016-03-10 14:10:38 -0800
commit5fc239a0e64a5e16a23b99e128f88cc494d5b65c (patch)
treeb64c7dabd2783be77ef1758b18040fd83329ec6c /core/include/fpdfapi/cpdf_stream.h
parent79fcb5f6fa61967517566100415972848edefd24 (diff)
downloadpdfium-5fc239a0e64a5e16a23b99e128f88cc494d5b65c.tar.xz
Split fpdf_parser_objects.cpp into per-class .cpp/.h files.
R=dsinclair@chromium.org Review URL: https://codereview.chromium.org/1776913007 .
Diffstat (limited to 'core/include/fpdfapi/cpdf_stream.h')
-rw-r--r--core/include/fpdfapi/cpdf_stream.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/core/include/fpdfapi/cpdf_stream.h b/core/include/fpdfapi/cpdf_stream.h
new file mode 100644
index 0000000000..fd3b8c0047
--- /dev/null
+++ b/core/include/fpdfapi/cpdf_stream.h
@@ -0,0 +1,99 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_INCLUDE_FPDFAPI_CPDF_STREAM_H_
+#define CORE_INCLUDE_FPDFAPI_CPDF_STREAM_H_
+
+#include "core/include/fpdfapi/cpdf_object.h"
+#include "core/include/fxcrt/fx_stream.h"
+
+class CPDF_Stream : public CPDF_Object {
+ public:
+ CPDF_Stream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDict);
+
+ // CPDF_Object.
+ Type GetType() const override;
+ CPDF_Object* Clone(FX_BOOL bDirect = FALSE) const override;
+ CPDF_Dictionary* GetDict() const override;
+ CFX_WideString GetUnicodeText() const override;
+ bool IsStream() const override;
+ CPDF_Stream* AsStream() override;
+ const CPDF_Stream* AsStream() const override;
+
+ FX_DWORD GetRawSize() const { return m_dwSize; }
+ uint8_t* GetRawData() const { return m_pDataBuf; }
+
+ void SetData(const uint8_t* pData,
+ FX_DWORD size,
+ FX_BOOL bCompressed,
+ FX_BOOL bKeepBuf);
+
+ void InitStream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDict);
+ void InitStreamFromFile(IFX_FileRead* pFile, CPDF_Dictionary* pDict);
+
+ FX_BOOL ReadRawData(FX_FILESIZE start_pos,
+ uint8_t* pBuf,
+ FX_DWORD buf_size) const;
+
+ bool IsMemoryBased() const { return m_GenNum == kMemoryBasedGenNum; }
+
+ protected:
+ static const FX_DWORD kMemoryBasedGenNum = (FX_DWORD)-1;
+
+ ~CPDF_Stream() override;
+
+ void InitStreamInternal(CPDF_Dictionary* pDict);
+
+ CPDF_Dictionary* m_pDict;
+ FX_DWORD m_dwSize;
+ FX_DWORD m_GenNum;
+
+ union {
+ uint8_t* m_pDataBuf;
+ IFX_FileRead* m_pFile;
+ };
+};
+
+inline CPDF_Stream* ToStream(CPDF_Object* obj) {
+ return obj ? obj->AsStream() : nullptr;
+}
+
+inline const CPDF_Stream* ToStream(const CPDF_Object* obj) {
+ return obj ? obj->AsStream() : nullptr;
+}
+
+class CPDF_StreamAcc {
+ public:
+ CPDF_StreamAcc();
+ ~CPDF_StreamAcc();
+
+ void LoadAllData(const CPDF_Stream* pStream,
+ FX_BOOL bRawAccess = FALSE,
+ FX_DWORD estimated_size = 0,
+ FX_BOOL bImageAcc = FALSE);
+
+ const CPDF_Stream* GetStream() const { return m_pStream; }
+ CPDF_Dictionary* GetDict() const {
+ return m_pStream ? m_pStream->GetDict() : nullptr;
+ }
+ const uint8_t* GetData() const;
+ FX_DWORD GetSize() const;
+ const CFX_ByteString& GetImageDecoder() const { return m_ImageDecoder; }
+ const CPDF_Dictionary* GetImageParam() const { return m_pImageParam; }
+
+ uint8_t* DetachData();
+
+ protected:
+ uint8_t* m_pData;
+ FX_DWORD m_dwSize;
+ FX_BOOL m_bNewBuf;
+ CFX_ByteString m_ImageDecoder;
+ CPDF_Dictionary* m_pImageParam;
+ const CPDF_Stream* m_pStream;
+ uint8_t* m_pSrcData;
+};
+
+#endif // CORE_INCLUDE_FPDFAPI_CPDF_STREAM_H_