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 #ifndef CMAP_H
0027 #define CMAP_H
0028
0029 #include <array>
0030 #include <atomic>
0031 #include <memory>
0032
0033 #include "poppler-config.h"
0034 #include "CharTypes.h"
0035
0036 class GooString;
0037 class Object;
0038 struct CMapVectorEntry;
0039 class CMapCache;
0040 class Stream;
0041
0042
0043
0044 class CMap
0045 {
0046 public:
0047
0048
0049 static std::shared_ptr<CMap> parse(CMapCache *cache, const GooString *collectionA, Object *obj);
0050
0051
0052
0053 static std::shared_ptr<CMap> parse(CMapCache *cache, const GooString *collectionA, const GooString *cMapNameA);
0054
0055
0056
0057 static std::shared_ptr<CMap> parse(CMapCache *cache, const GooString *collectionA, Stream *str);
0058
0059 ~CMap();
0060
0061 CMap(const CMap &) = delete;
0062 CMap &operator=(const CMap &) = delete;
0063
0064
0065 const GooString *getCollection() const { return collection; }
0066
0067 const GooString *getCMapName() const { return cMapName; }
0068
0069
0070
0071 bool match(const GooString *collectionA, const GooString *cMapNameA);
0072
0073
0074
0075
0076 CID getCID(const char *s, int len, CharCode *c, int *nUsed);
0077
0078
0079 int getWMode() const { return wMode; }
0080
0081 void setReverseMap(unsigned int *rmap, unsigned int rmapSize, unsigned int ncand);
0082
0083 private:
0084 void parse2(CMapCache *cache, int (*getCharFunc)(void *), void *data);
0085 CMap(GooString *collectionA, GooString *cMapNameA);
0086 CMap(GooString *collectionA, GooString *cMapNameA, int wModeA);
0087 void useCMap(CMapCache *cache, const char *useName);
0088 void useCMap(CMapCache *cache, Object *obj);
0089 void copyVector(CMapVectorEntry *dest, CMapVectorEntry *src);
0090 void addCIDs(unsigned int start, unsigned int end, unsigned int nBytes, CID firstCID);
0091 void freeCMapVector(CMapVectorEntry *vec);
0092 void setReverseMapVector(unsigned int startCode, CMapVectorEntry *vec, unsigned int *rmap, unsigned int rmapSize, unsigned int ncand);
0093
0094 GooString *collection;
0095 GooString *cMapName;
0096 bool isIdent;
0097
0098 int wMode;
0099 CMapVectorEntry *vector;
0100
0101 };
0102
0103
0104
0105 #define cMapCacheSize 4
0106
0107 class CMapCache
0108 {
0109 public:
0110 CMapCache();
0111 ~CMapCache() = default;
0112
0113 CMapCache(const CMapCache &) = delete;
0114 CMapCache &operator=(const CMapCache &) = delete;
0115
0116
0117
0118
0119
0120
0121
0122 std::shared_ptr<CMap> getCMap(const GooString *collection, const GooString *cMapName);
0123
0124 private:
0125 std::array<std::shared_ptr<CMap>, cMapCacheSize> cache;
0126 };
0127
0128 #endif