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

Provides compare(), which is a high-level helper function for comparing atomic values. More...

#include <qcomparisonfactory_p.h>

Static Public Functions

static bool compare (const AtomicValue::Ptr &operand1, const AtomicComparator::Operator op, const AtomicValue::Ptr &operand2, const SchemaType::Ptr &type, const ReportContext::Ptr &context, const SourceLocationReflection *const sourceLocationReflection)
 Returns the result of evaluating operator op applied to the atomic values operand1 and operand2. More...
 
static bool constructAndCompare (const DerivedString< TypeString >::Ptr &operand1, const AtomicComparator::Operator op, const DerivedString< TypeString >::Ptr &operand2, const SchemaType::Ptr &type, const ReportContext::Ptr &context, const SourceLocationReflection *const sourceLocationReflection)
 Returns the result of evaluating operator op applied to the atomic values operand1 and operand2. More...
 

Detailed Description

Provides compare(), which is a high-level helper function for comparing atomic values.

This class wraps the helper class ComparisonPlatform with a more specific, high-level API.

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

Definition at line 77 of file qcomparisonfactory_p.h.

Functions

◆ compare()

bool ComparisonFactory::compare ( const AtomicValue::Ptr operand1,
const AtomicComparator::Operator  op,
const AtomicValue::Ptr operand2,
const SchemaType::Ptr type,
const ReportContext::Ptr context,
const SourceLocationReflection *const  sourceLocationReflection 
)
static

Returns the result of evaluating operator op applied to the atomic values operand1 and operand2.

The caller guarantees that both values are of type type.

ComparisonFactory does not take ownership of sourceLocationReflection.

Definition at line 115 of file qcomparisonfactory.cpp.

Referenced by QPatternist::XsdSchemaHelper::constructAndCompare().

121 {
122  Q_ASSERT(operand1);
123  Q_ASSERT(operand2);
124  Q_ASSERT(context);
125  Q_ASSERT(sourceLocationReflection);
126  Q_ASSERT(type);
128  "We can only compare atomic values.");
129 
130  return PerformComparison(sourceLocationReflection, op)(operand1, operand2, type, context);
131 }
virtual TypeCategory category() const =0
int type
Definition: qmetatype.cpp:239
Helper class for ComparisonFactory::fromLexical() which exposes CastingPlatform appropriately.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ constructAndCompare()

bool ComparisonFactory::constructAndCompare ( const DerivedString< TypeString >::Ptr &  operand1,
const AtomicComparator::Operator  op,
const DerivedString< TypeString >::Ptr &  operand2,
const SchemaType::Ptr type,
const ReportContext::Ptr context,
const SourceLocationReflection *const  sourceLocationReflection 
)
static

Returns the result of evaluating operator op applied to the atomic values operand1 and operand2.

In opposite to compare() it converts the operands from string type to type and compares these constructed types.

The caller guarantees that both values are of type type.

ComparisonFactory does not take ownership of sourceLocationReflection.

Definition at line 133 of file qcomparisonfactory.cpp.

139 {
140  Q_ASSERT(operand1);
141  Q_ASSERT(operand2);
142  Q_ASSERT(context);
143  Q_ASSERT(sourceLocationReflection);
144  Q_ASSERT(type);
146  "We can only compare atomic values.");
147 
148  const AtomicValue::Ptr value1 = ValueFactory::fromLexical(operand1->stringValue(), type, context, sourceLocationReflection);
149  const AtomicValue::Ptr value2 = ValueFactory::fromLexical(operand2->stringValue(), type, context, sourceLocationReflection);
150 
151  return compare(value1, op, value2, type, context, sourceLocationReflection);
152 }
static AtomicValue::Ptr fromLexical(const QString &lexicalValue, const SchemaType::Ptr &type, const ReportContext::Ptr &context, const SourceLocationReflection *const sourceLocationReflection)
Returns an AtomicValue of type type from the lexical space lexicalValue, and raise an error through c...
virtual TypeCategory category() const =0
int type
Definition: qmetatype.cpp:239
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
virtual QString stringValue() const
static bool compare(const AtomicValue::Ptr &operand1, const AtomicComparator::Operator op, const AtomicValue::Ptr &operand2, const SchemaType::Ptr &type, const ReportContext::Ptr &context, const SourceLocationReflection *const sourceLocationReflection)
Returns the result of evaluating operator op applied to the atomic values operand1 and operand2...
#define Q_FUNC_INFO
Definition: qglobal.h:1871

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