1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
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.
52 #ifndef Patternist_DateTimeFNs_H
53 #define Patternist_DateTimeFNs_H
55 #include <private/qatomiccomparator_p.h>
56 #include <private/qcommonvalues_p.h>
57 #include <private/qschemadatetime_p.h>
58 #include <private/qdaytimeduration_p.h>
59 #include <private/qdecimal_p.h>
60 #include <private/qinteger_p.h>
61 #include <private/qfunctioncall_p.h>
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>.
69 * @ingroup Patternist_functions
79 * @short Helper class for implementing functions extracting components from durations.
81 * Each sub-class must implement this function:
84 * Item extract(const AbstractDuration *const duration) const;
87 * This function performs the actual component extraction from the argument, that
88 * is guaranteed to never be @c null.
90 * @ingroup Patternist_functions
91 * @author Frans Englich <frans.englich@nokia.com>
93 template<typename TSubClass>
94 class ExtractFromDurationFN : public FunctionCall
98 * Takes care of the argument handling, and, if applicable,
99 * calls extract() with the value of the operand.
101 virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const;
105 * @short Implements the function <tt>fn:years-from-duration()</tt>.
107 * @ingroup Patternist_functions
108 * @author Frans Englich <frans.englich@nokia.com>
110 class YearsFromDurationFN : public ExtractFromDurationFN<YearsFromDurationFN>
113 inline Item extract(const AbstractDuration *const duration) const;
117 * @short Implements the function <tt>fn:months-from-duration()</tt>.
119 * @ingroup Patternist_functions
120 * @author Frans Englich <frans.englich@nokia.com>
122 class MonthsFromDurationFN : public ExtractFromDurationFN<MonthsFromDurationFN>
125 inline Item extract(const AbstractDuration *const duration) const;
129 * @short Implements the function <tt>fn:days-from-duration()</tt>.
131 * @ingroup Patternist_functions
132 * @author Frans Englich <frans.englich@nokia.com>
134 class DaysFromDurationFN : public ExtractFromDurationFN<DaysFromDurationFN>
137 inline Item extract(const AbstractDuration *const duration) const;
141 * @short Implements the function <tt>fn:hours-from-duration()</tt>.
143 * @ingroup Patternist_functions
144 * @author Frans Englich <frans.englich@nokia.com>
146 class HoursFromDurationFN : public ExtractFromDurationFN<HoursFromDurationFN>
149 inline Item extract(const AbstractDuration *const duration) const;
153 * @short Implements the function <tt>fn:minutes-from-duration()</tt>.
155 * @ingroup Patternist_functions
156 * @author Frans Englich <frans.englich@nokia.com>
158 class MinutesFromDurationFN : public ExtractFromDurationFN<MinutesFromDurationFN>
161 inline Item extract(const AbstractDuration *const duration) const;
165 * @short Implements the function <tt>fn:seconds-from-duration()</tt>.
167 * @ingroup Patternist_functions
168 * @author Frans Englich <frans.englich@nokia.com>
170 class SecondsFromDurationFN : public ExtractFromDurationFN<SecondsFromDurationFN>
173 inline Item extract(const AbstractDuration *const duration) const;
177 * @short Helper class for implementing functions extracting components
178 * from date/time values.
180 * Each sub-class must implement this function:
183 * Item extract(const AbstractDuration *const duration) const;
186 * This function performs the actual component extraction from the argument, that
187 * is guaranteed to never be @c null.
189 * @ingroup Patternist_functions
190 * @author Frans Englich <frans.englich@nokia.com>
192 template<typename TSubClass>
193 class ExtractFromDateTimeFN : public FunctionCall
197 * Takes care of the argument handling, and, if applicable,
198 * calls extract() with the value of the operand.
200 virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const;
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>.
207 * @ingroup Patternist_functions
208 * @author Frans Englich <frans.englich@nokia.com>
210 class YearFromAbstractDateTimeFN : public ExtractFromDateTimeFN<YearFromAbstractDateTimeFN>
213 inline Item extract(const QDateTime &dt) const;
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>.
220 * @ingroup Patternist_functions
221 * @author Frans Englich <frans.englich@nokia.com>
223 class DayFromAbstractDateTimeFN : public ExtractFromDateTimeFN<DayFromAbstractDateTimeFN>
226 inline Item extract(const QDateTime &dt) const;
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>.
234 * @ingroup Patternist_functions
235 * @author Frans Englich <frans.englich@nokia.com>
237 class HoursFromAbstractDateTimeFN : public ExtractFromDateTimeFN<HoursFromAbstractDateTimeFN>
240 inline Item extract(const QDateTime &dt) const;
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>.
248 * @ingroup Patternist_functions
249 * @author Frans Englich <frans.englich@nokia.com>
251 class MinutesFromAbstractDateTimeFN : public ExtractFromDateTimeFN<MinutesFromAbstractDateTimeFN>
254 inline Item extract(const QDateTime &dt) const;
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>.
262 * @ingroup Patternist_functions
263 * @author Frans Englich <frans.englich@nokia.com>
265 class SecondsFromAbstractDateTimeFN : public ExtractFromDateTimeFN<SecondsFromAbstractDateTimeFN>
268 inline Item extract(const QDateTime &dt) const;
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>.
276 * @ingroup Patternist_functions
277 * @author Frans Englich <frans.englich@nokia.com>
279 class TimezoneFromAbstractDateTimeFN : public ExtractFromDateTimeFN<TimezoneFromAbstractDateTimeFN>
282 inline Item extract(const QDateTime &dt) const;
286 * @short implements the functions <tt>fn:month-from-dateTime()</tt> and <tt>fn:month-from-date()</tt>.
288 * @ingroup Patternist_functions
289 * @author Frans Englich <frans.englich@nokia.com>
291 class MonthFromAbstractDateTimeFN : public ExtractFromDateTimeFN<MonthFromAbstractDateTimeFN>
294 inline Item extract(const QDateTime &dt) const;
297 #include "qdatetimefns.cpp"