Code

(no commit message)
[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 Stack &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      * Set the root node\r
221      */\r
222     virtual void setRootNode(const Node *node);\r
223 \r
224     /**\r
225      * Get the current node list;\r
226      */\r
227     virtual NodeList &getNodeList();\r
228 \r
229 \r
230 private:\r
231 \r
232     Node *root;\r
233     NodeList nodeList;\r
234 \r
235     StackItem items[STACK_SIZE];\r
236     int size;\r
237 };\r
238 \r
239 \r
240 \r
241 //########################################################################\r
242 //# X P A T H    T O K E N\r
243 //########################################################################\r
244 \r
245 \r
246 \r
247 /**\r
248  *  This is a pseudocode-type class that executes itself on a stack,\r
249  *  much like stack-oriented languages such as FORTH or Postscript.\r
250  *  Each token can pop zero or more tokens off the stack, and push\r
251  *  zero or one token back onto it.  When a list of tokens is completed,\r
252  *  a single stack value should be left on the stack.\r
253  */\r
254 class Token\r
255 {\r
256 public:\r
257 \r
258     /**\r
259      * Token types.  Look in xpathtoken.cpp's function table\r
260      * to see how these types map to their respective\r
261      * functionalities\r
262      */\r
263     typedef enum\r
264         {\r
265         //primitives\r
266         TOK_NOP = 0,\r
267         TOK_STR,\r
268         TOK_INT,\r
269         TOK_FLOAT,\r
270         //operators\r
271         TOK_AND,\r
272         TOK_OR,\r
273         TOK_MOD,\r
274         TOK_DIV,\r
275         TOK_MULTIPLY,\r
276         TOK_DOUBLE_SLASH,\r
277         TOK_SLASH,\r
278         TOK_PIPE,\r
279         TOK_PLUS,\r
280         TOK_MINUS,\r
281         TOK_NEG,\r
282         TOK_EQUALS,\r
283         TOK_NOT_EQUALS,\r
284         TOK_LESS_THAN_EQUALS,\r
285         TOK_LESS_THAN,\r
286         TOK_GREATER_THAN_EQUALS,\r
287         TOK_GREATER_THAN,\r
288         //path types\r
289         TOK_ABSOLUTE,\r
290         TOK_RELATIVE,\r
291         TOK_STEP,\r
292         TOK_NAME_TEST,\r
293         TOK_EXPR,\r
294         TOK_UNION,\r
295         //axis types\r
296         TOK_AXIS_ANCESTOR_OR_SELF,\r
297         TOK_AXIS_ANCESTOR,\r
298         TOK_AXIS_ATTRIBUTE,\r
299         TOK_AXIS_CHILD,\r
300         TOK_AXIS_DESCENDANT_OR_SELF,\r
301         TOK_AXIS_DESCENDANT,\r
302         TOK_AXIS_FOLLOWING_SIBLING,\r
303         TOK_AXIS_FOLLOWING,\r
304         TOK_AXIS_NAMESPACE,\r
305         TOK_AXIS_PARENT,\r
306         TOK_AXIS_PRECEDING_SIBLING,\r
307         TOK_AXIS_PRECEDING,\r
308         TOK_AXIS_SELF,\r
309         //function types\r
310         TOK_FUNC_LAST,\r
311         TOK_FUNC_POSITION,\r
312         TOK_FUNC_COUNT,\r
313         TOK_FUNC_ID,\r
314         TOK_FUNC_LOCAL_NAME,\r
315         TOK_FUNC_NAMESPACE_URI,\r
316         TOK_FUNC_NAME,\r
317         TOK_FUNC_STRING,\r
318         TOK_FUNC_CONCAT,\r
319         TOK_FUNC_STARTS_WITH,\r
320         TOK_FUNC_CONTAINS,\r
321         TOK_FUNC_SUBSTRING_BEFORE,\r
322         TOK_FUNC_SUBSTRING_AFTER,\r
323         TOK_FUNC_SUBSTRING,\r
324         TOK_FUNC_STRING_LENGTH,\r
325         TOK_FUNC_NORMALIZE_SPACE,\r
326         TOK_FUNC_TRANSLATE,\r
327         TOK_FUNC_BOOLEAN,\r
328         TOK_FUNC_NOT,\r
329         TOK_FUNC_TRUE,\r
330         TOK_FUNC_FALSE,\r
331         TOK_FUNC_LANG,\r
332         TOK_FUNC_NUMBER,\r
333         TOK_FUNC_SUM,\r
334         TOK_FUNC_FLOOR,\r
335         TOK_FUNC_CEILING,\r
336         TOK_FUNC_ROUND,\r
337         } TokenType;\r
338 \r
339 \r
340 \r
341 \r
342     /**\r
343      *  Constructor with a NOP default type\r
344      */\r
345     Token()\r
346         {\r
347         type     = TOK_NOP;\r
348         ival     = 0L;\r
349         dval     = 0.0;\r
350         }\r
351 \r
352     /**\r
353      * Copy constructor\r
354      */\r
355     Token(const Token &other)\r
356         {\r
357         type     = other.type;\r
358         sval     = other.sval;\r
359         ival     = other.ival;\r
360         dval     = other.dval;\r
361         }\r
362 \r
363     /**\r
364      * Destructor\r
365      */\r
366     virtual ~Token()\r
367         {}\r
368 \r
369     /**\r
370      *  Return the enumerated TokenType of this token\r
371      */\r
372     virtual int getType()\r
373         { return type; }\r
374     /**\r
375      *  Return the enumerated TokenType of this token\r
376      *  (in the .cpp file)\r
377      */\r
378     virtual DOMString getTypeString();\r
379 \r
380     /**\r
381      *  Let this token execute itself on the given stack,\r
382      *  possibly adding Nodes to the node list.\r
383      */\r
384     virtual bool execute(Stack &stack)\r
385         { return true; }\r
386 \r
387     /**\r
388      *  Print the contents of this token\r
389      */\r
390     virtual void dump()\r
391         {\r
392         printf("%s %s %f %ld\n",\r
393             getTypeString().c_str(), sval.c_str(), dval, ival);\r
394         }\r
395 \r
396     //treat the token like an union of string, integer, and double\r
397 \r
398     /**\r
399      * String value\r
400      */\r
401     DOMString sval;\r
402 \r
403     /**\r
404      * Integer value\r
405      */\r
406     long ival;\r
407 \r
408     /**\r
409      * Double value;\r
410      */\r
411     double dval;\r
412 \r
413 protected:\r
414 \r
415     /**\r
416      * The enmerated token type\r
417      */\r
418     int type;\r
419 \r
420 \r
421 private:\r
422 \r
423 \r
424 };\r
425 \r
426 \r
427 //########################################################################\r
428 //# X P A T H    T O K E N    T Y P E S\r
429 //########################################################################\r
430 \r
431 \r
432 \r
433 //###########################\r
434 //# V A L U E S\r
435 //###########################\r
436 \r
437 class TokStr : public Token\r
438 {\r
439 public:\r
440     TokStr(const DOMString &val)\r
441         {\r
442         type = TOK_STR;\r
443         sval = val;\r
444         }\r
445     virtual bool execute(Stack &stack)\r
446         {\r
447         StackItem item;\r
448         item.sval = sval;\r
449         exec.push(item);\r
450         return true;\r
451         }\r
452 };\r
453 \r
454 class TokFloat : public Token\r
455 {\r
456 public:\r
457     TokFloat(double val)\r
458         {\r
459         type = TOK_FLOAT;\r
460         dval = val;\r
461         }\r
462     virtual bool execute(Stack &stack)\r
463         {\r
464         StackItem item;\r
465         item.dval = dval;\r
466         exec.push(item);\r
467         return true;\r
468         }\r
469 };\r
470 \r
471 class TokInt : public Token\r
472 {\r
473 public:\r
474     TokInt(long val)\r
475         {\r
476         type = TOK_INT;\r
477         ival = val;\r
478         }\r
479     virtual bool execute(Stack &stack)\r
480         {\r
481         StackItem item;\r
482         item.ival = ival;\r
483         exec.push(item);\r
484         return true;\r
485         }\r
486 };\r
487 \r
488 class TokAnd : public Token\r
489 {\r
490 public:\r
491     TokAnd()\r
492         {\r
493         type = TOK_AND;\r
494         }\r
495     virtual bool execute(Stack &stack)\r
496         {\r
497         StackItem item1 = exec.pop();\r
498         StackItem item2 = exec.pop();\r
499         item1.ival = item1.ival && item2.ival;\r
500         exec.push(item1);\r
501         return true;\r
502         }\r
503 };\r
504 \r
505 class TokOr : public Token\r
506 {\r
507 public:\r
508     TokOr()\r
509         {\r
510         type = TOK_OR;\r
511         }\r
512     virtual bool execute(Stack &stack)\r
513         {\r
514         StackItem item1 = exec.pop();\r
515         StackItem item2 = exec.pop();\r
516         item1.ival = item1.ival || item2.ival;\r
517         exec.push(item1);\r
518         return true;\r
519         }\r
520 };\r
521 \r
522 class TokMod : public Token\r
523 {\r
524 public:\r
525     TokMod()\r
526         {\r
527         type = TOK_MOD;\r
528         }\r
529     virtual bool execute(Stack &stack)\r
530         {\r
531         StackItem item1 = exec.pop();\r
532         StackItem item2 = exec.pop();\r
533         item1.dval = fmod(item1.dval, item2.dval);\r
534         exec.push(item1);\r
535         return true;\r
536         }\r
537 };\r
538 \r
539 class TokDiv : public Token\r
540 {\r
541 public:\r
542     TokDiv()\r
543         {\r
544         type = TOK_DIV;\r
545         }\r
546     virtual bool execute(Stack &stack)\r
547         {\r
548         StackItem item1 = exec.pop();\r
549         StackItem item2 = exec.pop();\r
550         item1.dval /= item2.dval;\r
551         exec.push(item1);\r
552         return true;\r
553         }\r
554 };\r
555 \r
556 class TokMul : public Token\r
557 {\r
558 public:\r
559     TokMul()\r
560         {\r
561         type = TOK_MULTIPLY;\r
562         }\r
563     virtual bool execute(Stack &stack)\r
564         {\r
565         StackItem item1 = exec.pop();\r
566         StackItem item2 = exec.pop();\r
567         item1.dval *= item2.dval;\r
568         exec.push(item1);\r
569         return true;\r
570         }\r
571 };\r
572 \r
573 class TokPlus : public Token\r
574 {\r
575 public:\r
576     TokPlus()\r
577         {\r
578         type = TOK_PLUS;\r
579         }\r
580     virtual bool execute(Stack &stack)\r
581         {\r
582         StackItem item1 = exec.pop();\r
583         StackItem item2 = exec.pop();\r
584         item1.dval += item2.dval;\r
585         exec.push(item1);\r
586         return true;\r
587         }\r
588 };\r
589 \r
590 class TokMinus : public Token\r
591 {\r
592 public:\r
593     TokMinus()\r
594         {\r
595         type = TOK_MINUS;\r
596         }\r
597     virtual bool execute(Stack &stack)\r
598         {\r
599         StackItem item1 = exec.pop();\r
600         StackItem item2 = exec.pop();\r
601         item1.dval -= item2.dval;\r
602         exec.push(item1);\r
603         return true;\r
604         }\r
605 };\r
606 \r
607 class TokNeg : public Token\r
608 {\r
609 public:\r
610     TokNeg()\r
611         {\r
612         type = TOK_NEG;\r
613         }\r
614     virtual bool execute(Stack &stack)\r
615         {\r
616         StackItem item = exec.pop();\r
617         item.dval = -item.dval;\r
618         item.ival = -item.ival;\r
619         exec.push(item);\r
620         return true;\r
621         }\r
622 };\r
623 \r
624 class TokEquals : public Token\r
625 {\r
626 public:\r
627     TokEquals()\r
628         {\r
629         type = TOK_EQUALS;\r
630         }\r
631     virtual bool execute(Stack &stack)\r
632         {\r
633         StackItem item1 = exec.pop();\r
634         StackItem item2 = exec.pop();\r
635         item1.ival = (item1.dval == item2.dval);\r
636         exec.push(item1);\r
637         return true;\r
638         }\r
639 };\r
640 \r
641 class TokNotEquals : public Token\r
642 {\r
643 public:\r
644     TokNotEquals()\r
645         {\r
646         type = TOK_NOT_EQUALS;\r
647         }\r
648     virtual bool execute(Stack &stack)\r
649         {\r
650         StackItem item1 = exec.pop();\r
651         StackItem item2 = exec.pop();\r
652         item1.ival = (item1.dval != item2.dval);\r
653         exec.push(item1);\r
654         return true;\r
655         }\r
656 };\r
657 \r
658 class TokLessThanEquals : public Token\r
659 {\r
660 public:\r
661     TokLessThanEquals()\r
662         {\r
663         type = TOK_LESS_THAN_EQUALS;\r
664         }\r
665     virtual bool execute(Stack &stack)\r
666         {\r
667         StackItem item1 = exec.pop();\r
668         StackItem item2 = exec.pop();\r
669         item1.ival = (item1.dval <= item2.dval);\r
670         exec.push(item1);\r
671         return true;\r
672         }\r
673 };\r
674 \r
675 class TokLessThan : public Token\r
676 {\r
677 public:\r
678     TokLessThan()\r
679         {\r
680         type = TOK_LESS_THAN;\r
681         }\r
682     virtual bool execute(Stack &stack)\r
683         {\r
684         StackItem item1 = exec.pop();\r
685         StackItem item2 = exec.pop();\r
686         item1.ival = (item1.dval < item2.dval);\r
687         exec.push(item1);\r
688         return true;\r
689         }\r
690 };\r
691 \r
692 class TokGreaterThanEquals : public Token\r
693 {\r
694 public:\r
695     TokGreaterThanEquals()\r
696         {\r
697         type = TOK_GREATER_THAN_EQUALS;\r
698         }\r
699     virtual bool execute(Stack &stack)\r
700         {\r
701         StackItem item1 = exec.pop();\r
702         StackItem item2 = exec.pop();\r
703         item1.ival = (item1.dval >= item2.dval);\r
704         exec.push(item1);\r
705         return true;\r
706         }\r
707 };\r
708 \r
709 class TokGreaterThan : public Token\r
710 {\r
711 public:\r
712     TokGreaterThan()\r
713         {\r
714         type = TOK_GREATER_THAN;\r
715         }\r
716     virtual bool execute(Stack &stack)\r
717         {\r
718         StackItem item1 = exec.pop();\r
719         StackItem item2 = exec.pop();\r
720         item1.ival = (item1.dval > item2.dval);\r
721         exec.push(item1);\r
722         return true;\r
723         }\r
724 };\r
725 \r
726 \r
727 //###########################\r
728 //# X P A T H    I T E M S\r
729 //###########################\r
730 \r
731 class TokAbsolute : public Token\r
732 {\r
733 public:\r
734     TokAbsolute()\r
735         {\r
736         type = TOK_ABSOLUTE;\r
737         }\r
738     virtual bool execute(Stack &stack)\r
739         {\r
740         Node *n = exec.axis.getNode();\r
741         while (n->getParentNode())\r
742              n = n->getParentNode();\r
743         exec.axis.setNode(n);\r
744         return true;\r
745         }\r
746 };\r
747 \r
748 class TokRelative : public Token\r
749 {\r
750 public:\r
751     TokRelative()\r
752         {\r
753         type = TOK_RELATIVE;\r
754         }\r
755     virtual bool execute(Stack &stack)\r
756         {\r
757         ///exec.axis.currentNode = stack.rootNode;\r
758         return true;\r
759         }\r
760 };\r
761 \r
762 class TokStep : public Token\r
763 {\r
764 public:\r
765     TokStep()\r
766         {\r
767         type = TOK_STEP;\r
768         }\r
769     virtual bool execute(Stack &stack)\r
770         {\r
771         return true;\r
772         }\r
773 };\r
774 \r
775 class TokNameTest : public Token\r
776 {\r
777 public:\r
778     TokNameTest(const DOMString &name)\r
779         {\r
780         type  = TOK_NAME_TEST;\r
781         sval  = name;\r
782         }\r
783     virtual bool execute(Stack &stack)\r
784         {\r
785         return true;\r
786         }\r
787 };\r
788 \r
789 class TokExpr : public Token\r
790 {\r
791 public:\r
792     TokExpr()\r
793         {\r
794         type = TOK_EXPR;\r
795         }\r
796     virtual bool execute(Stack &stack)\r
797         {\r
798         return true;\r
799         }\r
800 };\r
801 \r
802 class TokUnion : public Token\r
803 {\r
804 public:\r
805     TokUnion()\r
806         {\r
807         type = TOK_UNION;\r
808         }\r
809     virtual bool execute(Stack &stack)\r
810         {\r
811         return true;\r
812         }\r
813 };\r
814 \r
815 \r
816 \r
817 \r
818 //###########################\r
819 //# A X I S\r
820 //###########################\r
821 \r
822 \r
823 class TokAxisAncestorOrSelf : public Token\r
824 {\r
825 public:\r
826     TokAxisAncestorOrSelf()\r
827         {\r
828         type = TOK_AXIS_ANCESTOR_OR_SELF;\r
829         }\r
830     virtual bool execute(Stack &stack)\r
831         {\r
832         return true;\r
833         }\r
834 };\r
835 \r
836 class TokAxisAncestor : public Token\r
837 {\r
838 public:\r
839     TokAxisAncestor()\r
840         {\r
841         type = TOK_AXIS_ANCESTOR;\r
842         }\r
843     virtual bool execute(Stack &stack)\r
844         {\r
845         return true;\r
846         }\r
847 };\r
848 \r
849 class TokAxisAttribute : public Token\r
850 {\r
851 public:\r
852     TokAxisAttribute()\r
853         {\r
854         type = TOK_AXIS_ATTRIBUTE;\r
855         }\r
856     virtual bool execute(Stack &stack)\r
857         {\r
858         return true;\r
859         }\r
860 };\r
861 \r
862 class TokAxisChild : public Token\r
863 {\r
864 public:\r
865     TokAxisChild()\r
866         {\r
867         type = TOK_AXIS_CHILD;\r
868         }\r
869     virtual bool execute(Stack &stack)\r
870         {\r
871         return true;\r
872         }\r
873 };\r
874 \r
875 class TokAxisDescendantOrSelf : public Token\r
876 {\r
877 public:\r
878     TokAxisDescendantOrSelf()\r
879         {\r
880         type = TOK_AXIS_DESCENDANT_OR_SELF;\r
881         }\r
882     virtual bool execute(Stack &stack)\r
883         {\r
884         return true;\r
885         }\r
886 };\r
887 \r
888 class TokAxisDescendant : public Token\r
889 {\r
890 public:\r
891     TokAxisDescendant()\r
892         {\r
893         type = TOK_AXIS_DESCENDANT;\r
894         }\r
895     virtual bool execute(Stack &stack)\r
896         {\r
897         return true;\r
898         }\r
899 };\r
900 \r
901 class TokAxisFollowingSibling : public Token\r
902 {\r
903 public:\r
904     TokAxisFollowingSibling()\r
905         {\r
906         type = TOK_AXIS_FOLLOWING_SIBLING;\r
907         }\r
908     virtual bool execute(Stack &stack)\r
909         {\r
910         return true;\r
911         }\r
912 };\r
913 \r
914 class TokAxisFollowing : public Token\r
915 {\r
916 public:\r
917     TokAxisFollowing()\r
918         {\r
919         type = TOK_AXIS_FOLLOWING;\r
920         }\r
921     virtual bool execute(Stack &stack)\r
922         {\r
923         return true;\r
924         }\r
925 };\r
926 \r
927 class TokAxisNamespace : public Token\r
928 {\r
929 public:\r
930     TokAxisNamespace()\r
931         {\r
932         type = TOK_AXIS_NAMESPACE;\r
933         }\r
934     virtual bool execute(Stack &stack)\r
935         {\r
936         return true;\r
937         }\r
938 };\r
939 \r
940 class TokAxisParent : public Token\r
941 {\r
942 public:\r
943     TokAxisParent()\r
944         {\r
945         type = TOK_AXIS_PARENT;\r
946         }\r
947     virtual bool execute(Stack &stack)\r
948         {\r
949         return true;\r
950         }\r
951 };\r
952 \r
953 class TokAxisPrecedingSibling : public Token\r
954 {\r
955 public:\r
956     TokAxisPrecedingSibling()\r
957         {\r
958         type = TOK_AXIS_PRECEDING_SIBLING;\r
959         }\r
960     virtual bool execute(Stack &stack)\r
961         {\r
962         return true;\r
963         }\r
964 };\r
965 \r
966 class TokAxisPreceding : public Token\r
967 {\r
968 public:\r
969     TokAxisPreceding()\r
970         {\r
971         type = TOK_AXIS_PRECEDING;\r
972         }\r
973     virtual bool execute(Stack &stack)\r
974         {\r
975         return true;\r
976         }\r
977 };\r
978 \r
979 class TokAxisSelf : public Token\r
980 {\r
981 public:\r
982     TokAxisSelf()\r
983         {\r
984         type = TOK_AXIS_SELF;\r
985         }\r
986     virtual bool execute(Stack &stack)\r
987         {\r
988         return true;\r
989         }\r
990 };\r
991 \r
992 \r
993 \r
994 //###########################\r
995 //# F U N C T I O N S\r
996 //###########################\r
997 \r
998 class TokFuncLast : public Token\r
999 {\r
1000 public:\r
1001     TokFuncLast()\r
1002         {\r
1003         type = TOK_FUNC_LAST;\r
1004         }\r
1005     virtual bool execute(Stack &stack)\r
1006         {\r
1007         return true;\r
1008         }\r
1009 };\r
1010 \r
1011 class TokFuncPosition : public Token\r
1012 {\r
1013 public:\r
1014     TokFuncPosition()\r
1015         {\r
1016         type = TOK_FUNC_POSITION;\r
1017         }\r
1018     virtual bool execute(Stack &stack)\r
1019         {\r
1020         return true;\r
1021         }\r
1022 };\r
1023 \r
1024 class TokFuncCount : public Token\r
1025 {\r
1026 public:\r
1027     TokFuncCount()\r
1028         {\r
1029         type = TOK_FUNC_COUNT;\r
1030         }\r
1031     virtual bool execute(Stack &stack)\r
1032         {\r
1033         return true;\r
1034         }\r
1035 };\r
1036 \r
1037 class TokFuncId : public Token\r
1038 {\r
1039 public:\r
1040     TokFuncId()\r
1041         {\r
1042         type = TOK_FUNC_ID;\r
1043         }\r
1044     virtual bool execute(Stack &stack)\r
1045         {\r
1046         return true;\r
1047         }\r
1048 };\r
1049 \r
1050 class TokFuncLocalName : public Token\r
1051 {\r
1052 public:\r
1053     TokFuncLocalName()\r
1054         {\r
1055         type = TOK_FUNC_LOCAL_NAME;\r
1056         }\r
1057     virtual bool execute(Stack &stack)\r
1058         {\r
1059         return true;\r
1060         }\r
1061 };\r
1062 \r
1063 class TokFuncNamespaceUri : public Token\r
1064 {\r
1065 public:\r
1066     TokFuncNamespaceUri()\r
1067         {\r
1068         type = TOK_FUNC_NAMESPACE_URI;\r
1069         }\r
1070     virtual bool execute(Stack &stack)\r
1071         {\r
1072         return true;\r
1073         }\r
1074 };\r
1075 \r
1076 class TokFuncName : public Token\r
1077 {\r
1078 public:\r
1079     TokFuncName()\r
1080         {\r
1081         type = TOK_FUNC_NAME;\r
1082         }\r
1083     virtual bool execute(Stack &stack)\r
1084         {\r
1085         return true;\r
1086         }\r
1087 };\r
1088 \r
1089 class TokFuncString : public Token\r
1090 {\r
1091 public:\r
1092     TokFuncString()\r
1093         {\r
1094         type = TOK_FUNC_STRING;\r
1095         }\r
1096     virtual bool execute(Stack &stack)\r
1097         {\r
1098         return true;\r
1099         }\r
1100 };\r
1101 \r
1102 class TokFuncConcat : public Token\r
1103 {\r
1104 public:\r
1105     TokFuncConcat()\r
1106         {\r
1107         type = TOK_FUNC_CONCAT;\r
1108         }\r
1109     virtual bool execute(Stack &stack)\r
1110         {\r
1111         return true;\r
1112         }\r
1113 };\r
1114 \r
1115 class TokFuncStartsWith : public Token\r
1116 {\r
1117 public:\r
1118     TokFuncStartsWith()\r
1119         {\r
1120         type = TOK_FUNC_STARTS_WITH;\r
1121         }\r
1122     virtual bool execute(Stack &stack)\r
1123         {\r
1124         return true;\r
1125         }\r
1126 };\r
1127 \r
1128 class TokFuncContains : public Token\r
1129 {\r
1130 public:\r
1131     TokFuncContains()\r
1132         {\r
1133         type = TOK_FUNC_CONTAINS;\r
1134         }\r
1135     virtual bool execute(Stack &stack)\r
1136         {\r
1137         return true;\r
1138         }\r
1139 };\r
1140 \r
1141 class TokFuncSubstringBefore : public Token\r
1142 {\r
1143 public:\r
1144     TokFuncSubstringBefore()\r
1145         {\r
1146         type = TOK_FUNC_SUBSTRING_BEFORE;\r
1147         }\r
1148     virtual bool execute(Stack &stack)\r
1149         {\r
1150         return true;\r
1151         }\r
1152 };\r
1153 \r
1154 class TokFuncSubstringAfter : public Token\r
1155 {\r
1156 public:\r
1157     TokFuncSubstringAfter()\r
1158         {\r
1159         type = TOK_FUNC_SUBSTRING_AFTER;\r
1160         }\r
1161     virtual bool execute(Stack &stack)\r
1162         {\r
1163         return true;\r
1164         }\r
1165 };\r
1166 \r
1167 class TokFuncSubstring : public Token\r
1168 {\r
1169 public:\r
1170     TokFuncSubstring()\r
1171         {\r
1172         type = TOK_FUNC_SUBSTRING;\r
1173         }\r
1174     virtual bool execute(Stack &stack)\r
1175         {\r
1176         return true;\r
1177         }\r
1178 };\r
1179 \r
1180 class TokFuncStringLength : public Token\r
1181 {\r
1182 public:\r
1183     TokFuncStringLength()\r
1184         {\r
1185         type = TOK_FUNC_STRING_LENGTH;\r
1186         }\r
1187     virtual bool execute(Stack &stack)\r
1188         {\r
1189         return true;\r
1190         }\r
1191 };\r
1192 \r
1193 class TokFuncNormalizeSpace : public Token\r
1194 {\r
1195 public:\r
1196     TokFuncNormalizeSpace()\r
1197         {\r
1198         type = TOK_FUNC_NORMALIZE_SPACE;\r
1199         }\r
1200     virtual bool execute(Stack &stack)\r
1201         {\r
1202         return true;\r
1203         }\r
1204 };\r
1205 \r
1206 class TokFuncTranslate : public Token\r
1207 {\r
1208 public:\r
1209     TokFuncTranslate()\r
1210         {\r
1211         type = TOK_FUNC_TRANSLATE;\r
1212         }\r
1213     virtual bool execute(Stack &stack)\r
1214         {\r
1215         return true;\r
1216         }\r
1217 };\r
1218 \r
1219 class TokFuncBoolean : public Token\r
1220 {\r
1221 public:\r
1222     TokFuncBoolean()\r
1223         {\r
1224         type = TOK_FUNC_BOOLEAN;\r
1225         }\r
1226     virtual bool execute(Stack &stack)\r
1227         {\r
1228         return true;\r
1229         }\r
1230 };\r
1231 \r
1232 class TokFuncNot : public Token\r
1233 {\r
1234 public:\r
1235     TokFuncNot()\r
1236         {\r
1237         type = TOK_FUNC_NOT;\r
1238         }\r
1239     virtual bool execute(Stack &stack)\r
1240         {\r
1241         return true;\r
1242         }\r
1243 };\r
1244 \r
1245 class TokFuncTrue : public Token\r
1246 {\r
1247 public:\r
1248     TokFuncTrue()\r
1249         {\r
1250         type = TOK_FUNC_TRUE;\r
1251         }\r
1252     virtual bool execute(Stack &stack)\r
1253         {\r
1254         return true;\r
1255         }\r
1256 };\r
1257 \r
1258 class TokFuncFalse : public Token\r
1259 {\r
1260 public:\r
1261     TokFuncFalse()\r
1262         {\r
1263         type = TOK_FUNC_FALSE;\r
1264         }\r
1265     virtual bool execute(Stack &stack)\r
1266         {\r
1267         return true;\r
1268         }\r
1269 };\r
1270 \r
1271 class TokFuncLang : public Token\r
1272 {\r
1273 public:\r
1274     TokFuncLang()\r
1275         {\r
1276         type = TOK_FUNC_LANG;\r
1277         }\r
1278     virtual bool execute(Stack &stack)\r
1279         {\r
1280         return true;\r
1281         }\r
1282 };\r
1283 \r
1284 class TokFuncNumber : public Token\r
1285 {\r
1286 public:\r
1287     TokFuncNumber()\r
1288         {\r
1289         type = TOK_FUNC_NUMBER;\r
1290         }\r
1291     virtual bool execute(Stack &stack)\r
1292         {\r
1293         return true;\r
1294         }\r
1295 };\r
1296 \r
1297 class TokFuncSum : public Token\r
1298 {\r
1299 public:\r
1300     TokFuncSum()\r
1301         {\r
1302         type = TOK_FUNC_SUM;\r
1303         }\r
1304     virtual bool execute(Stack &stack)\r
1305         {\r
1306         return true;\r
1307         }\r
1308 };\r
1309 \r
1310 class TokFuncFloor : public Token\r
1311 {\r
1312 public:\r
1313     TokFuncFloor()\r
1314         {\r
1315         type = TOK_FUNC_FLOOR;\r
1316         }\r
1317     virtual bool execute(Stack &stack)\r
1318         {\r
1319         return true;\r
1320         }\r
1321 };\r
1322 \r
1323 class TokFuncCeiling : public Token\r
1324 {\r
1325 public:\r
1326     TokFuncCeiling()\r
1327         {\r
1328         type = TOK_FUNC_CEILING;\r
1329         }\r
1330     virtual bool execute(Stack &stack)\r
1331         {\r
1332         return true;\r
1333         }\r
1334 };\r
1335 \r
1336 class TokFuncRound : public Token\r
1337 {\r
1338 public:\r
1339     TokFuncRound()\r
1340         {\r
1341         type = TOK_FUNC_ROUND;\r
1342         }\r
1343     virtual bool execute(Stack &stack)\r
1344         {\r
1345         return true;\r
1346         }\r
1347 };\r
1348 \r
1349 \r
1350 \r
1351 \r
1352 \r
1353 \r
1354 //########################################################################\r
1355 //# T O K E N    L I S T\r
1356 //########################################################################\r
1357 \r
1358 /**\r
1359  *\r
1360  */\r
1361 class TokenList\r
1362 {\r
1363 public:\r
1364 \r
1365     /**\r
1366      *\r
1367      */\r
1368     TokenList();\r
1369 \r
1370     /**\r
1371      *\r
1372      */\r
1373     TokenList(const TokenList &other);\r
1374 \r
1375     /**\r
1376      *\r
1377      */\r
1378     TokenList &operator=(const TokenList &other);\r
1379 \r
1380     /**\r
1381      *\r
1382      */\r
1383     void assign(const TokenList &other);\r
1384 \r
1385     /**\r
1386      *\r
1387      */\r
1388     virtual ~TokenList();\r
1389 \r
1390     /**\r
1391      *\r
1392      */\r
1393     virtual void clear();\r
1394 \r
1395     /**\r
1396      *\r
1397      */\r
1398     virtual void add(Token *tok);\r
1399 \r
1400     /**\r
1401      *\r
1402      */\r
1403     virtual unsigned int size() const;\r
1404 \r
1405     /**\r
1406      *\r
1407      */\r
1408     virtual void dump();\r
1409 \r
1410 private:\r
1411 \r
1412 \r
1413     std::vector<Token *> tokens;\r
1414 \r
1415 \r
1416 };\r
1417 \r
1418 \r
1419 \r
1420 \r
1421 \r
1422 \r
1423 \r
1424 } // namespace xpath\r
1425 } // namespace dom\r
1426 } // namespace w3c\r
1427 } // namespace org\r
1428 \r
1429 \r
1430 \r
1431 \r
1432 \r
1433 \r
1434 #endif  /* __XPATHTOKEN_H__ */\r
1435 //########################################################################\r
1436 //# E N D    O F    F I L E\r
1437 //########################################################################\r
1438 \r