Qt 4.8
Public Functions | List of all members
QPatternist::BooleanComparator Class Reference

Compares xs:boolean values. More...

#include <qatomiccomparators_p.h>

Inheritance diagram for QPatternist::BooleanComparator:
QPatternist::AtomicComparator QPatternist::AtomicTypeVisitorResult QSharedData

Public Functions

virtual ComparisonResult compare (const Item &op1, const AtomicComparator::Operator op, const Item &op2) const
 
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

Compares xs:boolean values.

This is done via the object's Boolean::evaluteEBV() function.

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

Definition at line 148 of file qatomiccomparators_p.h.

Functions

◆ compare()

AtomicComparator::ComparisonResult BooleanComparator::compare ( const Item op1,
const AtomicComparator::Operator  op,
const Item op2 
) const
virtual

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::AtomicComparator.

Definition at line 124 of file qatomiccomparators.cpp.

127 {
128  /* We know Boolean::evaluateEBV doesn't use the DynamicContext. */
129  const bool v1 = o1.as<AtomicValue>()->evaluateEBV(QExplicitlySharedDataPointer<DynamicContext>());
130  const bool v2 = o2.as<AtomicValue>()->evaluateEBV(QExplicitlySharedDataPointer<DynamicContext>());
131 
132  if(v1 == v2)
133  return Equal;
134  else if(v1 == false)
135  {
136  Q_ASSERT(v2 == true);
137  return LessThan;
138  }
139  else
140  {
141  Q_ASSERT(v1 == true && v2 == false);
142  return GreaterThan;
143  }
144 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const TCastTarget * as() const
Base class for all classes representing atomic values.
Definition: qitem_p.h:118

◆ equals()

bool BooleanComparator::equals ( const Item op1,
const Item op2 
) const
virtual

Determines whether op1 and op2 are equal. It is the same as calling compare() and checking whether the return value is Equal, but since comparison testing is such a common operation, this specialized function exists.

Returns
true if op1 and op2 are equal.
Parameters
op1the first operand
op2the second operand

Implements QPatternist::AtomicComparator.

Definition at line 146 of file qatomiccomparators.cpp.

148 {
149  /* Boolean is an atomic class. */
150  return o1.as<AtomicValue>() == o2.as<AtomicValue>();
151 }
const TCastTarget * as() const
Base class for all classes representing atomic values.
Definition: qitem_p.h:118

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