[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
[561] | 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
[2] | 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 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
[2] | 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 |
|
---|
| 72 | QT_BEGIN_HEADER
|
---|
| 73 |
|
---|
| 74 | QT_BEGIN_NAMESPACE
|
---|
| 75 |
|
---|
| 76 | namespace 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
|
---|
[561] | 91 | * @author Frans Englich <[email protected]>
|
---|
[2] | 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
|
---|
[561] | 108 | * @author Frans Englich <[email protected]>
|
---|
[2] | 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
|
---|
[561] | 120 | * @author Frans Englich <[email protected]>
|
---|
[2] | 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
|
---|
[561] | 132 | * @author Frans Englich <[email protected]>
|
---|
[2] | 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
|
---|
[561] | 144 | * @author Frans Englich <[email protected]>
|
---|
[2] | 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
|
---|
[561] | 156 | * @author Frans Englich <[email protected]>
|
---|
[2] | 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
|
---|
[561] | 168 | * @author Frans Englich <[email protected]>
|
---|
[2] | 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
|
---|
[561] | 190 | * @author Frans Englich <[email protected]>
|
---|
[2] | 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
|
---|
[561] | 208 | * @author Frans Englich <[email protected]>
|
---|
[2] | 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
|
---|
[561] | 221 | * @author Frans Englich <[email protected]>
|
---|
[2] | 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
|
---|
[561] | 235 | * @author Frans Englich <[email protected]>
|
---|
[2] | 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
|
---|
[561] | 249 | * @author Frans Englich <[email protected]>
|
---|
[2] | 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
|
---|
[561] | 263 | * @author Frans Englich <[email protected]>
|
---|
[2] | 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
|
---|
[561] | 277 | * @author Frans Englich <[email protected]>
|
---|
[2] | 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
|
---|
[561] | 289 | * @author Frans Englich <[email protected]>
|
---|
[2] | 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 |
|
---|
| 301 | QT_END_NAMESPACE
|
---|
| 302 |
|
---|
| 303 | QT_END_HEADER
|
---|
| 304 |
|
---|
| 305 | #endif
|
---|