10 #include "PdfBaseDataTypes.h"
25 friend PdfName PODOFO_API
operator""_n(
const char*,
size_t);
40 template<std::
size_t N>
44 initFromUtf8String(str, N - 1);
47 template<
typename T,
typename = std::enable_if_t<std::is_same_v<T, const
char*>>>
51 initFromUtf8String(str, std::char_traits<char>::length(str));
62 PdfName(
const std::string& str);
79 static PdfName FromEscaped(
const std::string_view& name);
87 std::string GetEscapedName()
const;
90 const PdfStatefulEncrypt* encrypt,
charbuff& buffer)
const;
95 std::string_view GetString()
const;
103 std::string_view GetRawData()
const;
114 bool operator==(
const PdfName& rhs)
const;
115 bool operator==(
const char* str)
const;
116 bool operator==(
const std::string& str)
const;
117 bool operator==(
const std::string_view& view)
const;
122 bool operator!=(
const PdfName& rhs)
const;
123 bool operator!=(
const char* str)
const;
124 bool operator!=(
const std::string& str)
const;
125 bool operator!=(
const std::string_view& view)
const;
131 operator std::string_view()
const;
135 PdfName(
const char* str,
size_t length);
138 PdfName(std::nullptr_t) =
delete;
140 void expandUtf8String();
141 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;
167 inline PdfName operator""_n(
const char* name,
size_t length)
175 struct PODOFO_API PdfNameInequality
177 using is_transparent = std::true_type;
183 bool operator()(
const PdfName& lhs,
const std::string_view& rhs)
const
185 return lhs.GetRawData() < rhs;
187 bool operator()(
const std::string_view& lhs,
const PdfName& rhs)
const
189 return lhs < rhs.GetRawData();
193 struct PODOFO_API PdfNameHashing
195 using is_transparent = std::true_type;
197 inline std::size_t operator()(
const std::string_view& name)
const
199 return std::hash<std::string_view>()(name);
201 inline std::size_t operator()(
const PdfName& name)
const
203 return std::hash<std::string_view>()(name);
207 struct PODOFO_API PdfNameEquality
209 using is_transparent = std::true_type;
211 inline bool operator()(
const PdfName& lhs,
const PdfName& rhs)
const
213 return lhs.GetRawData() == rhs.GetRawData();
215 inline bool operator()(
const PdfName& lhs,
const std::string_view& rhs)
const
217 return lhs.GetRawData() == rhs;
219 inline bool operator()(
const std::string_view& lhs,
const PdfName& rhs)
const
221 return lhs == rhs.GetRawData();
225 template<
typename TValue>
226 using PdfNameMap = std::map<PdfName, TValue, PdfNameInequality>;
228 template<
typename TValue>
229 using PdfNameHashMap = std::unordered_map<PdfName, TValue, PdfNameHashing, PdfNameEquality>;
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
This class represents a PdfName.
Definition: PdfName.h:24
PdfName(const std::string_view &str)
Create a new PdfName object.
static const PdfName Null
Null name, corresponds to "/".
Definition: PdfName.h:30
std::string_view GetRawData() const
Definition: PdfName.cpp:327
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
PdfDataType
Every PDF datatype that can occur in a PDF file is referenced by an own enum (e.g.
Definition: PdfDeclarations.h:155
@ Name
Name datatype. Names are used as keys in dictionary to reference values.
PdfWriteFlags
Specify additional options for writing the PDF.
Definition: PdfDeclarations.h:137
cspan< char > bufferview
Convenient read-only char buffer span.
Definition: basetypes.h:19