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

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

#include <qatomiccomparators_p.h>

Inheritance diagram for QPatternist::StringComparator:
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 sensitive 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 77 of file qatomiccomparators_p.h.

Functions

◆ compare()

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

Compares two strings, and returns the appropriate AtomicComparator::ComparisonResult enum. This is a bit simplified version of string comparison as defined in the XPath specifications, since this does not take any string collations into account(which an implementation neither is required to do).

See also
XQuery 1.0 and XPath 2.0 Functions and Operators, 7.3 ValueComparison::Equality and Comparison of Strings

Reimplemented from QPatternist::AtomicComparator.

Definition at line 57 of file qatomiccomparators.cpp.

60 {
61  const int result = QString::compare(o1.stringValue(), o2.stringValue());
62 
63  if(result > 0)
64  return GreaterThan;
65  else if(result < 0)
66  return LessThan;
67  else
68  {
69  Q_ASSERT(result == 0);
70  return Equal;
71  }
72 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int compare(const QString &s) const
Definition: qstring.cpp:5037

◆ equals()

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

Compares two strings, and returns true if they are considered equal as per an ordinary string comparison. In other words, this is an implementation with the Unicode code point collation.

See also
XQuery 1.0 and XPath 2.0 Functions and Operators, 7.3 ValueComparison::Equality and Comparison of Strings

Implements QPatternist::AtomicComparator.

Definition at line 74 of file qatomiccomparators.cpp.

76 {
77  return o1.stringValue() == o2.stringValue();
78 }

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