PoDoFo  1.0.0-dev
PdfReference.h
1 
7 #ifndef PDF_REFERENCE_H
8 #define PDF_REFERENCE_H
9 
10 #include "PdfBaseDataTypes.h"
11 
12 namespace PoDoFo {
13 
14 class OutputStream;
15 
23 class PODOFO_API PdfReference final : private PdfDataMember, public PdfDataProvider<PdfReference>
24 {
25 public:
30  PdfReference();
31 
38  PdfReference(const uint32_t objectNo, const uint16_t generationNo);
39 
45  PdfReference(const PdfReference& rhs) = default;
46 
52  PdfReference& operator=(const PdfReference& rhs) = default;
53 
54  void Write(OutputStream& stream, PdfWriteFlags flags, const PdfStatefulEncrypt* encrypt, charbuff& buffer) const;
55 
60  bool operator==(const PdfReference& rhs) const;
61 
66  bool operator!=(const PdfReference& rhs) const;
67 
72  bool operator<(const PdfReference& rhs) const;
73 
83  bool IsIndirect() const;
84 
85 public:
89  inline void SetObjectNumber(uint32_t o) { m_ObjectNo = o; }
90 
94  inline uint32_t ObjectNumber() const { return m_ObjectNo; }
95 
99  inline void SetGenerationNumber(const uint16_t g) { m_GenerationNo = g; }
100 
104  inline uint16_t GenerationNumber() const { return m_GenerationNo; }
105 
106 private:
107  uint16_t m_GenerationNo;
108  uint32_t m_ObjectNo;
109 };
110 
111 };
112 
113 namespace std
114 {
117  template<>
118  struct hash<PoDoFo::PdfReference>
119  {
120  std::size_t operator()(const PoDoFo::PdfReference& ref) const noexcept
121  {
122  return ref.ObjectNumber() ^ (ref.GenerationNumber() << 16);
123  }
124  };
125 }
126 
127 #endif // PDF_REFERENCE_H
An interface for writing blocks of data to a data source.
Definition: OutputStream.h:18
A class to inherit for classes that are stored as union members in a PdfVariant.
Definition: PdfBaseDataTypes.h:21
An helper class to inherit to provide common serialization methods.
Definition: PdfBaseDataTypes.h:40
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
PdfReference & operator=(const PdfReference &rhs)=default
Assign the value of another object to this PdfReference.
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:89
void SetGenerationNumber(const uint16_t g)
Set the generation number of this object.
Definition: PdfReference.h:99
uint16_t GenerationNumber() const
Get the generation number.
Definition: PdfReference.h:104
uint32_t ObjectNumber() const
Get the object number.
Definition: PdfReference.h:94
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
PdfWriteFlags
Specify additional options for writing the PDF.
Definition: PdfDeclarations.h:137