tokenhash.h
Go to the documentation of this file.
00001 /* C++ code produced by gperf version 3.0.4 */
00002 /* Command-line: /usr/bin/gperf --compare-strncmp -C -m 20 ../../src/lib/tokens.gperf  */
00003 /* Computed positions: -k'1-2' */
00004 
00005 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
00006       && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
00007       && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
00008       && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
00009       && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
00010       && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
00011       && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
00012       && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
00013       && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
00014       && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
00015       && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
00016       && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
00017       && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
00018       && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
00019       && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
00020       && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
00021       && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
00022       && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
00023       && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
00024       && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
00025       && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
00026       && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
00027       && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
00028 /* The character set is not based on ISO-646.  */
00029 #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
00030 #endif
00031 
00032 #line 5 "../../src/lib/tokens.gperf"
00033 struct xmltoken
00034 {
00035   const char *name;
00036   int tokenId;
00037 };
00038 
00039 #define TOTAL_KEYWORDS 33
00040 #define MIN_WORD_LENGTH 1
00041 #define MAX_WORD_LENGTH 12
00042 #define MIN_HASH_VALUE 1
00043 #define MAX_HASH_VALUE 33
00044 /* maximum key range = 33, duplicates = 0 */
00045 
00046 class Perfect_Hash
00047 {
00048 private:
00049   static inline unsigned int hash (const char *str, unsigned int len);
00050 public:
00051   static const struct xmltoken *in_word_set (const char *str, unsigned int len);
00052 };
00053 
00054 inline unsigned int
00055 Perfect_Hash::hash (register const char *str, register unsigned int len)
00056 {
00057   static const unsigned char asso_values[] =
00058     {
00059       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00060       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00061       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00062       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00063       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00064       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00065       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00066       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00067       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00068       34, 34, 34, 34, 34, 34, 34,  1,  0, 14,
00069       27,  3,  5, 21, 23,  0, 34, 34, 26,  8,
00070       19, 17,  2, 34,  2,  6, 12, 34, 12, 18,
00071       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00072       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00073       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00074       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00075       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00076       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00077       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00078       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00079       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00080       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00081       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00082       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00083       34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
00084       34, 34, 34, 34, 34, 34
00085     };
00086   register int hval = len;
00087 
00088   switch (hval)
00089     {
00090       default:
00091         hval += asso_values[(unsigned char)str[1]];
00092       /*FALLTHROUGH*/
00093       case 1:
00094         hval += asso_values[(unsigned char)str[0]];
00095         break;
00096     }
00097   return hval;
00098 }
00099 
00100 static const struct xmltoken wordlist[] =
00101   {
00102     {(char*)0, 0},
00103 #line 27 "../../src/lib/tokens.gperf"
00104     {"i",XML_I},
00105 #line 11 "../../src/lib/tokens.gperf"
00106     {"a",XML_A},
00107 #line 35 "../../src/lib/tokens.gperf"
00108     {"p",XML_P},
00109 #line 15 "../../src/lib/tokens.gperf"
00110     {"br",XML_BR},
00111 #line 37 "../../src/lib/tokens.gperf"
00112     {"pbr",XML_PBR},
00113 #line 22 "../../src/lib/tokens.gperf"
00114     {"f",XML_F},
00115 #line 39 "../../src/lib/tokens.gperf"
00116     {"s",XML_S},
00117 #line 12 "../../src/lib/tokens.gperf"
00118     {"abiword",XML_ABIWORD},
00119 #line 33 "../../src/lib/tokens.gperf"
00120     {"m",XML_M},
00121 #line 23 "../../src/lib/tokens.gperf"
00122     {"field",XML_FIELD},
00123 #line 36 "../../src/lib/tokens.gperf"
00124     {"pagesize",XML_PAGESIZE},
00125 #line 25 "../../src/lib/tokens.gperf"
00126     {"frame",XML_FRAME},
00127 #line 29 "../../src/lib/tokens.gperf"
00128     {"image",XML_IMAGE},
00129 #line 38 "../../src/lib/tokens.gperf"
00130     {"revisions",XML_REVISIONS},
00131 #line 16 "../../src/lib/tokens.gperf"
00132     {"c",XML_C},
00133 #line 40 "../../src/lib/tokens.gperf"
00134     {"section",XML_SECTION},
00135 #line 17 "../../src/lib/tokens.gperf"
00136     {"cbr",XML_CBR},
00137 #line 42 "../../src/lib/tokens.gperf"
00138     {"table",XML_TABLE},
00139 #line 34 "../../src/lib/tokens.gperf"
00140     {"metadata",XML_METADATA},
00141 #line 30 "../../src/lib/tokens.gperf"
00142     {"iw",XML_IW},
00143 #line 18 "../../src/lib/tokens.gperf"
00144     {"cell",XML_CELL},
00145 #line 43 "../../src/lib/tokens.gperf"
00146     {"version",XML_VERSION},
00147 #line 13 "../../src/lib/tokens.gperf"
00148     {"awml",XML_AWML},
00149 #line 41 "../../src/lib/tokens.gperf"
00150     {"styles",XML_STYLES},
00151 #line 14 "../../src/lib/tokens.gperf"
00152     {"bookmark",XML_BOOKMARK},
00153 #line 24 "../../src/lib/tokens.gperf"
00154     {"foot",XML_FOOT},
00155 #line 31 "../../src/lib/tokens.gperf"
00156     {"l",XML_L},
00157 #line 19 "../../src/lib/tokens.gperf"
00158     {"d",XML_D},
00159 #line 21 "../../src/lib/tokens.gperf"
00160     {"endnote",XML_ENDNOTE},
00161 #line 26 "../../src/lib/tokens.gperf"
00162     {"history",XML_HISTORY},
00163 #line 32 "../../src/lib/tokens.gperf"
00164     {"lists",XML_LISTS},
00165 #line 20 "../../src/lib/tokens.gperf"
00166     {"data",XML_DATA},
00167 #line 28 "../../src/lib/tokens.gperf"
00168     {"ignoredwords",XML_IGNOREDWORDS}
00169   };
00170 
00171 const struct xmltoken *
00172 Perfect_Hash::in_word_set (register const char *str, register unsigned int len)
00173 {
00174   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
00175     {
00176       register int key = hash (str, len);
00177 
00178       if (key <= MAX_HASH_VALUE && key >= 0)
00179         {
00180           register const char *s = wordlist[key].name;
00181 
00182           if (s && *str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
00183             return &wordlist[key];
00184         }
00185     }
00186   return 0;
00187 }
00188 #line 44 "../../src/lib/tokens.gperf"
00189