Qt 4.8
qgenericstaticcontext.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 /* Patternist */
43 #include "qbasictypesfactory_p.h"
44 #include "qcommonnamespaces_p.h"
48 
50 
52 
53 using namespace QPatternist;
54 
57  const QUrl &aBaseURI,
58  const FunctionFactory::Ptr &factory,
59  const QXmlQuery::QueryLanguage lang) : m_boundarySpacePolicy(BSPStrip)
60  , m_constructionMode(CMPreserve)
61  , m_functionFactory(factory)
62  , m_defaultFunctionNamespace(CommonNamespaces::XFN)
63  , m_orderingEmptySequence(Greatest)
64  , m_orderingMode(Ordered)
65  , m_defaultCollation(QUrl::fromEncoded(CommonNamespaces::UNICODE_COLLATION))
66  , m_baseURI(aBaseURI)
67  , m_messageHandler(handler)
68  , m_preserveMode(Preserve)
69  , m_inheritMode(Inherit)
70  , m_namespaceResolver(lang == QXmlQuery::XQuery10
71  ? GenericNamespaceResolver::defaultXQueryBindings()
72  : GenericNamespaceResolver::defaultXSLTBindings())
73  , m_namePool(np)
74  , m_uriResolver(0)
75  , m_queryLanguage(lang)
76  , m_rangeSlot(-1)
77  , m_compatModeEnabled(false)
78 {
79  /* We'll easily have at least this many AST nodes, that we need
80  * to track locations for. */
81  m_locations.reserve(30);
82 
83  Q_ASSERT(np);
85 }
86 
88 {
89  return m_namespaceResolver;
90 }
91 
93 {
94  return m_functionFactory;
95 }
96 
98 {
100  // TODO we have many bugs here..
101  context->setResourceLoader(m_resourceLoader);
102  return context;
103 }
104 
106 {
108 }
109 
111 {
113  "The static base-uri must be absolute. This error is most likely caused by misuing the API.");
114  return m_baseURI;
115 }
116 
118 {
119  Q_ASSERT(!uri.isRelative());
120  m_baseURI = uri;
121 }
122 
124 {
125  return m_compatModeEnabled;
126 }
127 
129 {
130  m_compatModeEnabled = newVal;
131 }
132 
134 {
135  return m_defaultCollation;
136 }
137 
139 {
140  return m_messageHandler;
141 }
142 
144 {
145  m_defaultCollation = uri;
146 }
147 
149 {
150  Q_ASSERT(resolver);
151  m_namespaceResolver = resolver;
152 }
153 
155 {
156  return m_boundarySpacePolicy;
157 }
158 
160 {
161  Q_ASSERT(policy == BSPPreserve || policy == BSPStrip);
162  m_boundarySpacePolicy = policy;
163 }
164 
166 {
167  return m_constructionMode;
168 }
169 
171 {
172  Q_ASSERT(mode == CMPreserve || mode == CMStrip);
173  m_constructionMode = mode;
174 }
175 
177 {
178  return m_orderingMode;
179 }
180 
182 {
183  Q_ASSERT(mode == Ordered || mode == Unordered);
184  m_orderingMode = mode;
185 }
186 
188 {
190 }
191 
193 {
194  Q_ASSERT(ordering == Greatest || ordering == Least);
195  m_orderingEmptySequence = ordering;
196 }
197 
199 {
201 }
202 
204 {
206 }
207 
208 
210 {
212 }
213 
215 {
217 }
218 
220 {
221  return m_inheritMode;
222 }
223 
225 {
226  Q_ASSERT(mode == Inherit || mode == NoInherit);
227  m_inheritMode = mode;
228 }
229 
231 {
232  return m_preserveMode;
233 }
234 
236 {
237  Q_ASSERT(mode == Preserve || mode == NoPreserve);
238  m_preserveMode = mode;
239 }
240 
242 {
243  return m_contextItemType;
244 }
245 
247 {
248  return contextItemType();
249 }
250 
252 {
254 }
255 
257 {
260 
261  retval->setNamespaceBindings(newSolver);
268  retval->setInheritMode(m_inheritMode);
273  retval->m_locations = m_locations;
274 
275  return StaticContext::Ptr(retval);
276 }
277 
279 {
280  return m_resourceLoader;
281 }
282 
284 {
285  m_resourceLoader = loader;
286 }
287 
289 {
291 }
292 
294 {
295  m_externalVariableLoader = loader;
296 }
297 
299 {
300  return m_namePool;
301 }
302 
304  const QSourceLocation &location)
305 {
306  Q_ASSERT(!location.isNull());
307  Q_ASSERT_X(reflection, Q_FUNC_INFO,
308  "The reflection cannot be zero.");
309  m_locations.insert(reflection, location);
310 }
311 
313 {
314  return m_locations;
315 }
316 
318 {
319  return m_locations.value(reflection->actualReflection());
320 }
321 
323 {
324  return m_uriResolver;
325 }
326 
328 {
329  return m_rangeSlot;
330 }
331 
333 {
334  ++m_rangeSlot;
335  return m_rangeSlot;
336 }
337 
qint32 VariableSlotID
A DynamicContext supplying basic information that always is used.
void setResourceLoader(const ResourceLoader::Ptr &loader)
virtual SchemaTypeFactory::Ptr schemaDefinitions() const
virtual QString defaultElementNamespace() const
static SchemaTypeFactory::Ptr self(const NamePool::Ptr &np)
virtual StaticContext::Ptr copy() const
int type
Definition: qmetatype.cpp:239
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
virtual void setBaseURI(const QUrl &uri)
void setExternalVariableLoader(const ExternalVariableLoader::Ptr &loader)
virtual FunctionFactory::Ptr functionSignatures() const
virtual ItemType::Ptr contextItemType() const
The static type of the context item.
QueryLanguage
Specifies whether you want QXmlQuery to interpret the input to setQuery() as an XQuery or as an XSLT ...
Definition: qxmlquery.h:82
virtual QAbstractUriResolver * uriResolver() const
The URI resolver in use.
virtual OrderingEmptySequence orderingEmptySequence() const
virtual const SourceLocationReflection * actualReflection() const =0
virtual void setInheritMode(const InheritMode mode)
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
QAbstractMessageHandler * m_messageHandler
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual ConstructionMode constructionMode() const
virtual void addLocation(const SourceLocationReflection *const reflection, const QSourceLocation &location)
Adds location for reflection.
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
Definition: qurl.cpp:5880
virtual void setPreserveMode(const PreserveMode mode)
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
virtual VariableSlotID currentRangeSlot() const
void reserve(int size)
Ensures that the QHash's internal hash table consists of at least size buckets.
Definition: qhash.h:846
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
virtual DynamicContext::Ptr dynamicContext() const
virtual ItemType::Ptr currentItemType() const
The static type of the current item, as returned by fn:current().
virtual BoundarySpacePolicy boundarySpacePolicy() const
bool isNull() const
Returns true if this QSourceLocation doesn't identify anything.
virtual OrderingMode orderingMode() const
virtual void setOrderingEmptySequence(const OrderingEmptySequence ordering)
virtual NamePool::Ptr namePool() const
The QAbstractUriResolver class is a callback interface for resolving Uniform Resource Identifiers...
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
virtual InheritMode inheritMode() const
const QLatin1String XFN("http://www.w3.org/2005/xpath-functions")
The namespace for the internal API of QtXmlPatterns.
The QSourceLocation class identifies a location in a resource by URI, line, and column.
virtual LocationHash sourceLocations() const
Returns a hash of the contained locations.
virtual VariableSlotID allocateRangeSlot()
virtual QString defaultFunctionNamespace() const
virtual QSourceLocation locationFor(const SourceLocationReflection *const reflection) const
Returns the source location applying for reflection.
virtual PreserveMode preserveMode() const
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
void setContextItemType(const ItemType::Ptr &type)
The QAbstractMessageHandler class provides a callback interface for handling messages.
virtual ResourceLoader::Ptr resourceLoader() const
ExternalVariableLoader::Ptr m_externalVariableLoader
GenericStaticContext(const NamePool::Ptr &np, QAbstractMessageHandler *const errorHandler, const QUrl &aBaseURI, const FunctionFactory::Ptr &factory, const QXmlQuery::QueryLanguage lang)
static QTestResult::TestLocation location
Definition: qtestresult.cpp:63
virtual void setConstructionMode(const ConstructionMode mode)
virtual void setDefaultCollation(const QUrl &uri)
virtual QAbstractMessageHandler * messageHandler() const
virtual void setBoundarySpacePolicy(const BoundarySpacePolicy policy)
virtual void setNamespaceBindings(const NamespaceResolver::Ptr &)
virtual ExternalVariableLoader::Ptr externalVariableLoader() const
Generic namespace resolver which resolves lookups against entries in a QHash.
virtual void setDefaultElementNamespace(const QString &ns)
virtual Bindings bindings() const =0
QExplicitlySharedDataPointer< StaticContext > Ptr
virtual void setOrderingMode(const OrderingMode mode)
QImageIOHandler * handler
virtual void setDefaultFunctionNamespace(const QString &ns)
virtual NamespaceResolver::Ptr namespaceBindings() const
The QXmlQuery class performs XQueries on XML data, or on non-XML data modeled to look like XML...
Definition: qxmlquery.h:79
virtual void setCompatModeEnabled(const bool newVal)
Base class for all instances that represents something at a certain location.
Provides setters and getters for the properties defined in StaticContext.
#define Q_FUNC_INFO
Definition: qglobal.h:1871