filters
UnicodeMap.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef UNICODEMAP_H
00012 #define UNICODEMAP_H
00013
00014 #include <aconf.h>
00015
00016 #ifdef USE_GCC_PRAGMAS
00017 #pragma interface
00018 #endif
00019
00020 #include "gtypes.h"
00021 #include "CharTypes.h"
00022
00023 class GString;
00024
00025
00026
00027 enum UnicodeMapKind {
00028 unicodeMapUser,
00029 unicodeMapResident,
00030 unicodeMapFunc
00031 };
00032
00033 typedef int (*UnicodeMapFunc)(Unicode u, char *buf, int bufSize);
00034
00035 struct UnicodeMapRange {
00036 Unicode start, end;
00037 Guint code, nBytes;
00038 };
00039
00040 struct UnicodeMapExt;
00041
00042
00043
00044 class UnicodeMap {
00045 public:
00046
00047
00048
00049 static UnicodeMap *parse(GString *encodingNameA);
00050
00051
00052 UnicodeMap(const char *encodingNameA, GBool unicodeOutA,
00053 UnicodeMapRange *rangesA, int lenA);
00054
00055
00056
00057 UnicodeMap(const char *encodingNameA, GBool unicodeOutA,
00058 UnicodeMapFunc funcA);
00059
00060 ~UnicodeMap();
00061
00062 void incRefCnt();
00063 void decRefCnt();
00064
00065 GString *getEncodingName() { return encodingName; }
00066
00067 GBool isUnicode() { return unicodeOut; }
00068
00069
00070
00071 GBool match(GString *encodingNameA);
00072
00073
00074
00075
00076
00077 int mapUnicode(Unicode u, char *buf, int bufSize);
00078
00079 private:
00080
00081 UnicodeMap(GString *encodingNameA);
00082
00083 GString *encodingName;
00084 UnicodeMapKind kind;
00085 GBool unicodeOut;
00086 union {
00087 UnicodeMapRange *ranges;
00088 UnicodeMapFunc func;
00089 };
00090 int len;
00091 UnicodeMapExt *eMaps;
00092 int eMapsLen;
00093 int refCnt;
00094 };
00095
00096
00097
00098 #define unicodeMapCacheSize 4
00099
00100 class UnicodeMapCache {
00101 public:
00102
00103 UnicodeMapCache();
00104 ~UnicodeMapCache();
00105
00106
00107
00108
00109 UnicodeMap *getUnicodeMap(GString *encodingName);
00110
00111 private:
00112
00113 UnicodeMap *cache[unicodeMapCacheSize];
00114 };
00115
00116 #endif
|