7 #ifndef PDF_CHAR_CODE_MAP_H
8 #define PDF_CHAR_CODE_MAP_H
11 #include "PdfEncodingCommon.h"
37 void CopyTo(std::vector<codepoint>& codePoints)
const;
38 codepointview view()
const;
39 unsigned GetSize()
const;
41 operator codepointview()
const;
55 std::array<codepoint, 3> Data;
61 std::unique_ptr<codepoint[]> Data;
68 using CodeUnitMap = std::unordered_map<PdfCharCode, CodePointSpan>;
70 struct PODOFO_API CodeUnitRange final
79 struct PODOFO_API CodeUnitRangeInequality
81 using is_transparent = std::true_type;
83 bool operator()(
const CodeUnitRange& lhs,
const PdfCharCode& rhs)
const
85 return lhs.SrcCodeLo < rhs;
87 bool operator()(
const PdfCharCode& lhs,
const CodeUnitRange& rhs)
const
89 return lhs < rhs.SrcCodeLo;
91 bool operator()(
const CodeUnitRange& lhs,
const CodeUnitRange& rhs)
const
93 return lhs.SrcCodeLo < rhs.SrcCodeLo;
97 using CodeUnitRanges = std::set<CodeUnitRange, CodeUnitRangeInequality>;
110 PODOFO_PRIVATE_FRIEND(
class PdfCMapEncodingFactory);
120 PdfCharCodeMap(CodeUnitMap&& mapping, CodeUnitRanges&& ranges,
const PdfEncodingLimits& limits);
127 void PushMapping(
const PdfCharCode& codeUnit,
const codepointview& codePoints);
143 void PushRange(
const PdfCharCode& srcCodeLo,
unsigned size,
const codepointview& dstCodeLo);
153 bool TryGetNextCharCode(std::string_view::iterator& it,
154 const std::string_view::iterator& end,
PdfCharCode& code)
const;
159 bool TryGetCharCode(
const codepointview& codePoints,
PdfCharCode& code)
const;
167 const PdfEncodingLimits& GetLimits()
const {
return m_Limits; }
169 bool IsEmpty()
const;
173 bool IsTrivialIdentity()
const;
177 std::vector<unsigned char> GetCodeRangeSizes()
const;
186 const CodeUnitRanges&
GetRanges()
const {
return m_Ranges; }
190 void pushMapping(
const PdfCharCode& codeUnit,
const codepointview& codePoints);
193 struct CodePointMapNode
197 CodePointMapNode* Ligatures;
198 CodePointMapNode* Left;
199 CodePointMapNode* Right;
203 PdfCharCodeMap(
const PdfCharCodeMap&) =
delete;
204 PdfCharCodeMap& operator=(
const PdfCharCodeMap&) =
delete;
207 void updateLimits(
const PdfCharCode& codeUnit);
208 void reviseCodePointMap();
209 bool tryFixNextRanges(
const CodeUnitRanges::iterator& it,
unsigned prevRangeCodeUpper);
210 static bool tryFindNextCharacterId(
const CodePointMapNode* node, std::string_view::iterator &it,
211 const std::string_view::iterator& end, PdfCharCode& cid);
212 static const CodePointMapNode* findNode(
const CodePointMapNode* node,
codepoint codePoint);
213 static void deleteNode(CodePointMapNode* node);
214 static CodePointMapNode* findOrAddNode(CodePointMapNode*& node,
codepoint codePoint);
217 PdfEncodingLimits m_Limits;
218 CodeUnitMap m_Mappings;
219 CodeUnitRanges m_Ranges;
221 CodePointMapNode* m_codePointMapHead;
SPDX-FileCopyrightText: (C) 2005 Dominik Seichter domseichter@web.de SPDX-FileCopyrightText: (C) 2020...
A memory owning immutable block of code points, optimized for small segments as up to 3 elements can ...
Definition: PdfCharCodeMap.h:29
A bidirectional map from character code units to unspecified code points.
Definition: PdfCharCodeMap.h:109
const CodeUnitMap & GetMappings() const
Provides direct mappings.
Definition: PdfCharCodeMap.h:182
const CodeUnitRanges & GetRanges() const
Provides range mappings.
Definition: PdfCharCodeMap.h:186
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition: basetypes.h:16
char32_t codepoint
A convenient typedef for an unspecified codepoint The underlying type is convenientely char32_t so it...
Definition: PdfCharCodeMap.h:21
tcb::span< const T, Extent > cspan
Constant span.
Definition: span.h:13
A character code unit.
Definition: PdfEncodingCommon.h:20