0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the QtXmlPatterns module of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
//
|
|
43 |
// W A R N I N G
|
|
44 |
// -------------
|
|
45 |
//
|
|
46 |
// This file is not part of the Qt API. It exists purely as an
|
|
47 |
// implementation detail. This header file may change from version to
|
|
48 |
// version without notice, or even be removed.
|
|
49 |
//
|
|
50 |
// We mean it.
|
|
51 |
|
|
52 |
#ifndef Patternist_OptimizerBlocks_H
|
|
53 |
#define Patternist_OptimizerBlocks_H
|
|
54 |
|
|
55 |
#include "qatomiccomparator_p.h"
|
|
56 |
#include "qexpression_p.h"
|
|
57 |
#include "qoptimizerframework_p.h"
|
|
58 |
|
|
59 |
QT_BEGIN_HEADER
|
|
60 |
|
|
61 |
QT_BEGIN_NAMESPACE
|
|
62 |
|
|
63 |
namespace QPatternist
|
|
64 |
{
|
|
65 |
/**
|
|
66 |
* @short Identifies Expression instances by their Expression::id().
|
|
67 |
*
|
|
68 |
* @author Frans englich <frans.englich@nokia.com>
|
|
69 |
* @ingroup Patternist_expressions
|
|
70 |
*/
|
|
71 |
class ByIDIdentifier : public ExpressionIdentifier
|
|
72 |
{
|
|
73 |
public:
|
|
74 |
ByIDIdentifier(const Expression::ID id);
|
|
75 |
virtual bool matches(const Expression::Ptr &expr) const;
|
|
76 |
private:
|
|
77 |
const Expression::ID m_id;
|
|
78 |
};
|
|
79 |
|
|
80 |
/**
|
|
81 |
* @short Identifies Expression instances based on their static type.
|
|
82 |
*
|
|
83 |
* BySequenceTypeIdentifier identifies Expression instances
|
|
84 |
* if their Expression::staticType() matches the requested one,
|
|
85 |
* regardless of whether the Expression is a particular one, such
|
|
86 |
* as AndExpression.
|
|
87 |
*
|
|
88 |
* For example, constructing a BySequenceTypeIdentifier while
|
|
89 |
* passing CommonSequenceTypes::EBV in its constructor will create
|
|
90 |
* a ExpressionIdentifier that returns @c true for a static type with
|
|
91 |
* item type <tt>xs:string</tt>, but returns @c false for a static type involving
|
|
92 |
* <tt>xs:date</tt>.
|
|
93 |
*
|
|
94 |
* @author Frans englich <frans.englich@nokia.com>
|
|
95 |
* @ingroup Patternist_expressions
|
|
96 |
*/
|
|
97 |
class BySequenceTypeIdentifier : public ExpressionIdentifier
|
|
98 |
{
|
|
99 |
public:
|
|
100 |
BySequenceTypeIdentifier(const SequenceType::Ptr &seqType);
|
|
101 |
|
|
102 |
/**
|
|
103 |
* @returns @c true, if the static type of @p expr is matches
|
|
104 |
* the SequenceType passed in the BySequenceTypeIdentifier()
|
|
105 |
* constructor, otherwise @c false.
|
|
106 |
*/
|
|
107 |
virtual bool matches(const Expression::Ptr &expr) const;
|
|
108 |
|
|
109 |
private:
|
|
110 |
const SequenceType::Ptr m_seqType;
|
|
111 |
};
|
|
112 |
|
|
113 |
/**
|
|
114 |
* @short Determines whether an Expression is a value or general comparison or both,
|
|
115 |
* with a certain operator.
|
|
116 |
*
|
|
117 |
* @author Frans englich <frans.englich@nokia.com>
|
|
118 |
* @ingroup Patternist_expressions
|
|
119 |
*/
|
|
120 |
class ComparisonIdentifier : public ExpressionIdentifier
|
|
121 |
{
|
|
122 |
public:
|
|
123 |
|
|
124 |
/**
|
|
125 |
* @param comparatorHosts the possible parent that may have
|
|
126 |
* the operator. This may be Expression::IDGeneralComparison or
|
|
127 |
* Expression::IDValueComparison. The two values may also be OR'd,
|
|
128 |
* meaning any of them will do.
|
|
129 |
*
|
|
130 |
* @param op the operator that the comparator host must have. For example,
|
|
131 |
* if @p op is AtomicComparator::OperatorGreatorOrEqual this ComparisonIdentifier
|
|
132 |
* will match operator >= in the case of IDGeneralComparison and 'ge' in the
|
|
133 |
* case of IDValueComparison.
|
|
134 |
*/
|
|
135 |
ComparisonIdentifier(const QVector<Expression::ID> comparatorHosts,
|
|
136 |
const AtomicComparator::Operator op);
|
|
137 |
|
|
138 |
/**
|
|
139 |
* @returns @c true, if @p expr is a ValueComparison with the operator
|
|
140 |
* passed in ComparisonIdentifier().
|
|
141 |
*/
|
|
142 |
virtual bool matches(const Expression::Ptr &expr) const;
|
|
143 |
|
|
144 |
private:
|
|
145 |
const QVector<Expression::ID> m_hosts;
|
|
146 |
const AtomicComparator::Operator m_op;
|
|
147 |
};
|
|
148 |
|
|
149 |
/**
|
|
150 |
* @short Matches numeric literals that are of type xs:integer and
|
|
151 |
* has a specific value.
|
|
152 |
*
|
|
153 |
* For example IntegerIdentifier(4) would match the former but
|
|
154 |
* not the latter operand in this expression: "4 + 5".
|
|
155 |
*
|
|
156 |
* @author Frans englich <frans.englich@nokia.com>
|
|
157 |
* @ingroup Patternist_expressions
|
|
158 |
*/
|
|
159 |
class IntegerIdentifier : public ExpressionIdentifier
|
|
160 |
{
|
|
161 |
public:
|
|
162 |
IntegerIdentifier(const xsInteger num);
|
|
163 |
virtual bool matches(const Expression::Ptr &expr) const;
|
|
164 |
|
|
165 |
private:
|
|
166 |
const xsInteger m_num;
|
|
167 |
};
|
|
168 |
|
|
169 |
/**
|
|
170 |
* @short Matches boolean literals.
|
|
171 |
*
|
|
172 |
* For example BooleanIdentifier(true) would match the former but
|
|
173 |
* not the latter operand in this expression: "true() + false()".
|
|
174 |
*
|
|
175 |
* @author Frans englich <frans.englich@nokia.com>
|
|
176 |
* @ingroup Patternist_expressions
|
|
177 |
*/
|
|
178 |
class BooleanIdentifier : public ExpressionIdentifier
|
|
179 |
{
|
|
180 |
public:
|
|
181 |
BooleanIdentifier(const bool value);
|
|
182 |
virtual bool matches(const Expression::Ptr &expr) const;
|
|
183 |
|
|
184 |
private:
|
|
185 |
const bool m_value;
|
|
186 |
};
|
|
187 |
|
|
188 |
/**
|
|
189 |
* @short Creates a particular Expression instance identified by an Expression::ID.
|
|
190 |
*
|
|
191 |
* For example, if ByIDCreator() is passed Expression::IDCountFN, create()
|
|
192 |
* will return CountFN instances.
|
|
193 |
*
|
|
194 |
* @author Frans englich <frans.englich@nokia.com>
|
|
195 |
* @ingroup Patternist_expressions
|
|
196 |
*/
|
|
197 |
class ByIDCreator : public ExpressionCreator
|
|
198 |
{
|
|
199 |
public:
|
|
200 |
/**
|
|
201 |
* Creates a ByIDCreator that creates expressions
|
|
202 |
* of the type that @p id identifies.
|
|
203 |
*/
|
|
204 |
ByIDCreator(const Expression::ID id);
|
|
205 |
virtual Expression::Ptr create(const Expression::List &operands,
|
|
206 |
const StaticContext::Ptr &context,
|
|
207 |
const SourceLocationReflection *const r) const;
|
|
208 |
|
|
209 |
/**
|
|
210 |
* Creates an expression by id @p id with the arguments @p operands.
|
|
211 |
*/
|
|
212 |
static Expression::Ptr create(const Expression::ID id,
|
|
213 |
const Expression::List &operands,
|
|
214 |
const StaticContext::Ptr &context,
|
|
215 |
const SourceLocationReflection *const r);
|
|
216 |
|
|
217 |
private:
|
|
218 |
const Expression::ID m_id;
|
|
219 |
};
|
|
220 |
}
|
|
221 |
|
|
222 |
QT_END_NAMESPACE
|
|
223 |
|
|
224 |
QT_END_HEADER
|
|
225 |
|
|
226 |
#endif
|