7 #ifndef PDF_INDIRECT_OBJECT_LIST_H
8 #define PDF_INDIRECT_OBJECT_LIST_H
10 #include "PdfObject.h"
14 class PdfObjectStreamProvider;
15 using PdfFreeObjectList = std::deque<PdfReference>;
33 friend class PdfObjectOutputStream;
34 PODOFO_PRIVATE_FRIEND(
class PdfObjectStreamParser);
35 PODOFO_PRIVATE_FRIEND(
class PdfImmediateWriter);
36 PODOFO_PRIVATE_FRIEND(
class PdfParser);
37 PODOFO_PRIVATE_FRIEND(
class PdfWriter);
38 PODOFO_PRIVATE_FRIEND(
class PdfParserTest);
39 PODOFO_PRIVATE_FRIEND(
class PdfEncodingTest);
40 PODOFO_PRIVATE_FRIEND(
class PdfEncryptTest);
92 void CollectGarbage();
99 unsigned GetSize()
const;
121 class PODOFO_API Observer
125 virtual ~Observer() { }
130 virtual void BeginAppendStream(PdfObjectStream& stream) = 0;
135 virtual void EndAppendStream(PdfObjectStream& stream) = 0;
140 class PODOFO_API StreamFactory
143 virtual ~StreamFactory() { }
151 virtual std::unique_ptr<PdfObjectStreamProvider> CreateStream() = 0;
154 using ObjectNumSet = std::set<uint32_t>;
155 using ReferenceSet = std::set<PdfReference>;
156 using ObserverList = std::vector<Observer*>;
157 using ObjectList = std::set<PdfObject*, PdfObjectInequality>;
164 using iterator = ObjectList::const_iterator;
165 using reverse_iterator = ObjectList::const_reverse_iterator;
170 iterator begin()
const;
175 iterator end()
const;
177 reverse_iterator rbegin()
const;
179 reverse_iterator rend()
const;
184 PdfIndirectObjectList(PdfDocument& document);
185 PdfIndirectObjectList(PdfDocument& document,
const PdfIndirectObjectList& rhs);
187 PdfIndirectObjectList(
const PdfIndirectObjectList&) =
delete;
188 PdfIndirectObjectList& operator=(
const PdfIndirectObjectList&) =
delete;
198 std::unique_ptr<PdfObjectStreamProvider> CreateStream();
211 std::unique_ptr<PdfObject> RemoveObject(
const PdfReference& ref);
217 std::unique_ptr<PdfObject> RemoveObject(
const iterator& it);
233 void AttachObserver(Observer& observer);
239 void DetachObserver(Observer& observer);
244 void BeginAppendStream(PdfObjectStream& stream);
249 void EndAppendStream(PdfObjectStream& stream);
258 void PushObject(PdfObject* obj);
269 bool TryAddFreeObject(
const PdfReference& reference);
281 int32_t SafeAddFreeObject(
const PdfReference& reference);
288 void AddFreeObject(
const PdfReference& reference);
294 void AddObjectStream(uint32_t objectNum);
296 std::unique_ptr<PdfObject> RemoveObject(
const PdfReference& ref,
bool markAsFree);
302 void SetStreamFactory(StreamFactory* factory);
305 void pushObject(
const ObjectList::const_iterator& hintpos, ObjectList::node_type& node, PdfObject* obj);
307 std::unique_ptr<PdfObject> removeObject(
const iterator& it,
bool markAsFree);
309 void addNewObject(PdfObject* obj);
314 PdfReference getNextFreeObject();
316 int32_t tryAddFreeObject(uint32_t objnum, uint32_t gennum);
318 void visitObject(
const PdfObject& obj, std::unordered_set<PdfReference>& referencedObj);
326 void tryIncrementObjectCount(
const PdfReference& ref);
329 PdfDocument* m_Document;
330 ObjectList m_Objects;
331 unsigned m_ObjectCount;
332 PdfFreeObjectList m_FreeObjects;
333 ObjectNumSet m_unavailableObjects;
334 ObjectNumSet m_objectStreams;
336 ObserverList m_observers;
337 StreamFactory* m_StreamFactory;
PdfDocument is the core interface for working with PDF documents.
Definition: PdfDocument.h:108
A list of PdfObjects that constitutes the indirect object list of the document The PdfParser will rea...
Definition: PdfIndirectObjectList.h:30
const PdfFreeObjectList & GetFreeObjects() const
Definition: PdfIndirectObjectList.h:112
PdfDocument & GetDocument() const
Definition: PdfIndirectObjectList.h:116
unsigned GetObjectCount() const
Definition: PdfIndirectObjectList.h:108
This class represents a PdfName.
Definition: PdfName.h:24
static const PdfName Null
Null name, corresponds to "/".
Definition: PdfName.h:30
This class represents a PDF indirect Object in memory.
Definition: PdfObject.h:35
A reference is a pointer to a object in the PDF file of the form "4 0 R", where 4 is the object numbe...
Definition: PdfReference.h:24
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition: basetypes.h:16