upgrade to xpdf 3.00.
[swftools.git] / pdf2swf / xpdf / CMap.h
blobeff2a819ad80571784a9357e91aad31db82b8394
1 //========================================================================
2 //
3 // CMap.h
4 //
5 // Copyright 2001-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
9 #ifndef CMAP_H
10 #define CMAP_H
12 #include <aconf.h>
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
18 #include "gtypes.h"
19 #include "CharTypes.h"
21 #if MULTITHREADED
22 #include "GMutex.h"
23 #endif
25 class GString;
26 struct CMapVectorEntry;
27 class CMapCache;
29 //------------------------------------------------------------------------
31 class CMap {
32 public:
34 // Create the CMap specified by <collection> and <cMapName>. Sets
35 // the initial reference count to 1. Returns NULL on failure.
36 static CMap *parse(CMapCache *cache, GString *collectionA,
37 GString *cMapNameA);
39 ~CMap();
41 void incRefCnt();
42 void decRefCnt();
44 // Return collection name (<registry>-<ordering>).
45 GString *getCollection() { return collection; }
47 // Return true if this CMap matches the specified <collectionA>, and
48 // <cMapNameA>.
49 GBool match(GString *collectionA, GString *cMapNameA);
51 // Return the CID corresponding to the character code starting at
52 // <s>, which contains <len> bytes. Sets *<nUsed> to the number of
53 // bytes used by the char code.
54 CID getCID(char *s, int len, int *nUsed);
56 // Return the writing mode (0=horizontal, 1=vertical).
57 int getWMode() { return wMode; }
59 private:
61 CMap(GString *collectionA, GString *cMapNameA);
62 CMap(GString *collectionA, GString *cMapNameA, int wModeA);
63 void useCMap(CMapCache *cache, char *useName);
64 void copyVector(CMapVectorEntry *dest, CMapVectorEntry *src);
65 void addCodeSpace(CMapVectorEntry *vec, Guint start, Guint end,
66 Guint nBytes);
67 void addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID);
68 void freeCMapVector(CMapVectorEntry *vec);
70 GString *collection;
71 GString *cMapName;
72 int wMode; // writing mode (0=horizontal, 1=vertical)
73 CMapVectorEntry *vector; // vector for first byte (NULL for
74 // identity CMap)
75 int refCnt;
76 #ifdef MULTITHREADED
77 GMutex mutex;
78 #endif
81 //------------------------------------------------------------------------
83 #define cMapCacheSize 4
85 class CMapCache {
86 public:
88 CMapCache();
89 ~CMapCache();
91 // Get the <cMapName> CMap for the specified character collection.
92 // Increments its reference count; there will be one reference for
93 // the cache plus one for the caller of this function. Returns NULL
94 // on failure.
95 CMap *getCMap(GString *collection, GString *cMapName);
97 private:
99 CMap *cache[cMapCacheSize];
102 #endif