PoDoFo 1.2.0
Loading...
Searching...
No Matches
PdfReference.h
1// SPDX-FileCopyrightText: 2006 Dominik Seichter <domseichter@web.de>
2// SPDX-FileCopyrightText: 2020 Francesco Pretto <ceztko@gmail.com>
3// SPDX-License-Identifier: LGPL-2.0-or-later OR MPL-2.0
4
5#ifndef PDF_REFERENCE_H
6#define PDF_REFERENCE_H
7
8#include "PdfBaseDataTypes.h"
9
10namespace PoDoFo {
11
12class OutputStream;
13
19class PODOFO_API PdfReference final : private PdfDataMember, public PdfDataProvider<PdfReference>
20{
21public:
25
31
35 PdfReference(const PdfReference& rhs) = default;
36
41
42 void Write(OutputStream& stream, PdfWriteFlags flags, const PdfStatefulEncrypt* encrypt, charbuff& buffer) const;
43
46 bool operator==(const PdfReference& rhs) const;
47
50 bool operator!=(const PdfReference& rhs) const;
51
54 bool operator<(const PdfReference& rhs) const;
55
64 bool IsIndirect() const;
65
66public:
69 inline void SetObjectNumber(uint32_t o) { m_ObjectNo = o; }
70
73 inline uint32_t ObjectNumber() const { return m_ObjectNo; }
74
77 inline void SetGenerationNumber(const uint16_t g) { m_GenerationNo = g; }
78
81 inline uint16_t GenerationNumber() const { return m_GenerationNo; }
82
83private:
84 uint16_t m_GenerationNo;
85 uint32_t m_ObjectNo;
86};
87
88};
89
90namespace std
91{
93 template<>
94 struct hash<PoDoFo::PdfReference>
95 {
96 std::size_t operator()(const PoDoFo::PdfReference& ref) const noexcept
97 {
98 return ref.ObjectNumber() ^ (ref.GenerationNumber() << 16);
99 }
100 };
101}
102
103#endif // PDF_REFERENCE_H
An interface for writing blocks of data to a data source.
Definition OutputStream.h:15
A class to inherit for classes that are stored as union members in a PdfVariant.
Definition PdfBaseDataTypes.h:18
An helper class to inherit to provide common serialization methods.
Definition PdfBaseDataTypes.h:36
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:20
PdfReference(const PdfReference &rhs)=default
Create a copy of an existing PdfReference.
void SetObjectNumber(uint32_t o)
Set the object number of this object.
Definition PdfReference.h:69
PdfReference & operator=(const PdfReference &rhs)=default
Assign the value of another object to this PdfReference.
void SetGenerationNumber(const uint16_t g)
Set the generation number of this object.
Definition PdfReference.h:77
uint16_t GenerationNumber() const
Get the generation number.
Definition PdfReference.h:81
uint32_t ObjectNumber() const
Get the object number.
Definition PdfReference.h:73
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition basetypes.h:30
All classes, functions, types and enums of PoDoFo are members of these namespace.
Definition basetypes.h:13
PdfWriteFlags
Specify additional options for writing the PDF.
Definition PdfDeclarations.h:136