1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
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 The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/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 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #include "qcommonvalues_p.h" |
41 | #include "qfocus_p.h" |
42 | #include "qtemplatemode_p.h" |
43 | |
44 | #include "qgenericdynamiccontext_p.h" |
45 | |
46 | QT_BEGIN_NAMESPACE |
47 | |
48 | using namespace QPatternist; |
49 | |
50 | GenericDynamicContext::GenericDynamicContext(const NamePool::Ptr &np, |
51 | QAbstractMessageHandler *const errHandler, |
52 | const LocationHash &locations) : m_messageHandler(errHandler) |
53 | , m_currentDateTime(QDateTime::currentDateTime().toTimeSpec(spec: Qt::UTC)) |
54 | , m_outputReceiver(0) |
55 | , m_namePool(np) |
56 | , m_locations(locations) |
57 | , m_uriResolver(0) |
58 | { |
59 | Q_ASSERT(m_messageHandler); |
60 | Q_ASSERT(m_namePool); |
61 | } |
62 | |
63 | QExplicitlySharedDataPointer<DayTimeDuration> GenericDynamicContext::implicitTimezone() const |
64 | { |
65 | /* Or what do you prefer, sir? */ |
66 | return CommonValues::DayTimeDurationZero; |
67 | } |
68 | |
69 | QAbstractMessageHandler * GenericDynamicContext::messageHandler() const |
70 | { |
71 | return m_messageHandler; |
72 | } |
73 | |
74 | QDateTime GenericDynamicContext::currentDateTime() const |
75 | { |
76 | return m_currentDateTime; |
77 | } |
78 | |
79 | xsInteger GenericDynamicContext::contextPosition() const |
80 | { |
81 | Q_ASSERT_X(false, Q_FUNC_INFO, "That this function is called makes no sense. A Focus should be used." ); |
82 | return 0; |
83 | } |
84 | |
85 | Item GenericDynamicContext::contextItem() const |
86 | { |
87 | return Item(); |
88 | } |
89 | |
90 | xsInteger GenericDynamicContext::contextSize() |
91 | { |
92 | Q_ASSERT_X(false, Q_FUNC_INFO, "That this function is called makes no sense. A Focus should be used." ); |
93 | return 0; |
94 | } |
95 | |
96 | void GenericDynamicContext::setFocusIterator(const Item::Iterator::Ptr &) |
97 | { |
98 | Q_ASSERT_X(false, Q_FUNC_INFO, "That this function is called makes no sense. A Focus should be used." ); |
99 | } |
100 | |
101 | Item::Iterator::Ptr GenericDynamicContext::focusIterator() const |
102 | { |
103 | return Item::Iterator::Ptr(); |
104 | } |
105 | |
106 | QAbstractXmlReceiver *GenericDynamicContext::outputReceiver() const |
107 | { |
108 | return m_outputReceiver; |
109 | } |
110 | |
111 | void GenericDynamicContext::setOutputReceiver(QAbstractXmlReceiver *const receiver) |
112 | { |
113 | m_outputReceiver = receiver; |
114 | } |
115 | |
116 | void GenericDynamicContext::setNodeBuilder(NodeBuilder::Ptr &builder) |
117 | { |
118 | m_nodeBuilder = builder; |
119 | } |
120 | |
121 | NodeBuilder::Ptr GenericDynamicContext::nodeBuilder(const QUrl &baseURI) const |
122 | { |
123 | return m_nodeBuilder->create(baseURI); |
124 | } |
125 | |
126 | ResourceLoader::Ptr GenericDynamicContext::resourceLoader() const |
127 | { |
128 | return m_resourceLoader; |
129 | } |
130 | |
131 | void GenericDynamicContext::setResourceLoader(const ResourceLoader::Ptr &loader) |
132 | { |
133 | m_resourceLoader = loader; |
134 | } |
135 | |
136 | ExternalVariableLoader::Ptr GenericDynamicContext::externalVariableLoader() const |
137 | { |
138 | return m_externalVariableLoader; |
139 | } |
140 | |
141 | void GenericDynamicContext::setExternalVariableLoader(const ExternalVariableLoader::Ptr &loader) |
142 | { |
143 | m_externalVariableLoader = loader; |
144 | } |
145 | |
146 | NamePool::Ptr GenericDynamicContext::namePool() const |
147 | { |
148 | return m_namePool; |
149 | } |
150 | |
151 | QSourceLocation GenericDynamicContext::locationFor(const SourceLocationReflection *const reflection) const |
152 | { |
153 | |
154 | return m_locations.value(akey: reflection->actualReflection()); |
155 | } |
156 | |
157 | void GenericDynamicContext::addNodeModel(const QAbstractXmlNodeModel::Ptr &nm) |
158 | { |
159 | m_nodeModels.append(t: nm); |
160 | } |
161 | |
162 | const QAbstractUriResolver *GenericDynamicContext::uriResolver() const |
163 | { |
164 | return m_uriResolver; |
165 | } |
166 | |
167 | ItemCacheCell &GenericDynamicContext::globalItemCacheCell(const VariableSlotID slot) |
168 | { |
169 | if(slot >= m_globalItemCacheCells.size()) |
170 | m_globalItemCacheCells.resize(asize: qMax(a: slot + 1, b: m_globalItemCacheCells.size())); |
171 | |
172 | return m_globalItemCacheCells[slot]; |
173 | } |
174 | |
175 | ItemSequenceCacheCell::Vector &GenericDynamicContext::globalItemSequenceCacheCells(const VariableSlotID slot) |
176 | { |
177 | if(slot >= m_globalItemSequenceCacheCells.size()) |
178 | m_globalItemSequenceCacheCells.resize(asize: qMax(a: slot + 1, b: m_globalItemSequenceCacheCells.size())); |
179 | |
180 | return m_globalItemSequenceCacheCells; |
181 | } |
182 | |
183 | void GenericDynamicContext::setUriResolver(const QAbstractUriResolver *const resolver) |
184 | { |
185 | m_uriResolver = resolver; |
186 | } |
187 | |
188 | Item GenericDynamicContext::currentItem() const |
189 | { |
190 | return Item(); |
191 | } |
192 | |
193 | DynamicContext::Ptr GenericDynamicContext::previousContext() const |
194 | { |
195 | return DynamicContext::Ptr(); |
196 | } |
197 | |
198 | QExplicitlySharedDataPointer<TemplateMode> GenericDynamicContext::currentTemplateMode() const |
199 | { |
200 | return QExplicitlySharedDataPointer<TemplateMode>(); |
201 | } |
202 | |
203 | QT_END_NAMESPACE |
204 | |