1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
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 | **
|
---|
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.
|
---|
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 have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia 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 |
|
---|
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
|
---|
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 | /**
|
---|
|
---|