Qt 4.8
Static Public Functions | Static Private Functions | List of all members
QPatternist::TokenLookup Class Reference

Static Public Functions

static const struct TokenMapvalue (const char *str, unsigned int len)
 

Static Private Functions

static unsigned int hash (const char *str, unsigned int len)
 

Detailed Description

Definition at line 93 of file qtokenlookup.cpp.

Functions

◆ hash()

unsigned int QPatternist::TokenLookup::hash ( const char *  str,
unsigned int  len 
)
inlinestaticprivate

Definition at line 102 of file qtokenlookup.cpp.

103 {
104  static const unsigned char asso_values[] =
105  {
106  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
107  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
108  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
109  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
110  230, 230, 230, 230, 230, 25, 230, 230, 230, 230,
111  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
112  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
113  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
114  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
115  230, 230, 230, 230, 230, 230, 230, 0, 2, 5,
116  25, 0, 20, 20, 35, 85, 230, 230, 40, 110,
117  25, 65, 80, 0, 60, 5, 10, 0, 55, 5,
118  20, 0, 230, 230, 230, 230, 230, 230, 230, 230,
119  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
120  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
121  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
122  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
123  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
124  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
125  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
126  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
127  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
128  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
129  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
130  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
131  230, 230, 230, 230, 230, 230
132  };
133  register int hval = len;
134 
135  switch (hval)
136  {
137  default:
138  hval += asso_values[(unsigned char)str[2]];
139  /*FALLTHROUGH*/
140  case 2:
141  case 1:
142  hval += asso_values[(unsigned char)str[0]];
143  break;
144  }
145  return hval + asso_values[(unsigned char)str[len - 1]];
146 }

◆ value()

const struct TokenMap * QPatternist::TokenLookup::value ( const char *  str,
unsigned int  len 
)
static

Definition at line 149 of file qtokenlookup.cpp.

Referenced by QPatternist::XQueryTokenizer::lookupKeyword().

