Update obsolete contact address.
[profile/ivi/qtxmlpatterns.git] / src / xmlpatterns / functions / qcomparingaggregator_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
8 **
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.
17 **
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.
21 **
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.
29 **
30 ** Other Usage
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.
33 **
34 **
35 **
36 **
37 **
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_ComparingAggregator_H
53 #define Patternist_ComparingAggregator_H
54
55 /**
56  * @file qcomparingaggregator_p.h
57  * @short Contains the implementations for the functions <tt>fn:max()</tt>, MaxFN,
58  * and <tt>fn:min()</tt>, MinFN, and the class ComparingAggregator.
59  */
60
61 #include <private/qabstractfloat_p.h>
62 #include <private/qdecimal_p.h>
63 #include <private/qcastingplatform_p.h>
64 #include <private/qcomparisonplatform_p.h>
65 #include <private/qliteral_p.h>
66 #include <private/qaggregator_p.h>
67 #include <private/quntypedatomicconverter_p.h>
68 #include <private/qpatternistlocale_p.h>
69
70 QT_BEGIN_HEADER
71
72 QT_BEGIN_NAMESPACE
73
74 namespace QPatternist
75 {
76     /**
77      * @short Base class for the implementations of the <tt>fn:min()</tt> and <tt>fn:max()</tt> function.
78      *
79      * What function that more specifically is
80      * followed, depends on how the constructor is called.
81      *
82      * @see MaxFN
83      * @see MinFN
84      * @ingroup Patternist_functions
85      * @author Frans Englich <frans.englich@nokia.com>
86      */
87     template <AtomicComparator::Operator oper, AtomicComparator::ComparisonResult result>
88     class ComparingAggregator : public Aggregator,
89                                 public ComparisonPlatform<ComparingAggregator<oper, result>,
90                                                           true, AtomicComparator::AsValueComparison,
91                                                           ReportContext::FORG0006>,
92                                 public CastingPlatform<ComparingAggregator<oper, result>, true>
93     {
94     public:
95         virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const;
96         virtual Expression::Ptr typeCheck(const StaticContext::Ptr &context,
97                                           const SequenceType::Ptr &reqType);
98
99         inline AtomicComparator::Operator operatorID() const
100         {
101             return oper;
102         }
103
104         inline ItemType::Ptr targetType() const
105         {
106             return BuiltinTypes::xsDouble;
107         }
108
109     private:
110         inline Item applyNumericPromotion(const Item &old,
111                                                const Item &nev,
112                                                const Item &newVal) const;
113
114         using ComparisonPlatform<ComparingAggregator<oper, result>,
115                                  true,
116                                  AtomicComparator::AsValueComparison,
117                                  ReportContext::FORG0006>::comparator;
118         using ComparisonPlatform<ComparingAggregator<oper, result>,
119                                  true,
120                                  AtomicComparator::AsValueComparison,
121                                  ReportContext::FORG0006>::fetchComparator;
122         using CastingPlatform<ComparingAggregator<oper, result>, true>::cast;
123     };
124
125 #include "qcomparingaggregator.cpp"
126
127     /**
128      * @short An instantiation of ComparingAggregator suitable for <tt>fn:max()</tt>.
129      *
130      * @ingroup Patternist_functions
131      */
132     typedef ComparingAggregator<AtomicComparator::OperatorGreaterThan, AtomicComparator::GreaterThan> MaxFN;
133
134     /**
135      * @short An instantiation of ComparingAggregator suitable for <tt>fn:max()</tt>.
136      *
137      * @ingroup Patternist_functions
138      */
139     typedef ComparingAggregator<AtomicComparator::OperatorLessThan, AtomicComparator::LessThan> MinFN;
140 }
141
142 QT_END_NAMESPACE
143
144 QT_END_HEADER
145
146 #endif