4#ifndef PDF_ANNOTATION_COLLECTION_H
5#define PDF_ANNOTATION_COLLECTION_H
7#include "PdfAnnotation.h"
14 class PODOFO_API PdfAnnotationCollection final
17 friend class PdfAnnotation;
20 PdfAnnotationCollection(PdfPage& page);
23 template <
typename TAnnotation>
24 TAnnotation& CreateAnnot(
const Rect& rect);
26 PdfAnnotation& CreateAnnot(PdfAnnotationType annotType,
const Rect& rect);
28 PdfAnnotation& GetAnnotAt(
unsigned index);
30 const PdfAnnotation& GetAnnotAt(
unsigned index)
const;
32 PdfAnnotation& GetAnnot(
const PdfReference& ref);
34 const PdfAnnotation& GetAnnot(
const PdfReference& ref)
const;
36 void RemoveAnnotAt(
unsigned index);
38 void RemoveAnnot(
const PdfReference& ref);
40 unsigned GetCount()
const;
43 using AnnotationList = std::vector<std::unique_ptr<PdfAnnotation>>;
45 template <
typename TObject,
typename TListIterator>
48 friend class PdfAnnotationCollection;
50 using difference_type = void;
51 using value_type = TObject*;
53 using reference = void;
54 using iterator_category = std::forward_iterator_tag;
58 Iterator(
const TListIterator& iterator) : m_iterator(iterator) { }
60 Iterator(
const Iterator&) =
default;
61 Iterator& operator=(
const Iterator&) =
default;
62 bool operator==(
const Iterator& rhs)
const
64 return m_iterator == rhs.m_iterator;
66 bool operator!=(
const Iterator& rhs)
const
68 return m_iterator != rhs.m_iterator;
70 Iterator& operator++()
75 Iterator operator++(
int)
81 value_type operator*()
83 return m_iterator->get();
85 value_type operator->()
87 return m_iterator->get();
90 TListIterator m_iterator;
93 using iterator = Iterator<PdfAnnotation, AnnotationList::iterator>;
94 using const_iterator = Iterator<const PdfAnnotation, AnnotationList::const_iterator>;
99 const_iterator begin()
const;
100 const_iterator end()
const;
103 PdfAnnotation& addAnnotation(std::unique_ptr<PdfAnnotation>&& annot);
104 PdfArray* getAnnotationsArray()
const;
105 void initAnnotations();
106 PdfAnnotation& getAnnotAt(
unsigned index)
const;
107 PdfAnnotation& getAnnot(
const PdfReference& ref)
const;
108 void fixIndices(
unsigned index);
111 using AnnotationMap = std::map<PdfReference, unsigned>;
114 AnnotationList m_Annots;
115 std::unique_ptr<AnnotationMap> m_annotMap;
117 PdfArray* m_annotArray;
120 template<
typename TAnnotation>
121 TAnnotation& PdfAnnotationCollection::CreateAnnot(
const Rect& rect)
123 return static_cast<TAnnotation&
>(CreateAnnot(PdfAnnotation::GetAnnotationType<TAnnotation>(), rect));
All classes, functions, types and enums of PoDoFo are members of these namespace.
Definition basetypes.h:13