Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CMap.h

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

Generated on Sat Nov 5 16:18:13 2005 for OPIE by  doxygen 1.4.2