Code

r11516@tres: ted | 2006-04-26 21:30:18 -0700
[inkscape.git] / src / dom / xpathtoken.h
1 #ifndef __XPATHTOKEN_H__\r
2 #define __XPATHTOKEN_H__\r
3 \r
4 /**\r
5  * Phoebe DOM Implementation.\r
6  *\r
7  * This is a C++ approximation of the W3C DOM model, which follows\r
8  * fairly closely the specifications in the various .idl files, copies of\r
9  * which are provided for reference.  Most important is this one:\r
10  *\r
11  * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html\r
12  *\r
13  * Authors:\r
14  *   Bob Jamison\r
15  *\r
16  * Copyright (C) 2006 Bob Jamison\r
17  *\r
18  *  This library is free software; you can redistribute it and/or\r
19  *  modify it under the terms of the GNU Lesser General Public\r
20  *  License as published by the Free Software Foundation; either\r
21  *  version 2.1 of the License, or (at your option) any later version.\r
22  *\r
23  *  This library is distributed in the hope that it will be useful,\r
24  *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
25  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
26  *  Lesser General Public License for more details.\r
27  *\r
28  *  You should have received a copy of the GNU Lesser General Public\r
29  *  License along with this library; if not, write to the Free Software\r
30  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
31  */\r
32 \r
33 \r
34 #include "dom.h"\r
35 \r
36 #include <math.h>\r
37 \r
38 #include <vector>\r
39 \r
40 namespace org\r
41 {\r
42 namespace w3c\r
43 {\r
44 namespace dom\r
45 {\r
46 namespace xpath\r
47 {\r
48 \r
49 typedef org::w3c::dom::DOMString DOMString;\r
50 \r
51 class Axis\r
52 {\r
53 public:\r
54     /**\r
55      *  Constructor\r
56      */\r
57     Axis();\r
58 \r
59     /**\r
60      *  Constructor\r
61      */\r
62     Axis(int tokPos);\r
63 \r
64     /**\r
65      *  Copy constructor\r
66      */\r
67     Axis(const Axis &other);\r
68 \r
69     /**\r
70      *  Destructor\r
71      */\r
72     virtual ~Axis();\r
73 \r
74     /**\r
75      *\r
76      */\r
77     Axis &operator=(const Axis &other);\r
78 \r
79     /**\r
80      *\r
81      */\r
82     void init();\r
83 \r
84     /**\r
85      *\r
86      */\r
87     void assign(const Axis &other);\r
88 \r
89     /**\r
90      *\r
91      */\r
92     void setPosition(unsigned int val);\r
93 \r
94     /**\r
95      *\r
96      */\r
97     unsigned int getPosition();\r
98 \r
99     /**\r
100      *\r
101      */\r
102     void setNode(const Node *node);\r
103 \r
104     /**\r
105      *\r
106      */\r
107     Node *getNode();\r
108 \r
109 private:\r
110 \r
111     int tokenPosition;\r
112 \r
113     Node *node;\r
114 };\r
115 \r
116 \r
117 /**\r
118  * This represents a single value on the evaluation stack\r
119  */\r
120 class StackItem\r
121 {\r
122 public:\r
123 \r
124     /**\r
125      *  Constructor\r
126      */\r
127     StackItem();\r
128 \r
129     /**\r
130      *  Copy constructor\r
131      */\r
132     StackItem(const StackItem &other);\r
133 \r
134     /**\r
135      *  Destructor\r
136      */\r
137     virtual ~StackItem();\r
138 \r
139     /**\r
140      *\r
141      */\r
142     StackItem &operator=(const StackItem &other);\r
143 \r
144     /**\r
145      *\r
146      */\r
147     void assign(const StackItem &other);\r
148 \r
149 \r
150     //treat the stack item like an union of string, integer, and double\r
151 \r
152     /**\r
153      * String value\r
154      */\r
155     DOMString sval;\r
156 \r
157     /**\r
158      * Integer value\r
159      */\r
160     long      ival;\r
161 \r
162     /**\r
163      * Double value;\r
164      */\r
165     double    dval;\r
166 \r
167 };\r
168 \r
169 class TokenList;\r
170 \r
171 //########################################################################\r
172 //# T O K E N    E X E C U T O R\r
173 //########################################################################\r
174 \r
175 #define STACK_SIZE 1024\r
176 \r
177 /**\r
178  * A token evaluator, with stack and axis context\r
179  */\r
180 class TokenExecutor\r
181 {\r
182 public:\r
183 \r
184     /**\r
185      * Constructor\r
186      */\r
187     TokenExecutor();\r
188 \r
189     /**\r
190      * Copy constructor\r
191      */\r
192     TokenExecutor(const TokenExecutor &other);\r
193 \r
194     /**\r
195      * Destructor\r
196      */\r
197     virtual ~TokenExecutor();\r
198 \r
199     /**\r
200      *  Assign our values to those of the other\r
201      */\r
202     virtual void assign(const TokenExecutor &other);\r
203 \r
204     /**\r
205      * Reset the stack to its original settings\r
206      */\r
207     virtual void reset();\r
208 \r
209     /**\r
210      * Push a stack item onto the stack\r
211      */\r
212     virtual void push(StackItem &item);\r
213 \r
214     /**\r
215      * Pop a stack item from the stack\r
216      */\r
217     virtual StackItem pop();\r
218 \r
219     /**\r
220      * Execute a token list on the stack\r
221      */\r
222     NodeList execute(const TokenList &list, const Node *node);\r
223 \r
224     /**\r
225      *\r
226      */\r
227     Axis axis;\r
228 \r
229     /**\r
230      *\r
231      */\r
232     std::vector<Axis> axisStack;\r
233 \r
234 private:\r
235 \r
236     /**\r
237      * Contains the StackItem stack;\r
238      */\r
239     StackItem stack[STACK_SIZE];\r
240 \r
241     /**\r
242      * Marks the head of the stack, for push() and pop()\r
243      */\r
244     int stackSize;\r
245 \r
246     /**\r
247      *  Current list of nodes found by the expression\r
248      */\r
249     NodeList nodeList;\r
250 \r
251 \r
252 };\r
253 \r
254 \r
255 \r
256 //########################################################################\r
257 //# X P A T H    T O K E N\r
258 //########################################################################\r
259 \r
260 \r
261 \r
262 /**\r
263  *  This is a pseudocode-type class that executes itself on a stack,\r
264  *  much like stack-oriented languages such as FORTH or Postscript.\r
265  *  Each token can pop zero or more tokens off the stack, and push\r
266  *  zero or one token back onto it.  When a list of tokens is completed,\r
267  *  a single stack value should be left on the stack.\r
268  */\r
269 class Token\r
270 {\r
271 public:\r
272 \r
273     /**\r
274      * Token types.  Look in xpathtoken.cpp's function table\r
275      * to see how these types map to their respective\r
276      * functionalities\r
277      */\r
278     typedef enum\r
279         {\r
280         //primitives\r
281         TOK_NOP = 0,\r
282         TOK_STR,\r
283         TOK_INT,\r
284         TOK_FLOAT,\r
285         //operators\r
286         TOK_AND,\r
287         TOK_OR,\r
288         TOK_MOD,\r
289         TOK_DIV,\r
290         TOK_MULTIPLY,\r
291         TOK_DOUBLE_SLASH,\r
292         TOK_SLASH,\r
293         TOK_PIPE,\r
294         TOK_PLUS,\r
295         TOK_MINUS,\r
296         TOK_NEG,\r
297         TOK_EQUALS,\r
298         TOK_NOT_EQUALS,\r
299         TOK_LESS_THAN_EQUALS,\r
300         TOK_LESS_THAN,\r
301         TOK_GREATER_THAN_EQUALS,\r
302         TOK_GREATER_THAN,\r
303         //path types\r
304         TOK_ABSOLUTE,\r
305         TOK_RELATIVE,\r
306         TOK_STEP,\r
307         TOK_NAME_TEST,\r
308         TOK_EXPR,\r
309         TOK_UNION,\r
310         //axis types\r
311         TOK_AXIS_ANCESTOR_OR_SELF,\r
312         TOK_AXIS_ANCESTOR,\r
313         TOK_AXIS_ATTRIBUTE,\r
314         TOK_AXIS_CHILD,\r
315         TOK_AXIS_DESCENDANT_OR_SELF,\r
316         TOK_AXIS_DESCENDANT,\r
317         TOK_AXIS_FOLLOWING_SIBLING,\r
318         TOK_AXIS_FOLLOWING,\r
319         TOK_AXIS_NAMESPACE,\r
320         TOK_AXIS_PARENT,\r
321         TOK_AXIS_PRECEDING_SIBLING,\r
322         TOK_AXIS_PRECEDING,\r
323         TOK_AXIS_SELF,\r
324         //function types\r
325         TOK_FUNC_LAST,\r
326         TOK_FUNC_POSITION,\r
327         TOK_FUNC_COUNT,\r
328         TOK_FUNC_ID,\r
329         TOK_FUNC_LOCAL_NAME,\r
330         TOK_FUNC_NAMESPACE_URI,\r
331         TOK_FUNC_NAME,\r
332         TOK_FUNC_STRING,\r
333         TOK_FUNC_CONCAT,\r
334         TOK_FUNC_STARTS_WITH,\r
335         TOK_FUNC_CONTAINS,\r
336         TOK_FUNC_SUBSTRING_BEFORE,\r
337         TOK_FUNC_SUBSTRING_AFTER,\r
338         TOK_FUNC_SUBSTRING,\r
339         TOK_FUNC_STRING_LENGTH,\r
340         TOK_FUNC_NORMALIZE_SPACE,\r
341         TOK_FUNC_TRANSLATE,\r
342         TOK_FUNC_BOOLEAN,\r
343         TOK_FUNC_NOT,\r
344         TOK_FUNC_TRUE,\r
345         TOK_FUNC_FALSE,\r
346         TOK_FUNC_LANG,\r
347         TOK_FUNC_NUMBER,\r
348         TOK_FUNC_SUM,\r
349         TOK_FUNC_FLOOR,\r
350         TOK_FUNC_CEILING,\r
351         TOK_FUNC_ROUND,\r
352         } TokenType;\r
353 \r
354 \r
355 \r
356 \r
357     /**\r
358      *  Constructor with a NOP default type\r
359      */\r
360     Token()\r
361         {\r
362         type     = TOK_NOP;\r
363         ival     = 0L;\r
364         dval     = 0.0;\r
365         }\r
366 \r
367     /**\r
368      * Copy constructor\r
369      */\r
370     Token(const Token &other)\r
371         {\r
372         type     = other.type;\r
373         sval     = other.sval;\r
374         ival     = other.ival;\r
375         dval     = other.dval;\r
376         }\r
377 \r
378     /**\r
379      * Destructor\r
380      */\r
381     virtual ~Token()\r
382         {}\r
383 \r
384     /**\r
385      *  Return the enumerated TokenType of this token\r
386      */\r
387     virtual int getType()\r
388         { return type; }\r
389     /**\r
390      *  Return the string TokenType of this token\r
391      */\r
392     virtual DOMString getTypeString();\r
393 \r
394     /**\r
395      *  Let this token execute itself on the given stack,\r
396      *  possibly adding Nodes to the node list.\r
397      */\r
398     virtual bool execute(TokenExecutor &stack)\r
399         { return true; }\r
400 \r
401     /**\r
402      *  Print the contents of this token\r
403      */\r
404     virtual void dump()\r
405         {\r
406         printf("%s %s %f %ld\n",\r
407             getTypeString().c_str(), sval.c_str(), dval, ival);\r
408         }\r
409 \r
410     //treat the token like an union of string, integer, and double\r
411 \r
412     /**\r
413      * String value\r
414      */\r
415     DOMString sval;\r
416 \r
417     /**\r
418      * Integer value\r
419      */\r
420     long ival;\r
421 \r
422     /**\r
423      * Double value;\r
424      */\r
425     double dval;\r
426 \r
427 protected:\r
428 \r
429     /**\r
430      * The enmerated token type\r
431      */\r
432     int type;\r
433 \r
434 \r
435 private:\r
436 \r
437 \r
438 };\r
439 \r
440 \r
441 //########################################################################\r
442 //# X P A T H    T O K E N    T Y P E S\r
443 //########################################################################\r
444 \r
445 \r
446 \r
447 //###########################\r
448 //# V A L U E S\r
449 //###########################\r
450 \r
451 class TokStr : public Token\r
452 {\r
453 public:\r
454     TokStr(const DOMString &val)\r
455         {\r
456         type = TOK_STR;\r
457         sval = val;\r
458         }\r
459     virtual bool execute(TokenExecutor &exec)\r
460         {\r
461         StackItem item;\r
462         item.sval = sval;\r
463         exec.push(item);\r
464         return true;\r
465         }\r
466 };\r
467 \r
468 class TokFloat : public Token\r
469 {\r
470 public:\r
471     TokFloat(double val)\r
472         {\r
473         type = TOK_FLOAT;\r
474         dval = val;\r
475         }\r
476     virtual bool execute(TokenExecutor &exec)\r
477         {\r
478         StackItem item;\r
479         item.dval = dval;\r
480         exec.push(item);\r
481         return true;\r
482         }\r
483 };\r
484 \r
485 class TokInt : public Token\r
486 {\r
487 public:\r
488     TokInt(long val)\r
489         {\r
490         type = TOK_INT;\r
491         ival = val;\r
492         }\r
493     virtual bool execute(TokenExecutor &exec)\r
494         {\r
495         StackItem item;\r
496         item.ival = ival;\r
497         exec.push(item);\r
498         return true;\r
499         }\r
500 };\r
501 \r
502 class TokAnd : public Token\r
503 {\r
504 public:\r
505     TokAnd()\r
506         {\r
507         type = TOK_AND;\r
508         }\r
509     virtual bool execute(TokenExecutor &exec)\r
510         {\r
511         StackItem item1 = exec.pop();\r
512         StackItem item2 = exec.pop();\r
513         item1.ival = item1.ival && item2.ival;\r
514         exec.push(item1);\r
515         return true;\r
516         }\r
517 };\r
518 \r
519 class TokOr : public Token\r
520 {\r
521 public:\r
522     TokOr()\r
523         {\r
524         type = TOK_OR;\r
525         }\r
526     virtual bool execute(TokenExecutor &exec)\r
527         {\r
528         StackItem item1 = exec.pop();\r
529         StackItem item2 = exec.pop();\r
530         item1.ival = item1.ival || item2.ival;\r
531         exec.push(item1);\r
532         return true;\r
533         }\r
534 };\r
535 \r
536 class TokMod : public Token\r
537 {\r
538 public:\r
539     TokMod()\r
540         {\r
541         type = TOK_MOD;\r
542         }\r
543     virtual bool execute(TokenExecutor &exec)\r
544         {\r
545         StackItem item1 = exec.pop();\r
546         StackItem item2 = exec.pop();\r
547         item1.dval = fmod(item1.dval, item2.dval);\r
548         exec.push(item1);\r
549         return true;\r
550         }\r
551 };\r
552 \r
553 class TokDiv : public Token\r
554 {\r
555 public:\r
556     TokDiv()\r
557         {\r
558         type = TOK_DIV;\r
559         }\r
560     virtual bool execute(TokenExecutor &exec)\r
561         {\r
562         StackItem item1 = exec.pop();\r
563         StackItem item2 = exec.pop();\r
564         item1.dval /= item2.dval;\r
565         exec.push(item1);\r
566         return true;\r
567         }\r
568 };\r
569 \r
570 class TokMul : public Token\r
571 {\r
572 public:\r
573     TokMul()\r
574         {\r
575         type = TOK_MULTIPLY;\r
576         }\r
577     virtual bool execute(TokenExecutor &exec)\r
578         {\r
579         StackItem item1 = exec.pop();\r
580         StackItem item2 = exec.pop();\r
581         item1.dval *= item2.dval;\r
582         exec.push(item1);\r
583         return true;\r
584         }\r
585 };\r
586 \r
587 class TokPlus : public Token\r
588 {\r
589 public:\r
590     TokPlus()\r
591         {\r
592         type = TOK_PLUS;\r
593         }\r
594     virtual bool execute(TokenExecutor &exec)\r
595         {\r
596         StackItem item1 = exec.pop();\r
597         StackItem item2 = exec.pop();\r
598         item1.dval += item2.dval;\r
599         exec.push(item1);\r
600         return true;\r
601         }\r
602 };\r
603 \r
604 class TokMinus : public Token\r
605 {\r
606 public:\r
607     TokMinus()\r
608         {\r
609         type = TOK_MINUS;\r
610         }\r
611     virtual bool execute(TokenExecutor &exec)\r
612         {\r
613         StackItem item1 = exec.pop();\r
614         StackItem item2 = exec.pop();\r
615         item1.dval -= item2.dval;\r
616         exec.push(item1);\r
617         return true;\r
618         }\r
619 };\r
620 \r
621 class TokNeg : public Token\r
622 {\r
623 public:\r
624     TokNeg()\r
625         {\r
626         type = TOK_NEG;\r
627         }\r
628     virtual bool execute(TokenExecutor &exec)\r
629         {\r
630         StackItem item = exec.pop();\r
631         item.dval = -item.dval;\r
632         item.ival = -item.ival;\r
633         exec.push(item);\r
634         return true;\r
635         }\r
636 };\r
637 \r
638 class TokEquals : public Token\r
639 {\r
640 public:\r
641     TokEquals()\r
642         {\r
643         type = TOK_EQUALS;\r
644         }\r
645     virtual bool execute(TokenExecutor &exec)\r
646         {\r
647         StackItem item1 = exec.pop();\r
648         StackItem item2 = exec.pop();\r
649         item1.ival = (item1.dval == item2.dval);\r
650         exec.push(item1);\r
651         return true;\r
652         }\r
653 };\r
654 \r
655 class TokNotEquals : public Token\r
656 {\r
657 public:\r
658     TokNotEquals()\r
659         {\r
660         type = TOK_NOT_EQUALS;\r
661         }\r
662     virtual bool execute(TokenExecutor &exec)\r
663         {\r
664         StackItem item1 = exec.pop();\r
665         StackItem item2 = exec.pop();\r
666         item1.ival = (item1.dval != item2.dval);\r
667         exec.push(item1);\r
668         return true;\r
669         }\r
670 };\r
671 \r
672 class TokLessThanEquals : public Token\r
673 {\r
674 public:\r
675     TokLessThanEquals()\r
676         {\r
677         type = TOK_LESS_THAN_EQUALS;\r
678         }\r
679     virtual bool execute(TokenExecutor &exec)\r
680         {\r
681         StackItem item1 = exec.pop();\r
682         StackItem item2 = exec.pop();\r
683         item1.ival = (item1.dval <= item2.dval);\r
684         exec.push(item1);\r
685         return true;\r
686         }\r
687 };\r
688 \r
689 class TokLessThan : public Token\r
690 {\r
691 public:\r
692     TokLessThan()\r
693         {\r
694         type = TOK_LESS_THAN;\r
695         }\r
696     virtual bool execute(TokenExecutor &exec)\r
697         {\r
698         StackItem item1 = exec.pop();\r
699         StackItem item2 = exec.pop();\r
700         item1.ival = (item1.dval < item2.dval);\r
701         exec.push(item1);\r
702         return true;\r
703         }\r
704 };\r
705 \r
706 class TokGreaterThanEquals : public Token\r
707 {\r
708 public:\r
709     TokGreaterThanEquals()\r
710         {\r
711         type = TOK_GREATER_THAN_EQUALS;\r
712         }\r
713     virtual bool execute(TokenExecutor &exec)\r
714         {\r
715         StackItem item1 = exec.pop();\r
716         StackItem item2 = exec.pop();\r
717         item1.ival = (item1.dval >= item2.dval);\r
718         exec.push(item1);\r
719         return true;\r
720         }\r
721 };\r
722 \r
723 class TokGreaterThan : public Token\r
724 {\r
725 public:\r
726     TokGreaterThan()\r
727         {\r
728         type = TOK_GREATER_THAN;\r
729         }\r
730     virtual bool execute(TokenExecutor &exec)\r
731         {\r
732         StackItem item1 = exec.pop();\r
733         StackItem item2 = exec.pop();\r
734         item1.ival = (item1.dval > item2.dval);\r
735         exec.push(item1);\r
736         return true;\r
737         }\r
738 };\r
739 \r
740 \r
741 //###########################\r
742 //# X P A T H    I T E M S\r
743 //###########################\r
744 \r
745 class TokAbsolute : public Token\r
746 {\r
747 public:\r
748     TokAbsolute()\r
749         {\r
750         type = TOK_ABSOLUTE;\r
751         }\r
752     virtual bool execute(TokenExecutor &exec)\r
753         {\r
754         Node *n = exec.axis.getNode();\r
755         while (n->getParentNode())\r
756              n = n->getParentNode();\r
757         exec.axis.setNode(n);\r
758         return true;\r
759         }\r
760 };\r
761 \r
762 class TokRelative : public Token\r
763 {\r
764 public:\r
765     TokRelative()\r
766         {\r
767         type = TOK_RELATIVE;\r
768         }\r
769     virtual bool execute(TokenExecutor &exec)\r
770         {\r
771         ///exec.axis.currentNode = stack.rootNode;\r
772         return true;\r
773         }\r
774 };\r
775 \r
776 class TokStep : public Token\r
777 {\r
778 public:\r
779     TokStep()\r
780         {\r
781         type = TOK_STEP;\r
782         }\r
783     virtual bool execute(TokenExecutor &exec)\r
784         {\r
785         return true;\r
786         }\r
787 };\r
788 \r
789 class TokNameTest : public Token\r
790 {\r
791 public:\r
792     TokNameTest(const DOMString &name)\r
793         {\r
794         type  = TOK_NAME_TEST;\r
795         sval  = name;\r
796         }\r
797     virtual bool execute(TokenExecutor &exec)\r
798         {\r
799         return true;\r
800         }\r
801 };\r
802 \r
803 class TokExpr : public Token\r
804 {\r
805 public:\r
806     TokExpr()\r
807         {\r
808         type = TOK_EXPR;\r
809         }\r
810     virtual bool execute(TokenExecutor &exec)\r
811         {\r
812         return true;\r
813         }\r
814 };\r
815 \r
816 class TokUnion : public Token\r
817 {\r
818 public:\r
819     TokUnion()\r
820         {\r
821         type = TOK_UNION;\r
822         }\r
823     virtual bool execute(TokenExecutor &exec)\r
824         {\r
825         return true;\r
826         }\r
827 };\r
828 \r
829 \r
830 \r
831 \r
832 //###########################\r
833 //# A X I S\r
834 //###########################\r
835 \r
836 \r
837 class TokAxisAncestorOrSelf : public Token\r
838 {\r
839 public:\r
840     TokAxisAncestorOrSelf()\r
841         {\r
842         type = TOK_AXIS_ANCESTOR_OR_SELF;\r
843         }\r
844     virtual bool execute(TokenExecutor &exec)\r
845         {\r
846         return true;\r
847         }\r
848 };\r
849 \r
850 class TokAxisAncestor : public Token\r
851 {\r
852 public:\r
853     TokAxisAncestor()\r
854         {\r
855         type = TOK_AXIS_ANCESTOR;\r
856         }\r
857     virtual bool execute(TokenExecutor &exec)\r
858         {\r
859         return true;\r
860         }\r
861 };\r
862 \r
863 class TokAxisAttribute : public Token\r
864 {\r
865 public:\r
866     TokAxisAttribute()\r
867         {\r
868         type = TOK_AXIS_ATTRIBUTE;\r
869         }\r
870     virtual bool execute(TokenExecutor &exec)\r
871         {\r
872         return true;\r
873         }\r
874 };\r
875 \r
876 class TokAxisChild : public Token\r
877 {\r
878 public:\r
879     TokAxisChild()\r
880         {\r
881         type = TOK_AXIS_CHILD;\r
882         }\r
883     virtual bool execute(TokenExecutor &exec)\r
884         {\r
885         return true;\r
886         }\r
887 };\r
888 \r
889 class TokAxisDescendantOrSelf : public Token\r
890 {\r
891 public:\r
892     TokAxisDescendantOrSelf()\r
893         {\r
894         type = TOK_AXIS_DESCENDANT_OR_SELF;\r
895         }\r
896     virtual bool execute(TokenExecutor &exec)\r
897         {\r
898         return true;\r
899         }\r
900 };\r
901 \r
902 class TokAxisDescendant : public Token\r
903 {\r
904 public:\r
905     TokAxisDescendant()\r
906         {\r
907         type = TOK_AXIS_DESCENDANT;\r
908         }\r
909     virtual bool execute(TokenExecutor &exec)\r
910         {\r
911         return true;\r
912         }\r
913 };\r
914 \r
915 class TokAxisFollowingSibling : public Token\r
916 {\r
917 public:\r
918     TokAxisFollowingSibling()\r
919         {\r
920         type = TOK_AXIS_FOLLOWING_SIBLING;\r
921         }\r
922     virtual bool execute(TokenExecutor &exec)\r
923         {\r
924         return true;\r
925         }\r
926 };\r
927 \r
928 class TokAxisFollowing : public Token\r
929 {\r
930 public:\r
931     TokAxisFollowing()\r
932         {\r
933         type = TOK_AXIS_FOLLOWING;\r
934         }\r
935     virtual bool execute(TokenExecutor &exec)\r
936         {\r
937         return true;\r
938         }\r
939 };\r
940 \r
941 class TokAxisNamespace : public Token\r
942 {\r
943 public:\r
944     TokAxisNamespace()\r
945         {\r
946         type = TOK_AXIS_NAMESPACE;\r
947         }\r
948     virtual bool execute(TokenExecutor &exec)\r
949         {\r
950         return true;\r
951         }\r
952 };\r
953 \r
954 class TokAxisParent : public Token\r
955 {\r
956 public:\r
957     TokAxisParent()\r
958         {\r
959         type = TOK_AXIS_PARENT;\r
960         }\r
961     virtual bool execute(TokenExecutor &exec)\r
962         {\r
963         return true;\r
964         }\r
965 };\r
966 \r
967 class TokAxisPrecedingSibling : public Token\r
968 {\r
969 public:\r
970     TokAxisPrecedingSibling()\r
971         {\r
972         type = TOK_AXIS_PRECEDING_SIBLING;\r
973         }\r
974     virtual bool execute(TokenExecutor &exec)\r
975         {\r
976         return true;\r
977         }\r
978 };\r
979 \r
980 class TokAxisPreceding : public Token\r
981 {\r
982 public:\r
983     TokAxisPreceding()\r
984         {\r
985         type = TOK_AXIS_PRECEDING;\r
986         }\r
987     virtual bool execute(TokenExecutor &exec)\r
988         {\r
989         return true;\r
990         }\r
991 };\r
992 \r
993 class TokAxisSelf : public Token\r
994 {\r
995 public:\r
996     TokAxisSelf()\r
997         {\r
998         type = TOK_AXIS_SELF;\r
999         }\r
1000     virtual bool execute(TokenExecutor &exec)\r
1001         {\r
1002         return true;\r
1003         }\r
1004 };\r
1005 \r
1006 \r
1007 \r
1008 //###########################\r
1009 //# F U N C T I O N S\r
1010 //###########################\r
1011 \r
1012 class TokFuncLast : public Token\r
1013 {\r
1014 public:\r
1015     TokFuncLast()\r
1016         {\r
1017         type = TOK_FUNC_LAST;\r
1018         }\r
1019     virtual bool execute(TokenExecutor &exec)\r
1020         {\r
1021         return true;\r
1022         }\r
1023 };\r
1024 \r
1025 class TokFuncPosition : public Token\r
1026 {\r
1027 public:\r
1028     TokFuncPosition()\r
1029         {\r
1030         type = TOK_FUNC_POSITION;\r
1031         }\r
1032     virtual bool execute(TokenExecutor &exec)\r
1033         {\r
1034         return true;\r
1035         }\r
1036 };\r
1037 \r
1038 class TokFuncCount : public Token\r
1039 {\r
1040 public:\r
1041     TokFuncCount()\r
1042         {\r
1043         type = TOK_FUNC_COUNT;\r
1044         }\r
1045     virtual bool execute(TokenExecutor &exec)\r
1046         {\r
1047         return true;\r
1048         }\r
1049 };\r
1050 \r
1051 class TokFuncId : public Token\r
1052 {\r
1053 public:\r
1054     TokFuncId()\r
1055         {\r
1056         type = TOK_FUNC_ID;\r
1057         }\r
1058     virtual bool execute(TokenExecutor &exec)\r
1059         {\r
1060         return true;\r
1061         }\r
1062 };\r
1063 \r
1064 class TokFuncLocalName : public Token\r
1065 {\r
1066 public:\r
1067     TokFuncLocalName()\r
1068         {\r
1069         type = TOK_FUNC_LOCAL_NAME;\r
1070         }\r
1071     virtual bool execute(TokenExecutor &exec)\r
1072         {\r
1073         return true;\r
1074         }\r
1075 };\r
1076 \r
1077 class TokFuncNamespaceUri : public Token\r
1078 {\r
1079 public:\r
1080     TokFuncNamespaceUri()\r
1081         {\r
1082         type = TOK_FUNC_NAMESPACE_URI;\r
1083         }\r
1084     virtual bool execute(TokenExecutor &exec)\r
1085         {\r
1086         return true;\r
1087         }\r
1088 };\r
1089 \r
1090 class TokFuncName : public Token\r
1091 {\r
1092 public:\r
1093     TokFuncName()\r
1094         {\r
1095         type = TOK_FUNC_NAME;\r
1096         }\r
1097     virtual bool execute(TokenExecutor &exec)\r
1098         {\r
1099         return true;\r
1100         }\r
1101 };\r
1102 \r
1103 class TokFuncString : public Token\r
1104 {\r
1105 public:\r
1106     TokFuncString()\r
1107         {\r
1108         type = TOK_FUNC_STRING;\r
1109         }\r
1110     virtual bool execute(TokenExecutor &exec)\r
1111         {\r
1112         return true;\r
1113         }\r
1114 };\r
1115 \r
1116 class TokFuncConcat : public Token\r
1117 {\r
1118 public:\r
1119     TokFuncConcat()\r
1120         {\r
1121         type = TOK_FUNC_CONCAT;\r
1122         }\r
1123     virtual bool execute(TokenExecutor &exec)\r
1124         {\r
1125         return true;\r
1126         }\r
1127 };\r
1128 \r
1129 class TokFuncStartsWith : public Token\r
1130 {\r
1131 public:\r
1132     TokFuncStartsWith()\r
1133         {\r
1134         type = TOK_FUNC_STARTS_WITH;\r
1135         }\r
1136     virtual bool execute(TokenExecutor &exec)\r
1137         {\r
1138         return true;\r
1139         }\r
1140 };\r
1141 \r
1142 class TokFuncContains : public Token\r
1143 {\r
1144 public:\r
1145     TokFuncContains()\r
1146         {\r
1147         type = TOK_FUNC_CONTAINS;\r
1148         }\r
1149     virtual bool execute(TokenExecutor &exec)\r
1150         {\r
1151         return true;\r
1152         }\r
1153 };\r
1154 \r
1155 class TokFuncSubstringBefore : public Token\r
1156 {\r
1157 public:\r
1158     TokFuncSubstringBefore()\r
1159         {\r
1160         type = TOK_FUNC_SUBSTRING_BEFORE;\r
1161         }\r
1162     virtual bool execute(TokenExecutor &exec)\r
1163         {\r
1164         return true;\r
1165         }\r
1166 };\r
1167 \r
1168 class TokFuncSubstringAfter : public Token\r
1169 {\r
1170 public:\r
1171     TokFuncSubstringAfter()\r
1172         {\r
1173         type = TOK_FUNC_SUBSTRING_AFTER;\r
1174         }\r
1175     virtual bool execute(TokenExecutor &exec)\r
1176         {\r
1177         return true;\r
1178         }\r
1179 };\r
1180 \r
1181 class TokFuncSubstring : public Token\r
1182 {\r
1183 public:\r
1184     TokFuncSubstring()\r
1185         {\r
1186         type = TOK_FUNC_SUBSTRING;\r
1187         }\r
1188     virtual bool execute(TokenExecutor &exec)\r
1189         {\r
1190         return true;\r
1191         }\r
1192 };\r
1193 \r
1194 class TokFuncStringLength : public Token\r
1195 {\r
1196 public:\r
1197     TokFuncStringLength()\r
1198         {\r
1199         type = TOK_FUNC_STRING_LENGTH;\r
1200         }\r
1201     virtual bool execute(TokenExecutor &exec)\r
1202         {\r
1203         return true;\r
1204         }\r
1205 };\r
1206 \r
1207 class TokFuncNormalizeSpace : public Token\r
1208 {\r
1209 public:\r
1210     TokFuncNormalizeSpace()\r
1211         {\r
1212         type = TOK_FUNC_NORMALIZE_SPACE;\r
1213         }\r
1214     virtual bool execute(TokenExecutor &exec)\r
1215         {\r
1216         return true;\r
1217         }\r
1218 };\r
1219 \r
1220 class TokFuncTranslate : public Token\r
1221 {\r
1222 public:\r
1223     TokFuncTranslate()\r
1224         {\r
1225         type = TOK_FUNC_TRANSLATE;\r
1226         }\r
1227     virtual bool execute(TokenExecutor &exec)\r
1228         {\r
1229         return true;\r
1230         }\r
1231 };\r
1232 \r
1233 class TokFuncBoolean : public Token\r
1234 {\r
1235 public:\r
1236     TokFuncBoolean()\r
1237         {\r
1238         type = TOK_FUNC_BOOLEAN;\r
1239         }\r
1240     virtual bool execute(TokenExecutor &exec)\r
1241         {\r
1242         return true;\r
1243         }\r
1244 };\r
1245 \r
1246 class TokFuncNot : public Token\r
1247 {\r
1248 public:\r
1249     TokFuncNot()\r
1250         {\r
1251         type = TOK_FUNC_NOT;\r
1252         }\r
1253     virtual bool execute(TokenExecutor &exec)\r
1254         {\r
1255         return true;\r
1256         }\r
1257 };\r
1258 \r
1259 class TokFuncTrue : public Token\r
1260 {\r
1261 public:\r
1262     TokFuncTrue()\r
1263         {\r
1264         type = TOK_FUNC_TRUE;\r
1265         }\r
1266     virtual bool execute(TokenExecutor &exec)\r
1267         {\r
1268         return true;\r
1269         }\r
1270 };\r
1271 \r
1272 class TokFuncFalse : public Token\r
1273 {\r
1274 public:\r
1275     TokFuncFalse()\r
1276         {\r
1277         type = TOK_FUNC_FALSE;\r
1278         }\r
1279     virtual bool execute(TokenExecutor &exec)\r
1280         {\r
1281         return true;\r
1282         }\r
1283 };\r
1284 \r
1285 class TokFuncLang : public Token\r
1286 {\r
1287 public:\r
1288     TokFuncLang()\r
1289         {\r
1290         type = TOK_FUNC_LANG;\r
1291         }\r
1292     virtual bool execute(TokenExecutor &exec)\r
1293         {\r
1294         return true;\r
1295         }\r
1296 };\r
1297 \r
1298 class TokFuncNumber : public Token\r
1299 {\r
1300 public:\r
1301     TokFuncNumber()\r
1302         {\r
1303         type = TOK_FUNC_NUMBER;\r
1304         }\r
1305     virtual bool execute(TokenExecutor &exec)\r
1306         {\r
1307         return true;\r
1308         }\r
1309 };\r
1310 \r
1311 class TokFuncSum : public Token\r
1312 {\r
1313 public:\r
1314     TokFuncSum()\r
1315         {\r
1316         type = TOK_FUNC_SUM;\r
1317         }\r
1318     virtual bool execute(TokenExecutor &exec)\r
1319         {\r
1320         return true;\r
1321         }\r
1322 };\r
1323 \r
1324 class TokFuncFloor : public Token\r
1325 {\r
1326 public:\r
1327     TokFuncFloor()\r
1328         {\r
1329         type = TOK_FUNC_FLOOR;\r
1330         }\r
1331     virtual bool execute(TokenExecutor &exec)\r
1332         {\r
1333         return true;\r
1334         }\r
1335 };\r
1336 \r
1337 class TokFuncCeiling : public Token\r
1338 {\r
1339 public:\r
1340     TokFuncCeiling()\r
1341         {\r
1342         type = TOK_FUNC_CEILING;\r
1343         }\r
1344     virtual bool execute(TokenExecutor &exec)\r
1345         {\r
1346         return true;\r
1347         }\r
1348 };\r
1349 \r
1350 class TokFuncRound : public Token\r
1351 {\r
1352 public:\r
1353     TokFuncRound()\r
1354         {\r
1355         type = TOK_FUNC_ROUND;\r
1356         }\r
1357     virtual bool execute(TokenExecutor &exec)\r
1358         {\r
1359         return true;\r
1360         }\r
1361 };\r
1362 \r
1363 \r
1364 \r
1365 \r
1366 \r
1367 \r
1368 //########################################################################\r
1369 //# T O K E N    L I S T\r
1370 //########################################################################\r
1371 \r
1372 /**\r
1373  *\r
1374  */\r
1375 class TokenList\r
1376 {\r
1377 public:\r
1378 \r
1379     /**\r
1380      *\r
1381      */\r
1382     TokenList();\r
1383 \r
1384     /**\r
1385      *\r
1386      */\r
1387     TokenList(const TokenList &other);\r
1388 \r
1389     /**\r
1390      *\r
1391      */\r
1392     TokenList &operator=(const TokenList &other);\r
1393 \r
1394     /**\r
1395      *\r
1396      */\r
1397     void assign(const TokenList &other);\r
1398 \r
1399     /**\r
1400      *\r
1401      */\r
1402     virtual ~TokenList();\r
1403 \r
1404     /**\r
1405      *\r
1406      */\r
1407     virtual void clear();\r
1408 \r
1409     /**\r
1410      *\r
1411      */\r
1412     virtual void add(Token *tok);\r
1413 \r
1414     /**\r
1415      *\r
1416      */\r
1417     virtual unsigned int size() const;\r
1418 \r
1419     /**\r
1420      *\r
1421      */\r
1422     virtual void dump();\r
1423 \r
1424 private:\r
1425 \r
1426 \r
1427     std::vector<Token *> tokens;\r
1428 \r
1429 \r
1430 };\r
1431 \r
1432 \r
1433 \r
1434 \r
1435 \r
1436 \r
1437 \r
1438 } // namespace xpath\r
1439 } // namespace dom\r
1440 } // namespace w3c\r
1441 } // namespace org\r
1442 \r
1443 \r
1444 \r
1445 \r
1446 \r
1447 \r
1448 #endif  /* __XPATHTOKEN_H__ */\r
1449 //########################################################################\r
1450 //# E N D    O F    F I L E\r
1451 //########################################################################\r
1452 \r