7 #ifndef PDF_OBJECT_STREAM_H
8 #define PDF_OBJECT_STREAM_H
12 #include "PdfEncrypt.h"
13 #include <podofo/auxiliary/OutputStream.h>
14 #include <podofo/auxiliary/InputStream.h>
15 #include "PdfObjectStreamProvider.h"
20 class PdfObjectStream;
22 class PODOFO_API PdfObjectInputStream final :
public InputStream
24 friend class PdfObjectStream;
26 PdfObjectInputStream();
27 ~PdfObjectInputStream();
28 PdfObjectInputStream(PdfObjectInputStream&& rhs) noexcept;
30 PdfObjectInputStream(PdfObjectStream& stream,
bool raw);
32 const PdfFilterList& GetMediaFilters()
const {
return m_MediaFilters; }
33 const std::vector<const PdfDictionary*>& GetMediaDecodeParms()
const {
return m_MediaDecodeParms; }
35 size_t readBuffer(
char* buffer,
size_t size,
bool& eof)
override;
36 bool readChar(
char& ch)
override;
38 PdfObjectInputStream& operator=(PdfObjectInputStream&& rhs) noexcept;
40 PdfObjectStream* m_stream;
41 std::unique_ptr<InputStream> m_input;
42 PdfFilterList m_MediaFilters;
43 std::vector<const PdfDictionary*> m_MediaDecodeParms;
46 class PODOFO_API PdfObjectOutputStream final :
public OutputStream
48 friend class PdfObjectStream;
50 PdfObjectOutputStream();
51 ~PdfObjectOutputStream();
52 PdfObjectOutputStream(PdfObjectOutputStream&& rhs) noexcept;
58 PdfObjectOutputStream(PdfObjectStream& stream, PdfFilterList&& filters,
59 bool raw,
bool append);
60 PdfObjectOutputStream(PdfObjectStream& stream);
62 PdfObjectOutputStream(PdfObjectStream& stream, nullable<PdfFilterList> filters,
63 bool raw,
bool append,
bool skipSetDirty);
65 void writeBuffer(
const char* buffer,
size_t size)
override;
66 void flush()
override;
68 PdfObjectOutputStream& operator=(PdfObjectOutputStream&& rhs) noexcept;
70 PdfObjectStream* m_stream;
71 std::unique_ptr<OutputStream> m_output;
89 friend class PdfObjectInputStream;
90 friend class PdfObjectOutputStream;
91 PODOFO_PRIVATE_FRIEND(
class PdfParserObject);
92 PODOFO_PRIVATE_FRIEND(
class PdfImmediateWriter);
105 PdfObjectOutputStream GetOutputStreamRaw(
bool append =
false);
107 PdfObjectOutputStream GetOutputStreamRaw(
const PdfFilterList& filters,
bool append =
false);
109 PdfObjectOutputStream GetOutputStream(
bool append =
false);
111 PdfObjectOutputStream GetOutputStream(
const PdfFilterList& filters,
bool append =
false);
113 PdfObjectInputStream GetInputStream(
bool raw =
false)
const;
122 void SetData(
const bufferview& buffer,
bool raw =
false);
134 void SetData(
const bufferview& buffer,
const PdfFilterList& filters,
bool raw =
false);
143 void SetData(
InputStream& stream,
bool raw =
false);
155 void SetData(
InputStream& stream,
const PdfFilterList& filters,
bool raw =
false);
160 charbuff GetCopy(
bool raw =
false)
const;
170 void CopyTo(
charbuff& buffer,
bool raw =
false)
const;
174 void CopyToSafe(
charbuff& buffer)
const;
180 void CopyTo(
OutputStream& stream,
bool raw =
false)
const;
199 size_t GetLength()
const;
201 const PdfFilterList& GetFilters() {
return m_Filters; }
211 const PdfObjectStreamProvider& GetProvider()
const {
return *m_Provider; }
213 const PdfObject& GetParent()
const {
return *m_Parent; }
215 PdfObject& GetParent() {
return *m_Parent; }
222 void Write(
OutputStream& stream,
const PdfStatefulEncrypt* encrypt);
224 void SetParent(
PdfObject& parent) { m_Parent = &parent; }
226 void InitData(
InputStream& stream,
size_t len, PdfFilterList&& filterList);
236 PdfObjectStreamProvider& GetProvider() {
return *m_Provider; }
239 void ensureClosed()
const;
241 std::unique_ptr<InputStream> getInputStream(
bool raw, PdfFilterList& mediaFilters,
242 std::vector<const PdfDictionary*>& decodeParms);
244 void setData(
InputStream& stream, PdfFilterList filters,
bool raw,
245 ssize_t size,
bool markObjectDirty);
252 std::unique_ptr<PdfObjectStreamProvider> m_Provider;
253 PdfFilterList m_Filters;
SPDX-FileCopyrightText: (C) 2005 Dominik Seichter domseichter@web.de SPDX-FileCopyrightText: (C) 2020...
An interface for writing blocks of data to a data source.
Definition: OutputStream.h:18
A PDF stream can be appended to any PdfObject and can contain arbitrary data.
Definition: PdfObjectStream.h:87
This class represents a PDF indirect Object in memory.
Definition: PdfObject.h:35
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition: basetypes.h:38
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition: basetypes.h:16
cspan< char > bufferview
Convenient read-only char buffer span.
Definition: basetypes.h:19