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

Performs case insensitive string comparison between xs:anyUri, xs:string, and xs:untypedAtomic. More...

#include <qatomiccomparators_p.h>

Inheritance diagram for QPatternist::CaseInsensitiveStringComparator:
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

Performs case insensitive string comparison between xs:anyUri, xs:string, and xs:untypedAtomic.

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

Definition at line 112 of file qatomiccomparators_p.h.

Functions

◆ compare()

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

Converts both string values to upper case and afterwards compare them.

Reimplemented from QPatternist::AtomicComparator.

Definition at line 83 of file qatomiccomparators.cpp.

86 {
87  const QString i1(o1.stringValue().toLower());
88  const QString i2(o2.stringValue().toLower());
89  const int result = QString::compare(i1, i2);
90 
91  if(result > 0)
92  return GreaterThan;
93  else if(result < 0)
94  return LessThan;
95  else
96  {
97  Q_ASSERT(result == 0);
98  return Equal;
99  }
100 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int compare(const QString &s) const
Definition: qstring.cpp:5037

◆ equals()

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

Converts both string values case insensitively.

Implements QPatternist::AtomicComparator.

Definition at line 102 of file qatomiccomparators.cpp.

104 {
105  const QString s1(o1.stringValue());
106  const QString s2(o2.stringValue());
107 
108  return s1.length() == s2.length() &&
109  s1.startsWith(s2, Qt::CaseInsensitive);
110 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QString class provides a Unicode character string.
Definition: qstring.h:83

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