8#include "PdfBaseDataTypes.h"
33 template<std::
size_t N>
37 initFromUtf8String(
str, N - 1);
40 template<
typename T,
typename = std::enable_if_t<std::is_same_v<T, const
char*>>>
44 initFromUtf8String(
str, std::char_traits<char>::length(
str));
75 static PdfName FromEscaped(
const std::string_view&
name);
82 std::string GetEscapedName()
const;
89 std::string_view GetString()
const;
95 std::string_view GetRawData()
const;
105 bool operator==(
const char*
str)
const;
106 bool operator==(
const std::string&
str)
const;
107 bool operator==(
const std::string_view& view)
const;
112 bool operator!=(
const char*
str)
const;
113 bool operator!=(
const std::string&
str)
const;
114 bool operator!=(
const std::string_view& view)
const;
119 operator std::string_view()
const;
123 PdfName(std::nullptr_t) =
delete;
125 void expandUtf8String();
129 void initFromUtf8String(
const char*
str,
size_t length);
133 void initFromUtf8String(
const std::string_view& view);
142 std::unique_ptr<std::string> Utf8String;
146 bool m_dataAllocated;
149 std::shared_ptr<NameData> m_data;
150 std::string_view m_Utf8View;
165struct PODOFO_API PdfNameInequality
167 using is_transparent = std::true_type;
169 bool operator()(
const PdfName& lhs,
const PdfName& rhs)
const
171 return lhs.GetRawData() < rhs.GetRawData();
173 bool operator()(
const PdfName& lhs,
const std::string_view& rhs)
const
175 return lhs.GetRawData() < rhs;
177 bool operator()(
const std::string_view& lhs,
const PdfName& rhs)
const
179 return lhs < rhs.GetRawData();
183struct PODOFO_API PdfNameHashing
185 using is_transparent = std::true_type;
187 inline std::size_t operator()(
const std::string_view& name)
const
189 return std::hash<std::string_view>()(name);
191 inline std::size_t operator()(
const PdfName& name)
const
193 return std::hash<std::string_view>()(name);
197struct PODOFO_API PdfNameEquality
199 using is_transparent = std::true_type;
201 inline bool operator()(
const PdfName& lhs,
const PdfName& rhs)
const
203 return lhs.GetRawData() == rhs.GetRawData();
205 inline bool operator()(
const PdfName& lhs,
const std::string_view& rhs)
const
207 return lhs.GetRawData() == rhs;
209 inline bool operator()(
const std::string_view& lhs,
const PdfName& rhs)
const
211 return lhs == rhs.GetRawData();
215template<
typename TValue>
216using PdfNameMap = std::map<PdfName, TValue, PdfNameInequality>;
218template<
typename TValue>
219using PdfNameHashMap = std::unordered_map<PdfName, TValue, PdfNameHashing, PdfNameEquality>;
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
This class represents a PdfName.
Definition PdfName.h:21
PdfName(const std::string_view &str)
Create a new PdfName object.
static const PdfName Null
Null name, corresponds to "/".
Definition PdfName.h:24
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
PdfDataType
Every PDF datatype that can occur in a PDF file is referenced by an own enum (e.g.
Definition PdfDeclarations.h:152
@ Name
Name datatype. Names are used as keys in dictionary to reference values.
PdfWriteFlags
Specify additional options for writing the PDF.
Definition PdfDeclarations.h:136
cspan< char > bufferview
Convenient read-only char buffer span.
Definition basetypes.h:15