150 {
151  enum
152  {
153  TOTAL_KEYWORDS = 99,
154  MIN_WORD_LENGTH = 2,
155  MAX_WORD_LENGTH = 22,
156  MIN_HASH_VALUE = 2,
157  MAX_HASH_VALUE = 229
158  };
159 
160  static const struct TokenMap wordlist[] =
161  {
162  {"",ERROR}, {"",ERROR},
163 #line 152 "TokenLookup.gperf"
164  {"eq", EQ},
165  {"",ERROR},
166 #line 130 "TokenLookup.gperf"
167  {"by", BY},
168 #line 153 "TokenLookup.gperf"
169  {"every", EVERY},
170  {"",ERROR},
171 #line 123 "TokenLookup.gperf"
172  {"as", AS},
173  {"",ERROR},
174 #line 148 "TokenLookup.gperf"
175  {"else", ELSE},
176 #line 217 "TokenLookup.gperf"
177  {"where", WHERE},
178 #line 204 "TokenLookup.gperf"
179  {"stable", STABLE},
180 #line 126 "TokenLookup.gperf"
181  {"at", AT},
182  {"",ERROR},
183 #line 131 "TokenLookup.gperf"
184  {"case", CASE},
185  {"",ERROR},
186 #line 129 "TokenLookup.gperf"
187  {"boundary-space", BOUNDARY_SPACE},
188 #line 147 "TokenLookup.gperf"
189  {"element", ELEMENT},
190 #line 132 "TokenLookup.gperf"
191  {"castable", CASTABLE},
192 #line 127 "TokenLookup.gperf"
193  {"attribute", ATTRIBUTE},
194  {"",ERROR},
195 #line 154 "TokenLookup.gperf"
196  {"except", EXCEPT},
197 #line 161 "TokenLookup.gperf"
198  {"ge", GE},
199  {"",ERROR},
200 #line 133 "TokenLookup.gperf"
201  {"cast", CAST},
202 #line 210 "TokenLookup.gperf"
203  {"treat", TREAT},
204 #line 218 "TokenLookup.gperf"
205  {"xquery", XQUERY},
206 #line 181 "TokenLookup.gperf"
207  {"ne", NE},
208  {"",ERROR},
209 #line 198 "TokenLookup.gperf"
210  {"satisfies", SATISFIES},
211  {"",ERROR}, {"",ERROR},
212 #line 163 "TokenLookup.gperf"
213  {"gt", GT},
214 #line 151 "TokenLookup.gperf"
215  {"encoding", ENCODING},
216 #line 124 "TokenLookup.gperf"
217  {"ascending", ASCENDING},
218  {"",ERROR},
219 #line 125 "TokenLookup.gperf"
220  {"assign", ASSIGN},
221 #line 139 "TokenLookup.gperf"
222  {"declare", DECLARE},
223 #line 162 "TokenLookup.gperf"
224  {"greatest", GREATEST},
225 #line 208 "TokenLookup.gperf"
226  {"then", THEN},
227  {"",ERROR},
228 #line 121 "TokenLookup.gperf"
229  {"ancestor-or-self", ANCESTOR_OR_SELF},
230 #line 175 "TokenLookup.gperf"
231  {"le", LE},
232 #line 146 "TokenLookup.gperf"
233  {"document-node", DOCUMENT_NODE},
234 #line 207 "TokenLookup.gperf"
235  {"text", TEXT},
236  {"",ERROR},
237 #line 201 "TokenLookup.gperf"
238  {"schema", SCHEMA},
239  {"",ERROR},
240 #line 145 "TokenLookup.gperf"
241  {"document", DOCUMENT},
242  {"",ERROR},
243 #line 141 "TokenLookup.gperf"
244  {"descendant", DESCENDANT},
245  {"",ERROR},
246 #line 177 "TokenLookup.gperf"
247  {"lt", LT},
248 #line 122 "TokenLookup.gperf"
249  {"and", AND},
250 #line 182 "TokenLookup.gperf"
251  {"node", NODE},
252 #line 174 "TokenLookup.gperf"
253  {"least", LEAST},
254 #line 199 "TokenLookup.gperf"
255  {"schema-attribute", SCHEMA_ATTRIBUTE},
256  {"",ERROR},
257 #line 155 "TokenLookup.gperf"
258  {"external", EXTERNAL},
259  {"",ERROR},
260 #line 143 "TokenLookup.gperf"
261  {"descending", DESCENDING},
262 #line 184 "TokenLookup.gperf"
263  {"no-preserve", NO_PRESERVE},
264 #line 140 "TokenLookup.gperf"
265  {"default", DEFAULT},
266 #line 176 "TokenLookup.gperf"
267  {"let", LET},
268 #line 200 "TokenLookup.gperf"
269  {"schema-element", SCHEMA_ELEMENT},
270  {"",ERROR}, {"",ERROR},
271 #line 137 "TokenLookup.gperf"
272  {"construction", CONSTRUCTION},
273 #line 142 "TokenLookup.gperf"
274  {"descendant-or-self", DESCENDANT_OR_SELF},
275 #line 202 "TokenLookup.gperf"
276  {"self", SELF},
277 #line 183 "TokenLookup.gperf"
278  {"no-inherit", NO_INHERIT},
279  {"",ERROR},
280 #line 158 "TokenLookup.gperf"
281  {"follows", FOLLOWS},
282 #line 120 "TokenLookup.gperf"
283  {"ancestor", ANCESTOR},
284  {"",ERROR}, {"",ERROR}, {"",ERROR},
285 #line 209 "TokenLookup.gperf"
286  {"to", TO},
287 #line 160 "TokenLookup.gperf"
288  {"function", FUNCTION},
289 #line 135 "TokenLookup.gperf"
290  {"collation", COLLATION},
291  {"",ERROR},
292 #line 205 "TokenLookup.gperf"
293  {"strict", STRICT},
294  {"",ERROR},
295 #line 173 "TokenLookup.gperf"
296  {"lax", LAX},
297  {"",ERROR},
298 #line 149 "TokenLookup.gperf"
299  {"empty", EMPTY},
300  {"",ERROR},
301 #line 185 "TokenLookup.gperf"
302  {"of", OF},
303 #line 195 "TokenLookup.gperf"
304  {"preserve", PRESERVE},
305 #line 156 "TokenLookup.gperf"
306  {"following", FOLLOWING},
307  {"",ERROR}, {"",ERROR},
308 #line 171 "TokenLookup.gperf"
309  {"is", IS},
310 #line 192 "TokenLookup.gperf"
311  {"precedes", PRECEDES},
312 #line 150 "TokenLookup.gperf"
313  {"empty-sequence", EMPTY_SEQUENCE},
314  {"",ERROR}, {"",ERROR},
315 #line 157 "TokenLookup.gperf"
316  {"following-sibling", FOLLOWING_SIBLING},
317 #line 169 "TokenLookup.gperf"
318  {"instance", INSTANCE},
319 #line 213 "TokenLookup.gperf"
320  {"unordered", UNORDERED},
321 #line 128 "TokenLookup.gperf"
322  {"base-uri", BASEURI},
323 #line 197 "TokenLookup.gperf"
324  {"return", RETURN},
325  {"",ERROR},
326 #line 214 "TokenLookup.gperf"
327  {"validate", VALIDATE},
328  {"",ERROR},
329 #line 138 "TokenLookup.gperf"
330  {"copy-namespaces", COPY_NAMESPACES},
331 #line 186 "TokenLookup.gperf"
332  {"option", OPTION},
333 #line 165 "TokenLookup.gperf"
334  {"if", IF},
335  {"",ERROR},
336 #line 193 "TokenLookup.gperf"
337  {"preceding", PRECEDING},
338  {"",ERROR}, {"",ERROR},
339 #line 168 "TokenLookup.gperf"
340  {"in", IN},
341  {"",ERROR},
342 #line 170 "TokenLookup.gperf"
343  {"intersect", INTERSECT},
344 #line 212 "TokenLookup.gperf"
345  {"union", UNION},
346  {"",ERROR},
347 #line 194 "TokenLookup.gperf"
348  {"preceding-sibling", PRECEDING_SIBLING},
349 #line 188 "TokenLookup.gperf"
350  {"ordering", ORDERING},
351 #line 203 "TokenLookup.gperf"
352  {"some", SOME},
353 #line 134 "TokenLookup.gperf"
354  {"child", CHILD},
355  {"",ERROR},
356 #line 187 "TokenLookup.gperf"
357  {"ordered", ORDERED},
358 #line 215 "TokenLookup.gperf"
359  {"variable", VARIABLE},
360  {"",ERROR}, {"",ERROR}, {"",ERROR},
361 #line 190 "TokenLookup.gperf"
362  {"or", OR},
363  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
364 #line 136 "TokenLookup.gperf"
365  {"comment", COMMENT},
366  {"",ERROR}, {"",ERROR},
367 #line 211 "TokenLookup.gperf"
368  {"typeswitch", TYPESWITCH},
369  {"",ERROR},
370 #line 167 "TokenLookup.gperf"
371  {"inherit", INHERIT},
372 #line 144 "TokenLookup.gperf"
373  {"div", DIV},
374  {"",ERROR}, {"",ERROR},
375 #line 179 "TokenLookup.gperf"
376  {"module", MODULE},
377  {"",ERROR},
378 #line 159 "TokenLookup.gperf"
379  {"for", FOR},
380 #line 180 "TokenLookup.gperf"
381  {"namespace", NAMESPACE},
382  {"",ERROR}, {"",ERROR},
383 #line 216 "TokenLookup.gperf"
384  {"version", VERSION},
385  {"",ERROR}, {"",ERROR},
386 #line 206 "TokenLookup.gperf"
387  {"strip", STRIP},
388  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
389 #line 189 "TokenLookup.gperf"
390  {"order", ORDER},
391 #line 191 "TokenLookup.gperf"
392  {"parent", PARENT},
393  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
394  {"",ERROR}, {"",ERROR},
395 #line 178 "TokenLookup.gperf"
396  {"mod", MOD},
397  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
398  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
399  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
400  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
401  {"",ERROR},
402 #line 166 "TokenLookup.gperf"
403  {"import", IMPORT},
404  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
405  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
406  {"",ERROR}, {"",ERROR},
407 #line 196 "TokenLookup.gperf"
408  {"processing-instruction", PROCESSING_INSTRUCTION},
409  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
410  {"",ERROR}, {"",ERROR},
411 #line 172 "TokenLookup.gperf"
412  {"item", ITEM},
413  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
414  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
415  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
416  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
417  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
418  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
419  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
420  {"",ERROR},
421 #line 164 "TokenLookup.gperf"
422  {"idiv", IDIV}
423  };
424 
425  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
426  {
427  register int key = hash (str, len);
428 
429  if (key <= MAX_HASH_VALUE && key >= 0)
430  {
431  register const char *s = wordlist[key].name;
432 
433  if (*str == *s && !strcmp (str + 1, s + 1))
434  return &wordlist[key];
435  }
436  }
437  return 0;
438 }
static unsigned int hash(const char *str, unsigned int len)
int key

The documentation for this class was generated from the following file: