9#include "PdfBaseDataTypes.h"
21class PODOFO_API
PdfName final :
private PdfDataMember,
public PdfDataProvider<PdfName>
34 template<std::
size_t N>
38 initFromUtf8String(str, N - 1);
42 template<std::
size_t N>
46 initFromUtf8String(str, (
size_t)(std::find(str, str + N,
'\0') - str));
49 template<
typename T,
typename = std::enable_if_t<std::is_same_v<T, const
char*>>>
53 initFromUtf8String(str, std::char_traits<char>::length(str));
63 PdfName(
const std::string& str);
70 PdfName(
const char& str,
size_t length);
94 const PdfStatefulEncrypt* encrypt, charbuff& buffer)
const;
115 bool operator==(
const std::string& str)
const;
116 bool operator==(
const std::string_view& view)
const;
122 bool operator!=(
const std::string& str)
const;
123 bool operator!=(
const std::string_view& view)
const;
128 operator std::string_view()
const;
132 PdfName(std::nullptr_t) =
delete;
134 void expandUtf8String();
138 void initFromUtf8String(
const char* str,
size_t length);
142 void initFromUtf8String(
const std::string_view& view);
151 std::unique_ptr<std::string> Utf8String;
155 bool m_dataAllocated;
158 std::shared_ptr<NameData> m_data;
159 std::string_view m_Utf8View;
166inline PdfName operator""_n(
const char* name,
size_t length)
174struct PODOFO_API PdfNameInequality
176 using is_transparent = std::true_type;
178 bool operator()(
const PdfName& lhs,
const PdfName& rhs)
const
180 return lhs.GetRawData() < rhs.GetRawData();
182 bool operator()(
const PdfName& lhs,
const std::string_view& rhs)
const
184 return lhs.GetRawData() < rhs;
186 bool operator()(
const std::string_view& lhs,
const PdfName& rhs)
const
188 return lhs < rhs.GetRawData();
192struct PODOFO_API PdfNameHashing
194 using is_transparent = std::true_type;
196 inline std::size_t operator()(
const std::string_view& name)
const
198 return std::hash<std::string_view>()(name);
200 inline std::size_t operator()(
const PdfName& name)
const
202 return std::hash<std::string_view>()(name);
206struct PODOFO_API PdfNameEquality
208 using is_transparent = std::true_type;
210 inline bool operator()(
const PdfName& lhs,
const PdfName& rhs)
const
212 return lhs.GetRawData() == rhs.GetRawData();
214 inline bool operator()(
const PdfName& lhs,
const std::string_view& rhs)
const
216 return lhs.GetRawData() == rhs;
218 inline bool operator()(
const std::string_view& lhs,
const PdfName& rhs)
const
220 return lhs == rhs.GetRawData();
224template<
typename TValue>
225using PdfNameMap = std::map<PdfName, TValue, PdfNameInequality>;
227template<
typename TValue>
228using 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
This class represents a PdfName.
Definition PdfName.h:22
PdfName(const std::string_view &str)
Create a new PdfName object.
bool operator==(const PdfName &rhs) const
compare to PdfName objects.
Definition PdfName.cpp:336
PdfName()
Constructor to create null name (corresponds to "/") use PdfName::Null instead of this constructor.
Definition PdfName.cpp:25
static const PdfName Null
Null name, corresponds to "/".
Definition PdfName.h:25
std::string_view GetString() const
Definition PdfName.cpp:306
static PdfName FromEscaped(const std::string_view &name)
Create a new PdfName object from a string containing an escaped name string without the leading / .
Definition PdfName.cpp:153
bool operator!=(const PdfName &rhs) const
compare two PdfName objects.
Definition PdfName.cpp:341
bool IsNull() const
Definition PdfName.cpp:323
PdfName(char(&str)[N])
Construct a new PdfName from a character buffer, up to its NUL termination or its size.
Definition PdfName.h:43
std::string_view GetRawData() const
Definition PdfName.cpp:328
PdfName & operator=(const PdfName &rhs)
Assign another name to this object.
Definition PdfName.cpp:81
std::string GetEscapedName() const
Definition PdfName.cpp:192
All classes, functions, types and enums of PoDoFo are members of these namespace.
Definition basetypes.h:13
cspan< char > bufferview
Convenient read-only char buffer span.
Definition basetypes.h:15
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.
Definition PdfDeclarations.h:158
PdfWriteFlags
Specify additional options for writing the PDF.
Definition PdfDeclarations.h:136