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 | // |
41 | // W A R N I N G |
42 | // ------------- |
43 | // |
44 | // This file is not part of the Qt API. It exists purely as an |
45 | // implementation detail. This header file may change from version to |
46 | // version without notice, or even be removed. |
47 | // |
48 | // We mean it. |
49 | |
50 | #ifndef Patternist_DateTimeFNs_H |
51 | #define Patternist_DateTimeFNs_H |
52 | |
53 | #include <private/qatomiccomparator_p.h> |
54 | #include <private/qcommonvalues_p.h> |
55 | #include <private/qschemadatetime_p.h> |
56 | #include <private/qdaytimeduration_p.h> |
57 | #include <private/qdecimal_p.h> |
58 | #include <private/qinteger_p.h> |
59 | #include <private/qfunctioncall_p.h> |
60 | |
61 | /** |
62 | * @file |
63 | * @short Contains classes implementing the functions found in |
64 | * <a href="http://www.w3.org/TR/xpath-functions/#component-exraction-functions">XQuery 1.0 and |
65 | * XPath 2.0 Functions and Operators, 10.5 Component Extraction Functions on Durations, Dates and Times</a>. |
66 | * |
67 | * @ingroup Patternist_functions |
68 | */ |
69 | |
70 | QT_BEGIN_NAMESPACE |
71 | |
72 | namespace QPatternist |
73 | { |
74 | /** |
75 | * @short Helper class for implementing functions extracting components from durations. |
76 | * |
77 | * Each sub-class must implement this function: |
78 | * |
79 | * @code |
80 | * Item extract(const AbstractDuration *const duration) const; |
81 | * @endcode |
82 | * |
83 | * This function performs the actual component extraction from the argument, that |
84 | * is guaranteed to never be @c null. |
85 | * |
86 | * @ingroup Patternist_functions |
87 | * @author Frans Englich <frans.englich@nokia.com> |
88 | */ |
89 | template<typename TSubClass> |
90 | class : public FunctionCall |
91 | { |
92 | public: |
93 | /** |
94 | * Takes care of the argument handling, and, if applicable, |
95 | * calls extract() with the value of the operand. |
96 | */ |
97 | virtual Item (const DynamicContext::Ptr &context) const; |
98 | }; |
99 | |
100 | /** |
101 | * @short Implements the function <tt>fn:years-from-duration()</tt>. |
102 | * |
103 | * @ingroup Patternist_functions |
104 | * @author Frans Englich <frans.englich@nokia.com> |
105 | */ |
106 | class YearsFromDurationFN : public ExtractFromDurationFN<YearsFromDurationFN> |
107 | { |
108 | public: |
109 | inline Item (const AbstractDuration *const duration) const; |
110 | }; |
111 | |
112 | /** |
113 | * @short Implements the function <tt>fn:months-from-duration()</tt>. |
114 | * |
115 | * @ingroup Patternist_functions |
116 | * @author Frans Englich <frans.englich@nokia.com> |
117 | */ |
118 | class MonthsFromDurationFN : public ExtractFromDurationFN<MonthsFromDurationFN> |
119 | { |
120 | public: |
121 | inline Item (const AbstractDuration *const duration) const; |
122 | }; |
123 | |
124 | /** |
125 | * @short Implements the function <tt>fn:days-from-duration()</tt>. |
126 | * |
127 | * @ingroup Patternist_functions |
128 | * @author Frans Englich <frans.englich@nokia.com> |
129 | */ |
130 | class DaysFromDurationFN : public ExtractFromDurationFN<DaysFromDurationFN> |
131 | { |
132 | public: |
133 | inline Item (const AbstractDuration *const duration) const; |
134 | }; |
135 | |
136 | /** |
137 | * @short Implements the function <tt>fn:hours-from-duration()</tt>. |
138 | * |
139 | * @ingroup Patternist_functions |
140 | * @author Frans Englich <frans.englich@nokia.com> |
141 | */ |
142 | class HoursFromDurationFN : public ExtractFromDurationFN<HoursFromDurationFN> |
143 | { |
144 | public: |
145 | inline Item (const AbstractDuration *const duration) const; |
146 | }; |
147 | |
148 | /** |
149 | * @short Implements the function <tt>fn:minutes-from-duration()</tt>. |
150 | * |
151 | * @ingroup Patternist_functions |
152 | * @author Frans Englich <frans.englich@nokia.com> |
153 | */ |
154 | class MinutesFromDurationFN : public ExtractFromDurationFN<MinutesFromDurationFN> |
155 | { |
156 | public: |
157 | inline Item (const AbstractDuration *const duration) const; |
158 | }; |
159 | |
160 | /** |
161 | * @short Implements the function <tt>fn:seconds-from-duration()</tt>. |
162 | * |
163 | * @ingroup Patternist_functions |
164 | * @author Frans Englich <frans.englich@nokia.com> |
165 | */ |
166 | class SecondsFromDurationFN : public ExtractFromDurationFN<SecondsFromDurationFN> |
167 | { |
168 | public: |
169 | inline Item (const AbstractDuration *const duration) const; |
170 | }; |
171 | |
172 | /** |
173 | * @short Helper class for implementing functions extracting components |
174 | * from date/time values. |
175 | * |
176 | * Each sub-class must implement this function: |
177 | * |
178 | * @code |
179 | * Item extract(const AbstractDuration *const duration) const; |
180 | * @endcode |
181 | * |
182 | * This function performs the actual component extraction from the argument, that |
183 | * is guaranteed to never be @c null. |
184 | * |
185 | * @ingroup Patternist_functions |
186 | * @author Frans Englich <frans.englich@nokia.com> |
187 | */ |
188 | template<typename TSubClass> |
189 | class : public FunctionCall |
190 | { |
191 | public: |
192 | /** |
193 | * Takes care of the argument handling, and, if applicable, |
194 | * calls extract() with the value of the operand. |
195 | */ |
196 | virtual Item (const DynamicContext::Ptr &context) const; |
197 | }; |
198 | |
199 | /** |
200 | * @short Extracts the year property from a sub-class of AbstractDateTime such as DateTime or Date. |
201 | * This function implements <tt>fn:year-from-dateTime()</tt> and <tt>fn:year-from-date()</tt>. |
202 | * |
203 | * @ingroup Patternist_functions |
204 | * @author Frans Englich <frans.englich@nokia.com> |
205 | */ |
206 | class YearFromAbstractDateTimeFN : public ExtractFromDateTimeFN<YearFromAbstractDateTimeFN> |
207 | { |
208 | public: |
209 | inline Item (const QDateTime &dt) const; |
210 | }; |
211 | |
212 | /** |
213 | * @short Extracts the day property from a sub-class of AbstractDateTime such as DateTime or Date. |
214 | * This function implements <tt>fn:day-from-dateTime()</tt> and <tt>fn:day-from-date()</tt>. |
215 | * |
216 | * @ingroup Patternist_functions |
217 | * @author Frans Englich <frans.englich@nokia.com> |
218 | */ |
219 | class DayFromAbstractDateTimeFN : public ExtractFromDateTimeFN<DayFromAbstractDateTimeFN> |
220 | { |
221 | public: |
222 | inline Item (const QDateTime &dt) const; |
223 | }; |
224 | |
225 | /** |
226 | * @short Extracts the minute property from a sub-class of AbstractDateTime such as DateTime or SchemaTime. |
227 | * Implements the functions <tt>fn:hours-from-dateTime()</tt> and |
228 | * <tt>fn:hours-from-time()</tt>. |
229 | * |
230 | * @ingroup Patternist_functions |
231 | * @author Frans Englich <frans.englich@nokia.com> |
232 | */ |
233 | class HoursFromAbstractDateTimeFN : public ExtractFromDateTimeFN<HoursFromAbstractDateTimeFN> |
234 | { |
235 | public: |
236 | inline Item (const QDateTime &dt) const; |
237 | }; |
238 | |
239 | /** |
240 | * @short Extracts the minutes property from a sub-class of AbstractDateTime such as DateTime or Date. |
241 | * Implements the functions <tt>fn:minutes-from-dateTime()</tt> and |
242 | * <tt>fn:minutes-from-time()</tt>. |
243 | * |
244 | * @ingroup Patternist_functions |
245 | * @author Frans Englich <frans.englich@nokia.com> |
246 | */ |
247 | class MinutesFromAbstractDateTimeFN : public ExtractFromDateTimeFN<MinutesFromAbstractDateTimeFN> |
248 | { |
249 | public: |
250 | inline Item (const QDateTime &dt) const; |
251 | }; |
252 | |
253 | /** |
254 | * @short Extracts the seconds property from a sub-class of AbstractDateTime such as DateTime or Date. |
255 | * Implements the functions <tt>fn:seconds-from-dateTime()</tt> and |
256 | * <tt>fn:seconds-from-time()</tt>. |
257 | * |
258 | * @ingroup Patternist_functions |
259 | * @author Frans Englich <frans.englich@nokia.com> |
260 | */ |
261 | class SecondsFromAbstractDateTimeFN : public ExtractFromDateTimeFN<SecondsFromAbstractDateTimeFN> |
262 | { |
263 | public: |
264 | inline Item (const QDateTime &dt) const; |
265 | }; |
266 | |
267 | /** |
268 | * @short Extracts the timezone property from a sub-class of AbstractDateTime such as DateTime or Date. |
269 | * Implements the functions <tt>fn:timezone-from-dateTime()</tt>, |
270 | * <tt>fn:timezone-from-time()</tt> and <tt>fn:timezone-from-date()</tt>. |
271 | * |
272 | * @ingroup Patternist_functions |
273 | * @author Frans Englich <frans.englich@nokia.com> |
274 | */ |
275 | class TimezoneFromAbstractDateTimeFN : public ExtractFromDateTimeFN<TimezoneFromAbstractDateTimeFN> |
276 | { |
277 | public: |
278 | inline Item (const QDateTime &dt) const; |
279 | }; |
280 | |
281 | /** |
282 | * @short implements the functions <tt>fn:month-from-dateTime()</tt> and <tt>fn:month-from-date()</tt>. |
283 | * |
284 | * @ingroup Patternist_functions |
285 | * @author Frans Englich <frans.englich@nokia.com> |
286 | */ |
287 | class MonthFromAbstractDateTimeFN : public ExtractFromDateTimeFN<MonthFromAbstractDateTimeFN> |
288 | { |
289 | public: |
290 | inline Item (const QDateTime &dt) const; |
291 | }; |
292 | |
293 | #include "qdatetimefns_tpl_p.h" |
294 | |
295 | } |
296 | |
297 | QT_END_NAMESPACE |
298 | |
299 | #endif |
300 | |