1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
42 #include "qcommonvalues_p.h"
44 #include "qtemplatemode_p.h"
46 #include "qgenericdynamiccontext_p.h"
50 using namespace QPatternist;
52 GenericDynamicContext::GenericDynamicContext(const NamePool::Ptr &np,
53 QAbstractMessageHandler *const errHandler,
54 const LocationHash &locations) : m_messageHandler(errHandler)
55 , m_currentDateTime(QDateTime::currentDateTime().toTimeSpec(Qt::UTC))
58 , m_locations(locations)
61 Q_ASSERT(m_messageHandler);
65 QExplicitlySharedDataPointer<DayTimeDuration> GenericDynamicContext::implicitTimezone() const
67 /* Or what do you prefer, sir? */
68 return CommonValues::DayTimeDurationZero;
71 QAbstractMessageHandler * GenericDynamicContext::messageHandler() const
73 return m_messageHandler;
76 QDateTime GenericDynamicContext::currentDateTime() const
78 return m_currentDateTime;
81 xsInteger GenericDynamicContext::contextPosition() const
83 Q_ASSERT_X(false, Q_FUNC_INFO, "That this function is called makes no sense. A Focus should be used.");
87 Item GenericDynamicContext::contextItem() const
92 xsInteger GenericDynamicContext::contextSize()
94 Q_ASSERT_X(false, Q_FUNC_INFO, "That this function is called makes no sense. A Focus should be used.");
98 void GenericDynamicContext::setFocusIterator(const Item::Iterator::Ptr &)
100 Q_ASSERT_X(false, Q_FUNC_INFO, "That this function is called makes no sense. A Focus should be used.");
103 Item::Iterator::Ptr GenericDynamicContext::focusIterator() const
105 return Item::Iterator::Ptr();
108 QAbstractXmlReceiver *GenericDynamicContext::outputReceiver() const
110 return m_outputReceiver;
113 void GenericDynamicContext::setOutputReceiver(QAbstractXmlReceiver *const receiver)
115 m_outputReceiver = receiver;
118 void GenericDynamicContext::setNodeBuilder(NodeBuilder::Ptr &builder)
120 m_nodeBuilder = builder;
123 NodeBuilder::Ptr GenericDynamicContext::nodeBuilder(const QUrl &baseURI) const
125 return m_nodeBuilder->create(baseURI);
128 ResourceLoader::Ptr GenericDynamicContext::resourceLoader() const
130 return m_resourceLoader;
133 void GenericDynamicContext::setResourceLoader(const ResourceLoader::Ptr &loader)
135 m_resourceLoader = loader;
138 ExternalVariableLoader::Ptr GenericDynamicContext::externalVariableLoader() const
140 return m_externalVariableLoader;
143 void GenericDynamicContext::setExternalVariableLoader(const ExternalVariableLoader::Ptr &loader)
145 m_externalVariableLoader = loader;
148 NamePool::Ptr GenericDynamicContext::namePool() const
153 QSourceLocation GenericDynamicContext::locationFor(const SourceLocationReflection *const reflection) const
156 return m_locations.value(reflection->actualReflection());
159 void GenericDynamicContext::addNodeModel(const QAbstractXmlNodeModel::Ptr &nm)
161 m_nodeModels.append(nm);
164 const QAbstractUriResolver *GenericDynamicContext::uriResolver() const
166 return m_uriResolver;
169 ItemCacheCell &GenericDynamicContext::globalItemCacheCell(const VariableSlotID slot)
171 if(slot >= m_globalItemCacheCells.size())
172 m_globalItemCacheCells.resize(qMax(slot + 1, m_globalItemCacheCells.size()));
174 return m_globalItemCacheCells[slot];
177 ItemSequenceCacheCell::Vector &GenericDynamicContext::globalItemSequenceCacheCells(const VariableSlotID slot)
179 if(slot >= m_globalItemSequenceCacheCells.size())
180 m_globalItemSequenceCacheCells.resize(qMax(slot + 1, m_globalItemSequenceCacheCells.size()));
182 return m_globalItemSequenceCacheCells;
185 void GenericDynamicContext::setUriResolver(const QAbstractUriResolver *const resolver)
187 m_uriResolver = resolver;
190 Item GenericDynamicContext::currentItem() const
195 DynamicContext::Ptr GenericDynamicContext::previousContext() const
197 return DynamicContext::Ptr();
200 QExplicitlySharedDataPointer<TemplateMode> GenericDynamicContext::currentTemplateMode() const
202 return QExplicitlySharedDataPointer<TemplateMode>();