tokenhash.h
Go to the documentation of this file.
1 /* C++ code produced by gperf version 3.1 */
2 /* Command-line: gperf --compare-strncmp -C -m 20 tokens.gperf */
3 /* Computed positions: -k'1-2' */
4 
5 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
6  && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
7  && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
8  && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
9  && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
10  && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
11  && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
12  && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
13  && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
14  && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
15  && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
16  && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
17  && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
18  && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
19  && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
20  && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
21  && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
22  && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
23  && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
24  && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
25  && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
26  && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
27  && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
28 /* The character set is not based on ISO-646. */
29 #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
30 #endif
31 
32 #line 5 "tokens.gperf"
33 struct xmltoken
34 {
35  const char *name;
36  int tokenId;
37 };
38 
39 #define TOTAL_KEYWORDS 33
40 #define MIN_WORD_LENGTH 1
41 #define MAX_WORD_LENGTH 12
42 #define MIN_HASH_VALUE 1
43 #define MAX_HASH_VALUE 33
44 /* maximum key range = 33, duplicates = 0 */
45 
47 {
48 private:
49  static inline unsigned int hash (const char *str, size_t len);
50 public:
51  static const struct xmltoken *in_word_set (const char *str, size_t len);
52 };
53 
54 inline unsigned int
55 Perfect_Hash::hash (const char *str, size_t len)
56 {
57  static const unsigned char asso_values[] =
58  {
59  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
60  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
61  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
62  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
63  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
64  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
65  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
66  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
67  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
68  34, 34, 34, 34, 34, 34, 34, 1, 0, 14,
69  27, 3, 5, 21, 23, 0, 34, 34, 26, 8,
70  19, 17, 2, 34, 2, 6, 12, 34, 12, 18,
71  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
72  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
73  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
74  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
75  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
76  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
77  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
78  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
79  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
80  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
81  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
82  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
83  34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
84  34, 34, 34, 34, 34, 34
85  };
86  unsigned int hval = len;
87 
88  switch (hval)
89  {
90  default:
91  hval += asso_values[static_cast<unsigned char>(str[1])];
92 #if defined __cplusplus && (__cplusplus >= 201703L || (__cplusplus >= 201103L && defined __clang_major__ && defined __clang_minor__ && __clang_major__ + (__clang_minor__ >= 9) > 3))
93  [[fallthrough]];
94 #elif defined __GNUC__ && __GNUC__ >= 7
95  __attribute__ ((__fallthrough__));
96 #endif
97  /*FALLTHROUGH*/
98  case 1:
99  hval += asso_values[static_cast<unsigned char>(str[0])];
100  break;
101  }
102  return hval;
103 }
104 
105 static const struct xmltoken wordlist[] =
106  {
107  {(char*)0, 0},
108 #line 27 "tokens.gperf"
109  {"i",XML_I},
110 #line 11 "tokens.gperf"
111  {"a",XML_A},
112 #line 35 "tokens.gperf"
113  {"p",XML_P},
114 #line 15 "tokens.gperf"
115  {"br",XML_BR},
116 #line 37 "tokens.gperf"
117  {"pbr",XML_PBR},
118 #line 22 "tokens.gperf"
119  {"f",XML_F},
120 #line 39 "tokens.gperf"
121  {"s",XML_S},
122 #line 12 "tokens.gperf"
123  {"abiword",XML_ABIWORD},
124 #line 33 "tokens.gperf"
125  {"m",XML_M},
126 #line 23 "tokens.gperf"
127  {"field",XML_FIELD},
128 #line 36 "tokens.gperf"
129  {"pagesize",XML_PAGESIZE},
130 #line 25 "tokens.gperf"
131  {"frame",XML_FRAME},
132 #line 29 "tokens.gperf"
133  {"image",XML_IMAGE},
134 #line 38 "tokens.gperf"
135  {"revisions",XML_REVISIONS},
136 #line 16 "tokens.gperf"
137  {"c",XML_C},
138 #line 40 "tokens.gperf"
139  {"section",XML_SECTION},
140 #line 17 "tokens.gperf"
141  {"cbr",XML_CBR},
142 #line 42 "tokens.gperf"
143  {"table",XML_TABLE},
144 #line 34 "tokens.gperf"
145  {"metadata",XML_METADATA},
146 #line 30 "tokens.gperf"
147  {"iw",XML_IW},
148 #line 18 "tokens.gperf"
149  {"cell",XML_CELL},
150 #line 43 "tokens.gperf"
151  {"version",XML_VERSION},
152 #line 13 "tokens.gperf"
153  {"awml",XML_AWML},
154 #line 41 "tokens.gperf"
155  {"styles",XML_STYLES},
156 #line 14 "tokens.gperf"
157  {"bookmark",XML_BOOKMARK},
158 #line 24 "tokens.gperf"
159  {"foot",XML_FOOT},
160 #line 31 "tokens.gperf"
161  {"l",XML_L},
162 #line 19 "tokens.gperf"
163  {"d",XML_D},
164 #line 21 "tokens.gperf"
165  {"endnote",XML_ENDNOTE},
166 #line 26 "tokens.gperf"
167  {"history",XML_HISTORY},
168 #line 32 "tokens.gperf"
169  {"lists",XML_LISTS},
170 #line 20 "tokens.gperf"
171  {"data",XML_DATA},
172 #line 28 "tokens.gperf"
173  {"ignoredwords",XML_IGNOREDWORDS}
174  };
175 
176 const struct xmltoken *
177 Perfect_Hash::in_word_set (const char *str, size_t len)
178 {
179  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
180  {
181  unsigned int key = hash (str, len);
182 
183  if (key <= MAX_HASH_VALUE)
184  {
185  const char *s = wordlist[key].name;
186 
187  if (s && *str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
188  return &wordlist[key];
189  }
190  }
191  return 0;
192 }
193 #line 44 "tokens.gperf"
194 
XML_REVISIONS
const int XML_REVISIONS
Definition: tokens.h:31
Perfect_Hash::hash
static unsigned int hash(const char *str, size_t len)
Definition: tokenhash.h:55
XML_L
const int XML_L
Definition: tokens.h:24
XML_CBR
const int XML_CBR
Definition: tokens.h:10
XML_BR
const int XML_BR
Definition: tokens.h:8
XML_DATA
const int XML_DATA
Definition: tokens.h:13
Perfect_Hash::in_word_set
static const struct xmltoken * in_word_set(const char *str, size_t len)
Definition: tokenhash.h:177
XML_IW
const int XML_IW
Definition: tokens.h:23
MAX_HASH_VALUE
#define MAX_HASH_VALUE
Definition: tokenhash.h:43
XML_A
const int XML_A
Definition: tokens.h:4
XML_IMAGE
const int XML_IMAGE
Definition: tokens.h:22
XML_F
const int XML_F
Definition: tokens.h:15
XML_AWML
const int XML_AWML
Definition: tokens.h:6
XML_M
const int XML_M
Definition: tokens.h:26
XML_IGNOREDWORDS
const int XML_IGNOREDWORDS
Definition: tokens.h:21
XML_I
const int XML_I
Definition: tokens.h:20
XML_METADATA
const int XML_METADATA
Definition: tokens.h:27
XML_PAGESIZE
const int XML_PAGESIZE
Definition: tokens.h:29
wordlist
static const struct xmltoken wordlist[]
Definition: tokenhash.h:105
XML_TABLE
const int XML_TABLE
Definition: tokens.h:35
xmltoken::tokenId
int tokenId
Definition: tokenhash.h:36
XML_D
const int XML_D
Definition: tokens.h:12
xmltoken
Definition: tokenhash.h:33
XML_C
const int XML_C
Definition: tokens.h:9
MIN_WORD_LENGTH
#define MIN_WORD_LENGTH
Definition: tokenhash.h:40
XML_FRAME
const int XML_FRAME
Definition: tokens.h:18
XML_BOOKMARK
const int XML_BOOKMARK
Definition: tokens.h:7
XML_PBR
const int XML_PBR
Definition: tokens.h:30
XML_ENDNOTE
const int XML_ENDNOTE
Definition: tokens.h:14
XML_S
const int XML_S
Definition: tokens.h:32
XML_VERSION
const int XML_VERSION
Definition: tokens.h:36
XML_CELL
const int XML_CELL
Definition: tokens.h:11
Perfect_Hash
Definition: tokenhash.h:46
XML_FOOT
const int XML_FOOT
Definition: tokens.h:17
XML_HISTORY
const int XML_HISTORY
Definition: tokens.h:19
xmltoken::name
const char * name
Definition: tokenhash.h:35
XML_P
const int XML_P
Definition: tokens.h:28
XML_FIELD
const int XML_FIELD
Definition: tokens.h:16
XML_LISTS
const int XML_LISTS
Definition: tokens.h:25
XML_SECTION
const int XML_SECTION
Definition: tokens.h:33
XML_STYLES
const int XML_STYLES
Definition: tokens.h:34
XML_ABIWORD
const int XML_ABIWORD
Definition: tokens.h:5

Generated for libwpd by doxygen 1.8.17