1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** 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_ComparingAggregator_H
53 #define Patternist_ComparingAggregator_H
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.
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>
77 * @short Base class for the implementations of the <tt>fn:min()</tt> and <tt>fn:max()</tt> function.
79 * What function that more specifically is
80 * followed, depends on how the constructor is called.
84 * @ingroup Patternist_functions
85 * @author Frans Englich <frans.englich@nokia.com>
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>
95 virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const;
96 virtual Expression::Ptr typeCheck(const StaticContext::Ptr &context,
97 const SequenceType::Ptr &reqType);
99 inline AtomicComparator::Operator operatorID() const
104 inline ItemType::Ptr targetType() const
106 return BuiltinTypes::xsDouble;
110 inline Item applyNumericPromotion(const Item &old,
112 const Item &newVal) const;
114 using ComparisonPlatform<ComparingAggregator<oper, result>,
116 AtomicComparator::AsValueComparison,
117 ReportContext::FORG0006>::comparator;
118 using ComparisonPlatform<ComparingAggregator<oper, result>,
120 AtomicComparator::AsValueComparison,
121 ReportContext::FORG0006>::fetchComparator;
122 using CastingPlatform<ComparingAggregator<oper, result>, true>::cast;
125 #include "qcomparingaggregator_tpl_p.h"
128 * @short An instantiation of ComparingAggregator suitable for <tt>fn:max()</tt>.
130 * @ingroup Patternist_functions
132 typedef ComparingAggregator<AtomicComparator::OperatorGreaterThan, AtomicComparator::GreaterThan> MaxFN;
135 * @short An instantiation of ComparingAggregator suitable for <tt>fn:max()</tt>.
137 * @ingroup Patternist_functions
139 typedef ComparingAggregator<AtomicComparator::OperatorLessThan, AtomicComparator::LessThan> MinFN;