src/xmlpatterns/functions/qcomparingaggregator_p.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    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 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    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 "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 
       
    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