• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2005 Frerich Raabe <raabe@kde.org>
3  * Copyright (C) 2006 Apple Computer, Inc.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #ifndef XPathPredicate_h
28 #define XPathPredicate_h
29 
30 #if ENABLE(XPATH)
31 
32 #include "XPathExpressionNode.h"
33 #include "XPathValue.h"
34 
35 namespace WebCore {
36 
37     namespace XPath {
38 
39         class Number : public Expression {
40         public:
41             Number(double);
42         private:
43             virtual Value evaluate() const;
44             Value m_value;
45         };
46 
47         class StringExpression : public Expression {
48         public:
49             StringExpression(const String&);
50         private:
51             virtual Value evaluate() const;
52             Value m_value;
53         };
54 
55         class Negative : public Expression {
56         private:
57             virtual Value evaluate() const;
58         };
59 
60         class NumericOp : public Expression {
61         public:
62             enum Opcode {
63                 OP_Add, OP_Sub, OP_Mul, OP_Div, OP_Mod
64             };
65             NumericOp(Opcode, Expression* lhs, Expression* rhs);
66         private:
67             virtual Value evaluate() const;
68             Opcode m_opcode;
69         };
70 
71         class EqTestOp : public Expression {
72         public:
73             enum Opcode { OP_EQ, OP_NE, OP_GT, OP_LT, OP_GE, OP_LE };
74             EqTestOp(Opcode, Expression* lhs, Expression* rhs);
75             virtual Value evaluate() const;
76         private:
77             bool compare(const Value&, const Value&) const;
78             Opcode m_opcode;
79         };
80 
81         class LogicalOp : public Expression {
82         public:
83             enum Opcode { OP_And, OP_Or };
84             LogicalOp(Opcode, Expression* lhs, Expression* rhs);
85         private:
86             bool shortCircuitOn() const;
87             virtual Value evaluate() const;
88             Opcode m_opcode;
89         };
90 
91         class Union : public Expression {
92         private:
93             virtual Value evaluate() const;
94         };
95 
96         class Predicate : Noncopyable {
97         public:
98             Predicate(Expression*);
99             ~Predicate();
100             bool evaluate() const;
101         private:
102             Expression* m_expr;
103         };
104 
105     }
106 
107 }
108 
109 #endif // ENABLE(XPATH)
110 
111 #endif // XPathPredicate_h
112