1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
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>();