Qt 4.8
Public Functions | List of all members
QPatternist::AbstractFloatSortComparator< t_op > Class Template Reference

Compares xs:double values for the purpose of sorting. More...

#include <qatomiccomparators_p.h>

Inheritance diagram for QPatternist::AbstractFloatSortComparator< t_op >:
QPatternist::AbstractFloatComparator QPatternist::AtomicComparator QPatternist::AtomicTypeVisitorResult QSharedData

Public Functions

virtual ComparisonResult compare (const Item &o1, const AtomicComparator::Operator op, const Item &o2) const
 
- Public Functions inherited from QPatternist::AbstractFloatComparator
virtual bool equals (const Item &op1, const Item &op2) const
 
- Public Functions inherited from QPatternist::AtomicComparator
 AtomicComparator ()
 
virtual ~AtomicComparator ()
 
- Public Functions inherited from QPatternist::AtomicTypeVisitorResult
 AtomicTypeVisitorResult ()
 
virtual ~AtomicTypeVisitorResult ()
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 

Additional Inherited Members

- Public Types inherited from QPatternist::AtomicComparator
enum  ComparisonResult { LessThan = 1, Equal = 2, GreaterThan = 4, Incomparable = 8 }
 
enum  ComparisonType { AsGeneralComparison = 1, AsValueComparison }
 
enum  Operator {
  OperatorEqual = 1, OperatorNotEqual = 1 << 1, OperatorGreaterThan = 1 << 2, OperatorLessThan = 1 << 3,
  OperatorLessThanNaNLeast = 1 << 4, OperatorLessThanNaNGreatest = 1 << 5, OperatorGreaterOrEqual = OperatorEqual | OperatorGreaterThan, OperatorLessOrEqual = OperatorEqual | OperatorLessThan
}
 
typedef QFlags< OperatorOperators
 
typedef QExplicitlySharedDataPointer< AtomicComparatorPtr
 
- Public Types inherited from QPatternist::AtomicTypeVisitorResult
typedef QExplicitlySharedDataPointer< AtomicTypeVisitorResultPtr
 
- Static Public Functions inherited from QPatternist::AtomicComparator
static QString displayName (const AtomicComparator::Operator op, const ComparisonType type)
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

template<const AtomicComparator::Operator t_op>
class QPatternist::AbstractFloatSortComparator< t_op >

Compares xs:double values for the purpose of sorting.

Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 185 of file qatomiccomparators_p.h.

Functions

◆ compare()

template<const AtomicComparator::Operator t_op>
virtual ComparisonResult QPatternist::AbstractFloatSortComparator< t_op >::compare ( const Item op1,
const AtomicComparator::Operator  op,
const Item op2 
) const
inlinevirtual

Compares op1 and op2 and determines the relationship between the two. This is used for sorting and comparisons. The implementation performs an assert crash, and must therefore be re-implemented if comparing the relevant values should be possible.

Parameters
op1the first operand
opthe operator. How a comparison is carried out shouldn't depend on what the operator is, but in some cases it is of interest.
op2the second operand

Reimplemented from QPatternist::AbstractFloatComparator.

Definition at line 188 of file qatomiccomparators_p.h.

191  {
193  "Can only be instantiated with those two.");
194  Q_ASSERT(op == t_op);
195  Q_UNUSED(op); /* Needed when building in release mode. */
196 
197  const xsDouble v1 = o1.template as<Numeric>()->toDouble();
198  const xsDouble v2 = o2.template as<Numeric>()->toDouble();
199 
200  if(qIsNaN(v1) && !qIsNaN(v2))
201  return t_op == OperatorLessThanNaNLeast ? LessThan : GreaterThan;
202  if(!qIsNaN(v1) && qIsNaN(v2))
203  return t_op == OperatorLessThanNaNLeast ? GreaterThan : LessThan;
204 
205  if(Double::isEqual(v1, v2))
206  return Equal;
207  else if(v1 < v2)
208  return LessThan;
209  else
210  return GreaterThan;
211  }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_CORE_EXPORT bool qIsNaN(double d)
Returns true if the double {d} is not a number (NaN).
Definition: qnumeric.cpp:55
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
static bool isEqual(const xsDouble a, const xsDouble b)
static qreal toDouble(const QChar *&str)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
#define Q_FUNC_INFO
Definition: qglobal.h:1871

The documentation for this class was generated from the following file: