1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
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 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
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_StaticContext_H
|
---|
53 | #define Patternist_StaticContext_H
|
---|
54 |
|
---|
55 | #include "qexternalvariableloader_p.h"
|
---|
56 | #include "qitemtype_p.h"
|
---|
57 | #include "qnamepool_p.h"
|
---|
58 | #include "qnamespaceresolver_p.h"
|
---|
59 | #include "qreportcontext_p.h"
|
---|
60 | #include "qresourceloader_p.h"
|
---|
61 |
|
---|
62 | QT_BEGIN_HEADER
|
---|
63 |
|
---|
64 | QT_BEGIN_NAMESPACE
|
---|
65 |
|
---|
66 | class QUrl;
|
---|
67 | template<typename Key, typename T> class QHash;
|
---|
68 |
|
---|
69 | namespace QPatternist
|
---|
70 | {
|
---|
71 | class DynamicContext;
|
---|
72 | class Expression;
|
---|
73 | class FunctionFactory;
|
---|
74 | class SchemaTypeFactory;
|
---|
75 |
|
---|
76 | /**
|
---|
77 | * @short Carries information and facilities used at compilation time.
|
---|
78 | *
|
---|
79 | * A representation of the Static Context in XPath 2.0. The Static Context
|
---|
80 | * contains information which doesn't change and is the "outer scope" of the
|
---|
81 | * expression. It provides for example a base URI the expression can relate to and
|
---|
82 | * what functions and variables that are available for the expression.
|
---|
83 | *
|
---|
84 | * @see <a href="http://www.w3.org/TR/xpath20/#static_context">XML Path
|
---|
85 | * Language (XPath) 2.0, 2.1.1 Static Context</a>
|
---|
86 | * @author Frans Englich <[email protected]>
|
---|
87 | */
|
---|
88 | class StaticContext : public ReportContext
|
---|
89 | {
|
---|
90 | public:
|
---|
91 | /**
|
---|
92 | * A smart pointer wrapping StaticContext instances.
|
---|
93 | */
|
---|
94 | typedef QExplicitlySharedDataPointer<StaticContext> Ptr;
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * @see <a href="http://www.w3.org/TR/xquery/#id-boundary-space-decls">XQuery 1.0:
|
---|
98 | * An XML Query Language, 4.3 Boundary-space Declaration</a>
|
---|
99 | * @see <a href="http://www.w3.org/TR/xquery/#dt-boundary-space-policy">XQuery 1.0:
|
---|
100 | * An XML Query Language, Definition: Boundary-space policy</a>
|
---|
101 | */
|
---|
102 | enum BoundarySpacePolicy
|
---|
103 | {
|
---|
104 | BSPPreserve,
|
---|
105 | BSPStrip
|
---|
106 | };
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * @see <a href="http://www.w3.org/TR/xquery/#id-construction-declaration">XQuery 1.0:
|
---|
110 | * An XML Query Language, 4.6 Construction Declaration</a>
|
---|
111 | * @see <a href="http://www.w3.org/TR/xquery/#dt-construction-mode">XQuery 1.0:
|
---|
112 | * An XML Query Language, Definition: Construction mode</a>
|
---|
113 | */
|
---|
114 | enum ConstructionMode
|
---|
115 | {
|
---|
116 | CMPreserve,
|
---|
117 | CMStrip
|
---|
118 | };
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * @see <a href="http://www.w3.org/TR/xquery/#id-default-ordering-decl">XQuery 1.0:
|
---|
122 | * An XML Query Language, 4.7 Ordering Mode Declaration</a>
|
---|
123 | * @see <a href="http://www.w3.org/TR/xquery/#dt-ordering-mode">XQuery 1.0:
|
---|
124 | * An XML Query Language, Definition: Ordering mode</a>
|
---|
125 | */
|
---|
126 | enum OrderingMode
|
---|
127 | {
|
---|
128 | Ordered,
|
---|
129 | Unordered
|
---|
130 | };
|
---|
131 |
|
---|
132 | /**
|
---|
133 | * @see <a href="http://www.w3.org/TR/xquery/#id-empty-order-decl">XQuery 1.0:
|
---|
134 | * An XML Query Language, 4.8 Empty Order Declaration</a>
|
---|
135 | * @see <a href="http://www.w3.org/TR/xquery/#dt-default-empty-order">XQuery 1.0:
|
---|
136 | * An XML Query Language, Definition: Default order for empty sequences</a>
|
---|
137 | */
|
---|
138 | enum OrderingEmptySequence
|
---|
139 | {
|
---|
140 | Greatest,
|
---|
141 | Least
|
---|
142 | };
|
---|
143 |
|
---|
144 | enum InheritMode
|
---|
145 | {
|
---|
146 | Inherit,
|
---|
147 | NoInherit
|
---|
148 | };
|
---|
149 |
|
---|
150 | enum PreserveMode
|
---|
151 | {
|
---|
152 | Preserve,
|
---|
153 | NoPreserve
|
---|
154 | };
|
---|
155 |
|
---|
156 | inline StaticContext()
|
---|
157 | {
|
---|
158 | }
|
---|
159 |
|
---|
160 | virtual ~StaticContext();
|
---|
161 |
|
---|
162 | virtual NamespaceResolver::Ptr namespaceBindings() const = 0;
|
---|
163 | virtual void setNamespaceBindings(const NamespaceResolver::Ptr &) = 0;
|
---|
164 | virtual QExplicitlySharedDataPointer<FunctionFactory> functionSignatures() const = 0;
|
---|
165 | virtual QExplicitlySharedDataPointer<SchemaTypeFactory> schemaDefinitions() const = 0;
|
---|
166 |
|
---|
167 | /**
|
---|
168 | * The base URI of the context. Typically, this is the base URI
|
---|
169 | * if of the element that contained the expression.
|
---|
170 | *
|
---|
171 | * The base URI is in this implementation is never undefined, but is
|
---|
172 | * always valid.
|
---|
173 | */
|
---|
174 | virtual QUrl baseURI() const = 0;
|
---|
175 |
|
---|
176 | virtual void setBaseURI(const QUrl &uri) = 0;
|
---|
177 |
|
---|
178 | /**
|
---|
179 | * @returns always the standard function namespace defined in
|
---|
180 | * <a href="http://www.w3.org/TR/xpath-functions/">XQuery 1.0 and
|
---|
181 | * XPath 2.0 Functions and Operators</a>
|
---|
182 | */
|
---|
183 | virtual QString defaultFunctionNamespace() const = 0;
|
---|
184 | virtual void setDefaultFunctionNamespace(const QString &ns) = 0;
|
---|
185 |
|
---|
186 | virtual QString defaultElementNamespace() const = 0;
|
---|
187 | virtual void setDefaultElementNamespace(const QString &ns) = 0;
|
---|
188 |
|
---|
189 | /**
|
---|
190 | * @returns the URI identifying the default collation. The function
|
---|
191 | * is responsible for ensuring a collation is always returned. If
|
---|
192 | * a collation is not provided by the user or the host language in the
|
---|
193 | * context, the Unicode codepoint URI should be returned.
|
---|
194 | */
|
---|
195 | virtual QUrl defaultCollation() const = 0;
|
---|
196 |
|
---|
197 | virtual void setDefaultCollation(const QUrl &uri) = 0;
|
---|
198 |
|
---|
199 | /**
|
---|
200 | * Determine whether Backwards Compatible Mode is used.
|
---|
201 | *
|
---|
202 | * @see <a href="http://www.w3.org/TR/xpath20/#id-backwards-compatibility">XML Path
|
---|
203 | * Language (XPath) 2.0, I Backwards Compatibility with XPath 1.0 (Non-Normative)</a>
|
---|
204 | * @see <a href="http://www.w3.org/TR/xpath20/#dt-xpath-compat-mode">XML Path
|
---|
205 | * Language (XPath) 2.0, Definition: XPath 1.0 compatibility mode</a>
|
---|
206 | */
|
---|
207 | virtual bool compatModeEnabled() const = 0;
|
---|
208 |
|
---|
209 | virtual void setCompatModeEnabled(const bool newVal) = 0;
|
---|
210 |
|
---|
211 | /**
|
---|
212 | * This is the DynamicContext that is used for pre-evaluation at
|
---|
213 | * compilation time, const-folding at the static stage.
|
---|
214 | */
|
---|
215 | virtual QExplicitlySharedDataPointer<DynamicContext> dynamicContext() const = 0;
|
---|
216 |
|
---|
217 | virtual BoundarySpacePolicy boundarySpacePolicy() const = 0;
|
---|
218 | virtual void setBoundarySpacePolicy(const BoundarySpacePolicy policy) = 0;
|
---|
219 |
|
---|
220 | virtual ConstructionMode constructionMode() const = 0;
|
---|
221 | virtual void setConstructionMode(const ConstructionMode mode) = 0;
|
---|
222 |
|
---|
223 | virtual OrderingMode orderingMode() const = 0;
|
---|
224 | virtual void setOrderingMode(const OrderingMode mode) = 0;
|
---|
225 | virtual OrderingEmptySequence orderingEmptySequence() const = 0;
|
---|
226 | virtual void setOrderingEmptySequence(const OrderingEmptySequence ordering) = 0;
|
---|
227 |
|
---|
228 | virtual InheritMode inheritMode() const = 0;
|
---|
229 | virtual void setInheritMode(const InheritMode mode) = 0;
|
---|
230 |
|
---|
231 | virtual PreserveMode preserveMode() const = 0;
|
---|
232 | virtual void setPreserveMode(const PreserveMode mode) = 0;
|
---|
233 |
|
---|
234 | /**
|
---|
235 | * @short The static type of the context item.
|
---|
236 | *
|
---|
237 | * Different StaticContext instances are used for different nodes in the
|
---|
238 | * AST to properly reflect the type of the focus. If the focus is undefined,
|
---|
239 | * this function must return @c null.
|
---|
240 | *
|
---|
241 | * @see <a href="http://www.w3.org/TR/xquery/#dt-context-item-static-type">XQuery
|
---|
242 | * 1.0: An XML Query Language, Definition: Context item static type</a>
|
---|
243 | */
|
---|
244 | virtual ItemType::Ptr contextItemType() const = 0;
|
---|
245 |
|
---|
246 | /**
|
---|
247 | * @short The static type of the current item, as returned by @c
|
---|
248 | * fn:current().
|
---|
249 | */
|
---|
250 | virtual ItemType::Ptr currentItemType() const = 0;
|
---|
251 |
|
---|
252 | /**
|
---|
253 | * Copies this StaticContext and returns the copy.
|
---|
254 | *
|
---|
255 | * The copy and original must not be independent. Since the StaticContext is modified
|
---|
256 | * during the compilation process, the copy must be independent from the original
|
---|
257 | * to the degree that is required for the subclass in question.
|
---|
258 | */
|
---|
259 | virtual StaticContext::Ptr copy() const = 0;
|
---|
260 |
|
---|
261 | virtual ExternalVariableLoader::Ptr externalVariableLoader() const = 0;
|
---|
262 | virtual ResourceLoader::Ptr resourceLoader() const = 0;
|
---|
263 | virtual NamePool::Ptr namePool() const = 0;
|
---|
264 |
|
---|
265 | /**
|
---|
266 | * @short Adds @p location for @p reflection.
|
---|
267 | */
|
---|
268 | virtual void addLocation(const SourceLocationReflection *const reflection,
|
---|
269 | const QSourceLocation &location) = 0;
|
---|
270 |
|
---|
271 | /**
|
---|
272 | * @short Returns a hash of the contained locations.
|
---|
273 | *
|
---|
274 | * The key is the address for the expression, and the value is its location. Note
|
---|
275 | * that the key cannot be dereferenced, there's no guarantee the
|
---|
276 | * Expression is in scope. The key is merely an identifier.
|
---|
277 | */
|
---|
278 | virtual LocationHash sourceLocations() const = 0;
|
---|
279 |
|
---|
280 | virtual VariableSlotID currentRangeSlot() const = 0;
|
---|
281 | virtual VariableSlotID allocateRangeSlot() = 0;
|
---|
282 |
|
---|
283 | /**
|
---|
284 | * @short Ensures source locations are handled in such a manner that @p
|
---|
285 | * existingNode wraps @p newNode.
|
---|
286 | *
|
---|
287 | * Ensures that the source locations for @p existingNode, applies to
|
---|
288 | * @p newNode.
|
---|
289 | */
|
---|
290 | void wrapExpressionWith(const SourceLocationReflection *const existingNode,
|
---|
291 | const QExplicitlySharedDataPointer<Expression> &newNode);
|
---|
292 | };
|
---|
293 | }
|
---|
294 |
|
---|
295 | QT_END_NAMESPACE
|
---|
296 |
|
---|
297 | QT_END_HEADER
|
---|
298 |
|
---|
299 | #endif
|
---|