source: trunk/src/xmlpatterns/functions/qcomparingaggregator_p.h@ 117

Last change on this file since 117 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 5.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** 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 are unsure which license is appropriate for your use, please
37** contact the sales department 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_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 "qabstractfloat_p.h"
62#include "qdecimal_p.h"
63#include "qcastingplatform_p.h"
64#include "qcomparisonplatform_p.h"
65#include "qliteral_p.h"
66#include "qaggregator_p.h"
67#include "quntypedatomicconverter_p.h"
68#include "qpatternistlocale_p.h"
69
70QT_BEGIN_HEADER
71
72QT_BEGIN_NAMESPACE
73
74namespace 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 <[email protected]>
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
142QT_END_NAMESPACE
143
144QT_END_HEADER
145
146#endif
Note: See TracBrowser for help on using the repository browser.