File indexing completed on 2025-12-10 10:23:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #ifndef CHARCODETOUNICODE_H
0032 #define CHARCODETOUNICODE_H
0033
0034 #include <atomic>
0035 #include <optional>
0036
0037 #include "poppler-config.h"
0038 #include "CharTypes.h"
0039
0040 struct CharCodeToUnicodeString;
0041 class GooString;
0042
0043
0044
0045 class CharCodeToUnicode
0046 {
0047 friend class UnicodeToCharCode;
0048
0049 public:
0050
0051 static CharCodeToUnicode *makeIdentityMapping();
0052
0053
0054
0055
0056 static CharCodeToUnicode *parseCIDToUnicode(const char *fileName, const GooString *collection);
0057
0058
0059
0060
0061 static CharCodeToUnicode *parseUnicodeToUnicode(const GooString *fileName);
0062
0063
0064
0065
0066 static CharCodeToUnicode *make8BitToUnicode(Unicode *toUnicode);
0067
0068
0069 static CharCodeToUnicode *parseCMap(const GooString *buf, int nBits);
0070 static CharCodeToUnicode *parseCMapFromFile(const GooString *fileName, int nBits);
0071
0072
0073
0074 void mergeCMap(const GooString *buf, int nBits);
0075
0076 ~CharCodeToUnicode();
0077
0078 CharCodeToUnicode(const CharCodeToUnicode &) = delete;
0079 CharCodeToUnicode &operator=(const CharCodeToUnicode &) = delete;
0080
0081 void incRefCnt();
0082 void decRefCnt();
0083
0084
0085 bool match(const GooString *tagA);
0086
0087
0088 void setMapping(CharCode c, Unicode *u, int len);
0089
0090
0091
0092
0093 int mapToUnicode(CharCode c, Unicode const **u) const;
0094
0095
0096 int mapToCharCode(const Unicode *u, CharCode *c, int usize) const;
0097
0098
0099
0100 CharCode getLength() const { return mapLen; }
0101
0102 private:
0103 bool parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);
0104 void addMapping(CharCode code, char *uStr, int n, int offset);
0105 void addMappingInt(CharCode code, Unicode u);
0106 CharCodeToUnicode();
0107 explicit CharCodeToUnicode(const std::optional<std::string> &tagA);
0108 CharCodeToUnicode(const std::optional<std::string> &tagA, Unicode *mapA, CharCode mapLenA, bool copyMap, CharCodeToUnicodeString *sMapA, int sMapLenA, int sMapSizeA);
0109
0110 const std::optional<std::string> tag;
0111 Unicode *map;
0112 CharCode mapLen;
0113 CharCodeToUnicodeString *sMap;
0114 int sMapLen, sMapSize;
0115 std::atomic_int refCnt;
0116 bool isIdentity;
0117 };
0118
0119
0120
0121 class CharCodeToUnicodeCache
0122 {
0123 public:
0124 explicit CharCodeToUnicodeCache(int sizeA);
0125 ~CharCodeToUnicodeCache();
0126
0127 CharCodeToUnicodeCache(const CharCodeToUnicodeCache &) = delete;
0128 CharCodeToUnicodeCache &operator=(const CharCodeToUnicodeCache &) = delete;
0129
0130
0131
0132
0133 CharCodeToUnicode *getCharCodeToUnicode(const GooString *tag);
0134
0135
0136 void add(CharCodeToUnicode *ctu);
0137
0138 private:
0139 CharCodeToUnicode **cache;
0140 int size;
0141 };
0142
0143 #endif