filters

CMap.h

00001 //========================================================================
00002 //
00003 // CMap.h
00004 //
00005 // Copyright 2001-2002 Glyph & Cog, LLC
00006 //
00007 //========================================================================
00008 
00009 #ifndef CMAP_H
00010 #define CMAP_H
00011 
00012 #include <aconf.h>
00013 
00014 #ifdef USE_GCC_PRAGMAS
00015 #pragma interface
00016 #endif
00017 
00018 #include "gtypes.h"
00019 #include "CharTypes.h"
00020 
00021 class GString;
00022 struct CMapVectorEntry;
00023 class CMapCache;
00024 
00025 //------------------------------------------------------------------------
00026 
00027 class CMap {
00028 public:
00029 
00030   // Create the CMap specified by <collection> and <cMapName>.  Sets
00031   // the initial reference count to 1.  Returns NULL on failure.
00032   static CMap *parse(CMapCache *cache, GString *collectionA,
00033              GString *cMapNameA);
00034 
00035   ~CMap();
00036 
00037   void incRefCnt();
00038   void decRefCnt();
00039 
00040   // Return collection name (<registry>-<ordering>).
00041   GString *getCollection() { return collection; }
00042 
00043   // Return true if this CMap matches the specified <collectionA>, and
00044   // <cMapNameA>.
00045   GBool match(GString *collectionA, GString *cMapNameA);
00046 
00047   // Return the CID corresponding to the character code starting at
00048   // <s>, which contains <len> bytes.  Sets *<nUsed> to the number of
00049   // bytes used by the char code.
00050   CID getCID(char *s, int len, int *nUsed);
00051 
00052   // Return the writing mode (0=horizontal, 1=vertical).
00053   int getWMode() { return wMode; }
00054 
00055 private:
00056 
00057   CMap(GString *collectionA, GString *cMapNameA);
00058   CMap(GString *collectionA, GString *cMapNameA, int wModeA);
00059   void useCMap(CMapCache *cache, char *useName);
00060   void copyVector(CMapVectorEntry *dest, CMapVectorEntry *src);
00061   void addCodeSpace(CMapVectorEntry *vec, Guint start, Guint end,
00062             Guint nBytes);
00063   void addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID);
00064   void freeCMapVector(CMapVectorEntry *vec);
00065 
00066   GString *collection;
00067   GString *cMapName;
00068   int wMode;            // writing mode (0=horizontal, 1=vertical)
00069   CMapVectorEntry *vector;  // vector for first byte (NULL for
00070                 //   identity CMap)
00071   int refCnt;
00072 };
00073 
00074 //------------------------------------------------------------------------
00075 
00076 #define cMapCacheSize 4
00077 
00078 class CMapCache {
00079 public:
00080 
00081   CMapCache();
00082   ~CMapCache();
00083 
00084   // Get the <cMapName> CMap for the specified character collection.
00085   // Increments its reference count; there will be one reference for
00086   // the cache plus one for the caller of this function.  Returns NULL
00087   // on failure.
00088   CMap *getCMap(GString *collection, GString *cMapName);
00089 
00090 private:
00091 
00092   CMap *cache[cMapCacheSize];
00093 };
00094 
00095 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys