mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:37:36 +00:00
LibPDF: Add support for stream filters
This commit also splits up StreamObject into PlainTextStreamObject and EncodedStreamObject, which is essentially just a stream object which does not own its bytes vs one which does.
This commit is contained in:
parent
97cc482087
commit
477e3946e5
6 changed files with 253 additions and 7 deletions
|
@ -147,18 +147,17 @@ private:
|
|||
HashMap<FlyString, Value> m_map;
|
||||
};
|
||||
|
||||
class StreamObject final : public Object {
|
||||
class StreamObject : public Object {
|
||||
public:
|
||||
StreamObject(const NonnullRefPtr<DictObject>& dict, const ReadonlyBytes& bytes)
|
||||
explicit StreamObject(const NonnullRefPtr<DictObject>& dict)
|
||||
: m_dict(dict)
|
||||
, m_bytes(bytes)
|
||||
{
|
||||
}
|
||||
|
||||
~StreamObject() override = default;
|
||||
virtual ~StreamObject() override = default;
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE NonnullRefPtr<DictObject> dict() const { return m_dict; }
|
||||
[[nodiscard]] ALWAYS_INLINE const ReadonlyBytes& bytes() const { return m_bytes; }
|
||||
[[nodiscard]] virtual ReadonlyBytes bytes() const = 0;
|
||||
|
||||
ALWAYS_INLINE bool is_stream() const override { return true; }
|
||||
ALWAYS_INLINE const char* type_name() const override { return "stream"; }
|
||||
|
@ -166,9 +165,40 @@ public:
|
|||
|
||||
private:
|
||||
NonnullRefPtr<DictObject> m_dict;
|
||||
};
|
||||
|
||||
class PlainTextStreamObject final : public StreamObject {
|
||||
public:
|
||||
PlainTextStreamObject(const NonnullRefPtr<DictObject>& dict, const ReadonlyBytes& bytes)
|
||||
: StreamObject(dict)
|
||||
, m_bytes(bytes)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~PlainTextStreamObject() override = default;
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE virtual ReadonlyBytes bytes() const override { return m_bytes; }
|
||||
|
||||
private:
|
||||
ReadonlyBytes m_bytes;
|
||||
};
|
||||
|
||||
class EncodedStreamObject final : public StreamObject {
|
||||
public:
|
||||
EncodedStreamObject(const NonnullRefPtr<DictObject>& dict, ByteBuffer&& buffer)
|
||||
: StreamObject(dict)
|
||||
, m_buffer(buffer)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~EncodedStreamObject() override = default;
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE virtual ReadonlyBytes bytes() const override { return m_buffer.bytes(); }
|
||||
|
||||
private:
|
||||
ByteBuffer m_buffer;
|
||||
};
|
||||
|
||||
class IndirectValue final : public Object {
|
||||
public:
|
||||
IndirectValue(u32 index, u32 generation_index, const Value& value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue