summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_stream.h
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-10-04 11:55:50 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-04 11:55:51 -0700
commit488b7ad845d6de212d89cd957303b294ecfa5922 (patch)
treeadfdd2327724bd3597a1a7614bbe29a01a0c8dc0 /core/fpdfapi/parser/cpdf_stream.h
parent41872fa5ac7448a50f66ad56d7bde8d1aa77db4b (diff)
downloadpdfium-488b7ad845d6de212d89cd957303b294ecfa5922.tar.xz
Move core/fpdfapi/fpdf_parser to core/fpdfapi/parser
BUG=pdfium:603 Review-Url: https://codereview.chromium.org/2392603004
Diffstat (limited to 'core/fpdfapi/parser/cpdf_stream.h')
-rw-r--r--core/fpdfapi/parser/cpdf_stream.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/core/fpdfapi/parser/cpdf_stream.h b/core/fpdfapi/parser/cpdf_stream.h
new file mode 100644
index 0000000000..6a4f1011c0
--- /dev/null
+++ b/core/fpdfapi/parser/cpdf_stream.h
@@ -0,0 +1,61 @@
+// 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_FPDFAPI_PARSER_CPDF_STREAM_H_
+#define CORE_FPDFAPI_PARSER_CPDF_STREAM_H_
+
+#include <memory>
+#include <set>
+
+#include "core/fpdfapi/parser/cpdf_dictionary.h"
+#include "core/fpdfapi/parser/cpdf_object.h"
+#include "core/fxcrt/fx_basic.h"
+
+class CPDF_Stream : public CPDF_Object {
+ public:
+ CPDF_Stream();
+
+ // Takes ownership of |pData| and |pDict|.
+ CPDF_Stream(uint8_t* pData, uint32_t size, CPDF_Dictionary* pDict);
+
+ // CPDF_Object.
+ Type GetType() const override;
+ CPDF_Object* Clone() 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;
+
+ uint32_t GetRawSize() const { return m_dwSize; }
+ uint8_t* GetRawData() const { return m_pDataBuf.get(); }
+
+ // Does not takes onwership of |pData|, copies into internally-owned buffer.
+ void SetData(const uint8_t* pData, uint32_t size);
+
+ void InitStream(const uint8_t* pData, uint32_t size, CPDF_Dictionary* pDict);
+ void InitStreamFromFile(IFX_FileRead* pFile, CPDF_Dictionary* pDict);
+
+ FX_BOOL ReadRawData(FX_FILESIZE start_pos,
+ uint8_t* pBuf,
+ uint32_t buf_size) const;
+
+ bool IsMemoryBased() const { return m_bMemoryBased; }
+
+ protected:
+ ~CPDF_Stream() override;
+ CPDF_Object* CloneNonCyclic(
+ bool bDirect,
+ std::set<const CPDF_Object*>* pVisited) const override;
+
+ std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> m_pDict;
+ bool m_bMemoryBased = true;
+ uint32_t m_dwSize = 0;
+ std::unique_ptr<uint8_t, FxFreeDeleter> m_pDataBuf;
+ IFX_FileRead* m_pFile = nullptr;
+};
+
+#endif // CORE_FPDFAPI_PARSER_CPDF_STREAM_H_