source: trunk/poppler/mypoppler/poppler/CMap.h @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 15 years ago

First import

File size: 2.6 KB
Line 
1//========================================================================
2//
3// CMap.h
4//
5// Copyright 2001-2003 Glyph & Cog, LLC
6//
7//========================================================================
8
9#ifndef CMAP_H
10#define CMAP_H
11
12#ifdef USE_GCC_PRAGMAS
13#pragma interface
14#endif
15
16#include "poppler-config.h"
17#include "goo/gtypes.h"
18#include "CharTypes.h"
19
20#if MULTITHREADED
21#include <goo/GooMutex.h>
22#endif
23
24class GooString;
25struct CMapVectorEntry;
26class CMapCache;
27
28//------------------------------------------------------------------------
29
30class CMap {
31public:
32
33  // Create the CMap specified by <collection> and <cMapName>.  Sets
34  // the initial reference count to 1.  Returns NULL on failure.
35  static CMap *parse(CMapCache *cache, GooString *collectionA,
36                     GooString *cMapNameA);
37
38  ~CMap();
39
40  void incRefCnt();
41  void decRefCnt();
42
43  // Return collection name (<registry>-<ordering>).
44  GooString *getCollection() { return collection; }
45
46  // Return true if this CMap matches the specified <collectionA>, and
47  // <cMapNameA>.
48  GBool match(GooString *collectionA, GooString *cMapNameA);
49
50  // Return the CID corresponding to the character code starting at
51  // <s>, which contains <len> bytes.  Sets *<nUsed> to the number of
52  // bytes used by the char code.
53  CID getCID(char *s, int len, int *nUsed);
54
55  // Return the writing mode (0=horizontal, 1=vertical).
56  int getWMode() { return wMode; }
57
58private:
59
60  CMap(GooString *collectionA, GooString *cMapNameA);
61  CMap(GooString *collectionA, GooString *cMapNameA, int wModeA);
62  void useCMap(CMapCache *cache, char *useName);
63  void copyVector(CMapVectorEntry *dest, CMapVectorEntry *src);
64  void addCodeSpace(CMapVectorEntry *vec, Guint start, Guint end,
65                    Guint nBytes);
66  void addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID);
67  void freeCMapVector(CMapVectorEntry *vec);
68
69  GooString *collection;
70  GooString *cMapName;
71  int wMode;                    // writing mode (0=horizontal, 1=vertical)
72  CMapVectorEntry *vector;      // vector for first byte (NULL for
73                                //   identity CMap)
74  int refCnt;
75#if MULTITHREADED
76  GooMutex mutex;
77#endif
78};
79
80//------------------------------------------------------------------------
81
82#define cMapCacheSize 4
83
84class CMapCache {
85public:
86
87  CMapCache();
88  ~CMapCache();
89
90  // Get the <cMapName> CMap for the specified character collection.
91  // Increments its reference count; there will be one reference for
92  // the cache plus one for the caller of this function.  Returns NULL
93  // on failure.
94  CMap *getCMap(GooString *collection, GooString *cMapName);
95
96private:
97
98  CMap *cache[cMapCacheSize];
99};
100
101#endif
Note: See TracBrowser for help on using the repository browser.