• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • sources
  • kde-4.14
  • kdelibs
  • khtml
  • xpath
predicate.h
Go to the documentation of this file.
1 /*
2  * predicate.h - Copyright 2005 Frerich Raabe <raabe@kde.org>
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 #ifndef PREDICATE_H
26 #define PREDICATE_H
27 
28 #include "expression.h"
29 
30 namespace khtml {
31 namespace XPath {
32 
33 class Number : public Expression
34 {
35  public:
36  Number( double value );
37 
38  bool isConstant() const;
39  virtual QString dump() const;
40 
41  private:
42  virtual Value doEvaluate() const;
43 
44  double m_value;
45 };
46 
47 class String : public Expression
48 {
49  public:
50  String( const DOM::DOMString &value );
51 
52  bool isConstant() const;
53  virtual QString dump() const;
54 
55  private:
56  virtual Value doEvaluate() const;
57 
58  DOM::DOMString m_value;
59 };
60 
61 class Negative : public Expression
62 {
63  public:
64  virtual QString dump() const;
65 
66  private:
67  virtual Value doEvaluate() const;
68 };
69 
70 class BinaryExprBase : public Expression
71 {
72  public:
73  virtual QString dump() const;
74 
75  protected:
76  virtual QString opName() const = 0;
77 };
78 
79 class NumericOp : public BinaryExprBase
80 {
81  public:
82  enum {
83  OP_Add = 1,
84  OP_Sub,
85  OP_Mul,
86  OP_Div,
87  OP_Mod
88  };
89 
90  NumericOp( int opCode, Expression* lhs, Expression* rhs );
91 
92  private:
93  virtual QString opName() const;
94  virtual Value doEvaluate() const;
95  int opCode;
96 };
97 
98 class RelationOp : public BinaryExprBase
99 {
100  public:
101  enum {
102  OP_GT = 1,
103  OP_LT,
104  OP_GE,
105  OP_LE,
106  OP_EQ,
107  OP_NE
108  };
109 
110  RelationOp( int opCode, Expression* lhs, Expression* rhs );
111 
112  private:
113  virtual QString opName() const;
114  virtual Value doEvaluate() const;
115  int opCode;
116 
117  // compares strings based on the op-code
118  bool compareStrings(const DOM::DOMString& l, const DOM::DOMString& r) const;
119  bool compareNumbers(double l, double r) const;
120 };
121 
122 class LogicalOp : public BinaryExprBase
123 {
124  public:
125  enum {
126  OP_And = 1,
127  OP_Or
128  };
129 
130  LogicalOp( int opCode, Expression* lhs, Expression* rhs );
131 
132  virtual bool isConstant() const;
133 
134  private:
135  bool shortCircuitOn() const;
136  virtual QString opName() const;
137  virtual Value doEvaluate() const;
138  int opCode;
139 };
140 
141 class Union : public BinaryExprBase
142 {
143  private:
144  virtual QString opName() const;
145  virtual Value doEvaluate() const;
146 };
147 
148 class Predicate
149 {
150  public:
151  Predicate( Expression *expr );
152  ~Predicate();
153 
154  bool evaluate() const;
155 
156  void optimize();
157  QString dump() const;
158 
159  private:
160  Predicate( const Predicate &rhs );
161  Predicate &operator=( const Predicate &rhs );
162 
163  Expression *m_expr;
164 };
165 
166 } // namespace XPath
167 
168 } // namespace khtml
169 
170 
171 #endif // PREDICATE_H
172 
173 // kate: indent-width 4; replace-tabs off; tab-width 4; space-indent off;
khtml::XPath::Number
Definition: predicate.h:33
khtml::XPath::NumericOp
Definition: predicate.h:79
khtml::XPath::Number::Number
Number(double value)
Definition: predicate.cpp:42
khtml::XPath::NumericOp::OP_Sub
Definition: predicate.h:84
khtml::XPath::RelationOp::OP_EQ
Definition: predicate.h:106
khtml::XPath::Predicate::optimize
void optimize()
Definition: predicate.cpp:430
khtml::XPath::String::String
String(const DOM::DOMString &value)
Definition: predicate.cpp:62
khtml::XPath::LogicalOp
Definition: predicate.h:122
khtml::XPath::RelationOp::OP_LT
Definition: predicate.h:103
khtml::XPath::Predicate::dump
QString dump() const
Definition: predicate.cpp:435
khtml::XPath::BinaryExprBase::dump
virtual QString dump() const
Definition: predicate.cpp:93
khtml::XPath::RelationOp::OP_LE
Definition: predicate.h:105
khtml::XPath::LogicalOp::OP_And
Definition: predicate.h:126
khtml::XPath::BinaryExprBase
Definition: predicate.h:70
khtml::XPath::Value
Definition: expression.h:75
khtml::XPath::Union
Definition: predicate.h:141
khtml::XPath::Number::isConstant
bool isConstant() const
Definition: predicate.cpp:47
khtml::XPath::Predicate
Definition: predicate.h:148
khtml::XPath::BinaryExprBase::opName
virtual QString opName() const =0
expression.h
khtml::XPath::NumericOp::OP_Div
Definition: predicate.h:86
khtml::XPath::Predicate::evaluate
bool evaluate() const
Definition: predicate.cpp:416
khtml::XPath::RelationOp::RelationOp
RelationOp(int opCode, Expression *lhs, Expression *rhs)
Definition: predicate.cpp:166
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition: dom_string.h:43
khtml::XPath::String::isConstant
bool isConstant() const
Definition: predicate.cpp:67
khtml::XPath::NumericOp::OP_Mul
Definition: predicate.h:85
QString
khtml::XPath::String
Definition: predicate.h:47
khtml::XPath::LogicalOp::LogicalOp
LogicalOp(int opCode, Expression *lhs, Expression *rhs)
Definition: predicate.cpp:335
khtml::XPath::String::dump
virtual QString dump() const
Definition: predicate.cpp:72
khtml::XPath::Predicate::Predicate
Predicate(Expression *expr)
Definition: predicate.cpp:406
khtml::XPath::LogicalOp::isConstant
virtual bool isConstant() const
Definition: predicate.cpp:350
khtml::XPath::NumericOp::NumericOp
NumericOp(int opCode, Expression *lhs, Expression *rhs)
Definition: predicate.cpp:102
khtml::XPath::NumericOp::OP_Mod
Definition: predicate.h:87
khtml::XPath::Negative
Definition: predicate.h:61
khtml::XPath::RelationOp::OP_NE
Definition: predicate.h:107
khtml::XPath::RelationOp
Definition: predicate.h:98
khtml::XPath::LogicalOp::OP_Or
Definition: predicate.h:127
khtml::XPath::Expression
Definition: expression.h:114
khtml::XPath::Negative::dump
virtual QString dump() const
Definition: predicate.cpp:88
khtml::XPath::Number::dump
virtual QString dump() const
Definition: predicate.cpp:52
khtml::XPath::NumericOp::OP_Add
Definition: predicate.h:83
khtml::XPath::Predicate::~Predicate
~Predicate()
Definition: predicate.cpp:411
khtml::XPath::RelationOp::OP_GT
Definition: predicate.h:102
khtml::XPath::RelationOp::OP_GE
Definition: predicate.h:104
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:26:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal