PoDoFo  1.0.0-dev
PdfEncodingCommon.h
1 
7 #ifndef PDF_ENCODING_COMMON_H
8 #define PDF_ENCODING_COMMON_H
9 
10 #include "PdfDeclarations.h"
11 
12 namespace PoDoFo
13 {
19  struct PODOFO_API PdfCharCode final
20  {
21  unsigned Code;
22 
23  // RangeSize example <cd> -> 1, <00cd> -> 2
24  unsigned char CodeSpaceSize;
25 
26  PdfCharCode();
27 
30  explicit PdfCharCode(unsigned code);
31 
32  PdfCharCode(unsigned code, unsigned char codeSpaceSize);
33 
34  bool operator<(const PdfCharCode& rhs) const;
35 
36  bool operator==(const PdfCharCode& rhs) const;
37 
38  bool operator!=(const PdfCharCode& rhs) const;
39 
40  public:
41  void AppendTo(std::string& str) const;
42  void WriteHexTo(std::string& str, bool wrap = true) const;
43  };
44 
47  struct PODOFO_API PdfCID final
48  {
49  unsigned Id;
50  PdfCharCode Unit;
51 
52  PdfCID();
53 
57  explicit PdfCID(unsigned id);
58 
59  PdfCID(unsigned id, const PdfCharCode& unit);
60 
64  PdfCID(const PdfCharCode& unit);
65  };
66 
67  struct PODOFO_API PdfEncodingLimits final
68  {
69  public:
70  PdfEncodingLimits(unsigned char minCodeSize, unsigned char maxCodeSize,
71  const PdfCharCode& firstCharCode, const PdfCharCode& lastCharCode);
72 
75  PdfEncodingLimits();
76 
80  bool AreValid() const;
81 
85  bool HaveValidCodeSizeRange() const;
86 
87  PdfCharCode FirstChar; // The first defined character code
88  PdfCharCode LastChar; // The last defined character code
89  unsigned char MinCodeSize;
90  unsigned char MaxCodeSize;
91  };
92 }
93 
94 namespace std
95 {
98  template<>
99  struct hash<PoDoFo::PdfCharCode>
100  {
101  size_t operator()(const PoDoFo::PdfCharCode& code) const noexcept
102  {
103  return code.CodeSpaceSize << 24 | code.Code;
104  }
105  };
106 }
107 
108 #endif // PDF_ENCODING_COMMON_H
SPDX-FileCopyrightText: (C) 2005 Dominik Seichter domseichter@web.de SPDX-FileCopyrightText: (C) 2020...
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition: basetypes.h:16
Represent a CID (Character ID) with full code unit information.
Definition: PdfEncodingCommon.h:48
A character code unit.
Definition: PdfEncodingCommon.h:20