source: branches/4.5.1/src/xmlpatterns/functions/qdatetimefns_p.h@ 1168

Last change on this file since 1168 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 10.1 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42//
43// W A R N I N G
44// -------------
45//
46// This file is not part of the Qt API. It exists purely as an
47// implementation detail. This header file may change from version to
48// version without notice, or even be removed.
49//
50// We mean it.
51
52#ifndef Patternist_DateTimeFNs_H
53#define Patternist_DateTimeFNs_H
54
55#include "qatomiccomparator_p.h"
56#include "qcommonvalues_p.h"
57#include "qschemadatetime_p.h"
58#include "qdaytimeduration_p.h"
59#include "qdecimal_p.h"
60#include "qinteger_p.h"
61#include "qfunctioncall_p.h"
62
63/**
64 * @file
65 * @short Contains classes implementing the functions found in
66 * <a href="http://www.w3.org/TR/xpath-functions/#component-exraction-functions">XQuery 1.0 and
67 * XPath 2.0 Functions and Operators, 10.5 Component Extraction Functions on Durations, Dates and Times</a>.
68 *
69 * @ingroup Patternist_functions
70 */
71
72QT_BEGIN_HEADER
73
74QT_BEGIN_NAMESPACE
75
76namespace QPatternist
77{
78 /**
79 * @short Helper class for implementing functions extracting components from durations.
80 *
81 * Each sub-class must implement this function:
82 *
83 * @code
84 * Item extract(const AbstractDuration *const duration) const;
85 * @endcode
86 *
87 * This function performs the actual component extraction from the argument, that
88 * is guaranteed to never be @c null.
89 *
90 * @ingroup Patternist_functions
91 * @author Frans Englich <[email protected]>
92 */
93 template<typename TSubClass>
94 class ExtractFromDurationFN : public FunctionCall
95 {
96 public:
97 /**
98 * Takes care of the argument handling, and, if applicable,
99 * calls extract() with the value of the operand.
100 */
101 virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const;
102 };
103
104 /**
105 * @short Implements the function <tt>fn:years-from-duration()</tt>.
106 *
107 * @ingroup Patternist_functions
108 * @author Frans Englich <[email protected]>
109 */
110 class YearsFromDurationFN : public ExtractFromDurationFN<YearsFromDurationFN>
111 {
112 public:
113 inline Item extract(const AbstractDuration *const duration) const;
114 };
115
116 /**
117 * @short Implements the function <tt>fn:months-from-duration()</tt>.
118 *
119 * @ingroup Patternist_functions
120 * @author Frans Englich <[email protected]>
121 */
122 class MonthsFromDurationFN : public ExtractFromDurationFN<MonthsFromDurationFN>
123 {
124 public:
125 inline Item extract(const AbstractDuration *const duration) const;
126 };
127
128 /**
129 * @short Implements the function <tt>fn:days-from-duration()</tt>.
130 *
131 * @ingroup Patternist_functions
132 * @author Frans Englich <[email protected]>
133 */
134 class DaysFromDurationFN : public ExtractFromDurationFN<DaysFromDurationFN>
135 {
136 public:
137 inline Item extract(const AbstractDuration *const duration) const;
138 };
139
140 /**
141 * @short Implements the function <tt>fn:hours-from-duration()</tt>.
142 *
143 * @ingroup Patternist_functions
144 * @author Frans Englich <[email protected]>
145 */
146 class HoursFromDurationFN : public ExtractFromDurationFN<HoursFromDurationFN>
147 {
148 public:
149 inline Item extract(const AbstractDuration *const duration) const;
150 };
151
152 /**
153 * @short Implements the function <tt>fn:minutes-from-duration()</tt>.
154 *
155 * @ingroup Patternist_functions
156 * @author Frans Englich <[email protected]>
157 */
158 class MinutesFromDurationFN : public ExtractFromDurationFN<MinutesFromDurationFN>
159 {
160 public:
161 inline Item extract(const AbstractDuration *const duration) const;
162 };
163
164 /**
165 * @short Implements the function <tt>fn:seconds-from-duration()</tt>.
166 *
167 * @ingroup Patternist_functions
168 * @author Frans Englich <[email protected]>
169 */
170 class SecondsFromDurationFN : public ExtractFromDurationFN<SecondsFromDurationFN>
171 {
172 public:
173 inline Item extract(const AbstractDuration *const duration) const;
174 };
175
176 /**
177 * @short Helper class for implementing functions extracting components
178 * from date/time values.
179 *
180 * Each sub-class must implement this function:
181 *
182 * @code
183 * Item extract(const AbstractDuration *const duration) const;
184 * @endcode
185 *
186 * This function performs the actual component extraction from the argument, that
187 * is guaranteed to never be @c null.
188 *
189 * @ingroup Patternist_functions
190 * @author Frans Englich <[email protected]>
191 */
192 template<typename TSubClass>
193 class ExtractFromDateTimeFN : public FunctionCall
194 {
195 public:
196 /**
197 * Takes care of the argument handling, and, if applicable,
198 * calls extract() with the value of the operand.
199 */
200 virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const;
201 };
202
203 /**
204 * @short Extracts the year property from a sub-class of AbstractDateTime such as DateTime or Date.
205 * This function implements <tt>fn:year-from-dateTime()</tt> and <tt>fn:year-from-date()</tt>.
206 *
207 * @ingroup Patternist_functions
208 * @author Frans Englich <[email protected]>
209 */
210 class YearFromAbstractDateTimeFN : public ExtractFromDateTimeFN<YearFromAbstractDateTimeFN>
211 {
212 public:
213 inline Item extract(const QDateTime &dt) const;
214 };
215
216 /**
217 * @short Extracts the day property from a sub-class of AbstractDateTime such as DateTime or Date.
218 * This function implements <tt>fn:day-from-dateTime()</tt> and <tt>fn:day-from-date()</tt>.
219 *
220 * @ingroup Patternist_functions
221 * @author Frans Englich <[email protected]>
222 */
223 class DayFromAbstractDateTimeFN : public ExtractFromDateTimeFN<DayFromAbstractDateTimeFN>
224 {
225 public:
226 inline Item extract(const QDateTime &dt) const;
227 };
228
229 /**
230 * @short Extracts the minute property from a sub-class of AbstractDateTime such as DateTime or SchemaTime.
231 * Implements the functions <tt>fn:hours-from-dateTime()</tt> and
232 * <tt>fn:hours-from-time()</tt>.
233 *
234 * @ingroup Patternist_functions
235 * @author Frans Englich <[email protected]>
236 */
237 class HoursFromAbstractDateTimeFN : public ExtractFromDateTimeFN<HoursFromAbstractDateTimeFN>
238 {
239 public:
240 inline Item extract(const QDateTime &dt) const;
241 };
242
243 /**
244 * @short Extracts the minutes property from a sub-class of AbstractDateTime such as DateTime or Date.
245 * Implements the functions <tt>fn:minutes-from-dateTime()</tt> and
246 * <tt>fn:minutes-from-time()</tt>.
247 *
248 * @ingroup Patternist_functions
249 * @author Frans Englich <[email protected]>
250 */
251 class MinutesFromAbstractDateTimeFN : public ExtractFromDateTimeFN<MinutesFromAbstractDateTimeFN>
252 {
253 public:
254 inline Item extract(const QDateTime &dt) const;
255 };
256
257 /**
258 * @short Extracts the seconds property from a sub-class of AbstractDateTime such as DateTime or Date.
259 * Implements the functions <tt>fn:seconds-from-dateTime()</tt> and
260 * <tt>fn:seconds-from-time()</tt>.
261 *
262 * @ingroup Patternist_functions
263 * @author Frans Englich <[email protected]>
264 */
265 class SecondsFromAbstractDateTimeFN : public ExtractFromDateTimeFN<SecondsFromAbstractDateTimeFN>
266 {
267 public:
268 inline Item extract(const QDateTime &dt) const;
269 };
270
271 /**
272 * @short Extracts the timezone property from a sub-class of AbstractDateTime such as DateTime or Date.
273 * Implements the functions <tt>fn:timezone-from-dateTime()</tt>,
274 * <tt>fn:timezone-from-time()</tt> and <tt>fn:timezone-from-date()</tt>.
275 *
276 * @ingroup Patternist_functions
277 * @author Frans Englich <[email protected]>
278 */
279 class TimezoneFromAbstractDateTimeFN : public ExtractFromDateTimeFN<TimezoneFromAbstractDateTimeFN>
280 {
281 public:
282 inline Item extract(const QDateTime &dt) const;
283 };
284
285 /**
286 * @short implements the functions <tt>fn:month-from-dateTime()</tt> and <tt>fn:month-from-date()</tt>.
287 *
288 * @ingroup Patternist_functions
289 * @author Frans Englich <[email protected]>
290 */
291 class MonthFromAbstractDateTimeFN : public ExtractFromDateTimeFN<MonthFromAbstractDateTimeFN>
292 {
293 public:
294 inline Item extract(const QDateTime &dt) const;
295 };
296
297#include "qdatetimefns.cpp"
298
299}
300
301QT_END_NAMESPACE
302
303QT_END_HEADER
304
305#endif
Note: See TracBrowser for help on using the repository browser.