10 #include "PdfBaseDataTypes.h"
34 template<std::
size_t N>
38 initFromUtf8String(str, N - 1,
true);
41 template<
typename T,
typename = std::enable_if_t<std::is_same_v<T, const
char*>>>
45 initFromUtf8String(str, std::char_traits<char>::length(str),
false);
80 static PdfString FromHexData(
const std::string_view& hexView,
const PdfStatefulEncrypt* encrypt = { });
90 inline bool IsHex()
const {
return m_isHex; }
103 bool IsStringEvaluated()
const;
115 std::string_view GetString()
const;
117 std::string_view GetRawData()
const;
120 const PdfStatefulEncrypt* encrypt,
charbuff& buffer)
const;
138 bool operator==(
const PdfString& rhs)
const;
139 bool operator==(
const char* str)
const;
140 bool operator==(
const std::string& str)
const;
141 bool operator==(
const std::string_view& view)
const;
147 bool operator!=(
const PdfString& rhs)
const;
148 bool operator!=(
const char* str)
const;
149 bool operator!=(
const std::string& str)
const;
150 bool operator!=(
const std::string_view& view)
const;
154 operator std::string_view()
const;
168 void initFromUtf8String(
const char* str,
size_t length,
bool literal);
169 void ensureCharsEvaluated()
const;
175 StringData(
charbuff&& buff,
bool stringEvaluated);
178 bool StringEvaluated;
182 bool m_dataAllocated;
186 std::string_view m_Utf8View;
187 std::shared_ptr<StringData> m_data;
194 struct PODOFO_API PdfStringInequality
196 using is_transparent = std::true_type;
198 inline bool operator()(
const PdfString& lhs,
const PdfString& rhs)
const
200 return lhs.GetString() < rhs.GetString();
202 inline bool operator()(
const PdfString& lhs,
const std::string_view& rhs)
const
204 return lhs.GetString() < rhs;
206 bool operator()(
const std::string_view& lhs,
const PdfString& rhs)
const
208 return lhs < rhs.GetString();
212 struct PODOFO_API PdfStringHashing
214 using is_transparent = std::true_type;
216 inline std::size_t operator()(
const std::string_view& str)
const
218 return std::hash<std::string_view>()(str);
220 inline std::size_t operator()(
const PdfString& str)
const
222 return std::hash<std::string_view>()(str);
226 struct PODOFO_API PdfStringEquality
228 using is_transparent = std::true_type;
230 inline bool operator()(
const PdfString& lhs,
const PdfString& rhs)
const
232 return lhs.GetString() == rhs.GetString();
234 inline bool operator()(
const PdfString& lhs,
const std::string_view& rhs)
const
236 return lhs.GetString() == rhs;
238 inline bool operator()(
const std::string_view& lhs,
const PdfString& rhs)
const
240 return lhs == rhs.GetString();
244 template<
typename TValue>
245 using PdfStringMap = std::map<PdfString, TValue, PdfStringInequality>;
247 template<
typename TValue>
248 using PdfStringHashMap = std::unordered_map<PdfString, TValue, PdfStringHashing, PdfStringEquality>;
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 string that can be written to a PDF document.
Definition: PdfString.h:24
bool IsHex() const
Check if this is a hex string.
Definition: PdfString.h:90
PdfString(const std::string_view &view)
Construct a new PdfString from a utf-8 string The input string will be copied.
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
@ String
String datatype in PDF file. Strings have the form (Hallo World!) in PDF files.
PdfStringCharset
Definition: PdfDeclarations.h:105
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