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

Implements the function fn:distinct-values(). More...

#include <qsequencefns_p.h>

Inheritance diagram for QPatternist::DistinctValuesFN:
QPatternist::FunctionCall QPatternist::ComparisonPlatform< IndexOfFN, false > QPatternist::UnlimitedContainer QPatternist::Expression QSharedData QPatternist::CppCastingHelper< Expression > QPatternist::SourceLocationReflection

Public Functions

 DistinctValuesFN ()
 
virtual Item::Iterator::Ptr evaluateSequence (const DynamicContext::Ptr &context) const
 
virtual SequenceType::Ptr staticType () const
 
virtual Expression::Ptr typeCheck (const StaticContext::Ptr &context, const SequenceType::Ptr &reqType)
 
- Public Functions inherited from QPatternist::FunctionCall
virtual ExpressionVisitorResult::Ptr accept (const ExpressionVisitor::Ptr &visitor) const
 
virtual SequenceType::List expectedOperandTypes () const
 
virtual ID id () const
 
virtual Expression::Properties properties () const
 
virtual void setSignature (const FunctionSignature::Ptr &sign)
 
virtual FunctionSignature::Ptr signature () const
 
- Public Functions inherited from QPatternist::UnlimitedContainer
virtual bool compressOperands (const StaticContext::Ptr &)
 
virtual Expression::List operands () const
 
virtual void setOperands (const Expression::List &list)
 
 UnlimitedContainer (const Expression::List &operands=Expression::List())
 
- Public Functions inherited from QPatternist::Expression
virtual const SourceLocationReflectionactualReflection () const
 Returns this. More...
 
virtual void announceFocusType (const ItemType::Ptr &itemType)
 
virtual Expression::Ptr compress (const StaticContext::Ptr &context)
 
Properties deepProperties () const
 Computes the union of properties for this Expression and all its descending children. More...
 
virtual Properties dependencies () const
 
virtual QString description () const
 
virtual bool evaluateEBV (const DynamicContext::Ptr &context) const
 
virtual Item evaluateSingleton (const DynamicContext::Ptr &context) const
 
virtual void evaluateToSequenceReceiver (const DynamicContext::Ptr &context) const
 
virtual ItemType::Ptr expectedContextItemType () const
 
 Expression ()
 
bool has (const Property prop) const
 
bool hasDependency (const Property prop) const
 
bool is (const ID id) const
 
bool isEvaluated () const
 
virtual ItemType::Ptr newFocusType () const
 
virtual QList< QExplicitlySharedDataPointer< OptimizationPass > > optimizationPasses () const
 
virtual PatternPriority patternPriority () const
 
const Expression::Ptrrewrite (const Expression::Ptr &to, const StaticContext::Ptr &context) const
 Rewrites this Expression to to, and return to. More...
 
virtual ~Expression ()
 
- 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...
 
- Public Functions inherited from QPatternist::CppCastingHelper< Expression >
const TCastTarget * as () const
 
TCastTarget * as ()
 
- Public Functions inherited from QPatternist::SourceLocationReflection
virtual QSourceLocation sourceLocation () const
 
 SourceLocationReflection ()
 
virtual ~SourceLocationReflection ()
 

Protected Functions

AtomicComparator::Operator operatorID () const
 
- Protected Functions inherited from QPatternist::UnlimitedContainer
template<CardinalityComputation suppliedCard>
SequenceType::Ptr operandsUnionType () const
 
- Protected Functions inherited from QPatternist::Expression
void typeCheckOperands (const StaticContext::Ptr &context)
 
- Protected Functions inherited from QPatternist::CppCastingHelper< Expression >
 CppCastingHelper ()
 
- Protected Functions inherited from QPatternist::ComparisonPlatform< IndexOfFN, false >
const AtomicComparator::Ptrcomparator () const
 
bool compare (const Item &i1, const Item &i2, const AtomicComparator::Ptr &comp, const AtomicComparator::Operator op) const
 Compares i1 and i2 with operator op, using comparator comp. All input arguments must be valid, and not null. More...
 
 ComparisonPlatform ()
 
AtomicComparator::ComparisonResult detailedFlexibleCompare (const Item &it1, const Item &it2, const DynamicContext::Ptr &context) const
 like flexibleCompare(), but returns the result as an AtomicComparator::Operator instead of bool. More...
 
AtomicComparator::Ptr fetchComparator (const ItemType::Ptr &type1, const ItemType::Ptr &type2, const ReportContext::Ptr &context) const
 
bool flexibleCompare (const Item &it1, const Item &it2, const DynamicContext::Ptr &context) const
 Compares it1 against it2, using comparator() and operatorID(). More...
 
void prepareComparison (const AtomicComparator::Ptr &comparator)
 
void useCaseInsensitiveComparator ()
 

Additional Inherited Members

- Public Types inherited from QPatternist::FunctionCall
typedef QExplicitlySharedDataPointer< FunctionCallPtr
 
- Public Types inherited from QPatternist::UnlimitedContainer
enum  CardinalityComputation { ProductOfCardinality, UnionOfCardinality }
 
- Public Types inherited from QPatternist::Expression
typedef QExplicitlySharedDataPointer< const ExpressionConstPtr
 A smart pointer wrapping const Expression instances. More...
 
enum  ID {
  IDBooleanValue = 1, IDCountFN, IDEmptyFN, IDExistsFN,
  IDExpressionSequence, IDGeneralComparison, IDIfThenClause, IDIgnorableExpression,
  IDIntegerValue, IDPositionFN, IDStringValue, IDValueComparison,
  IDRangeVariableReference, IDContextItem, IDUserFunctionCallsite, IDExpressionVariableReference,
  IDAttributeConstructor, IDUpperCaseFN, IDLowerCaseFN, IDFirstItemPredicate,
  IDEmptySequence, IDReturnOrderBy, IDLetClause, IDForClause,
  IDPath, IDNamespaceConstructor, IDArgumentReference, IDGenericPredicate,
  IDAxisStep, IDFloat, IDCombineNodes, IDUnresolvedVariableReference,
  IDCardinalityVerifier
}
 
typedef QList< Expression::PtrList
 
typedef QFlags< PropertyProperties
 
enum  Property {
  UseContextItem = 1, DisableElimination = 1 << 1, IsEvaluated = 1 << 2, DisableTypingDeduction = 1 << 3,
  EmptynessFollowsChild = 1 << 4, RewriteToEmptyOnEmpty = 1 << 5, RequiresFocus = 1 << 6, AffectsOrderOnly = 1 << 7,
  RequiresContextItem = (1 << 8) | RequiresFocus, CreatesFocusForLast = 1 << 9, LastOperandIsCollation = 1 << 10, DependsOnLocalVariable = (1 << 11) | DisableElimination,
  EvaluationCacheRedundant = (1 << 12), IsNodeConstructor = 1 << 13, RequiresCurrentItem = 1 << 14
}
 
typedef QExplicitlySharedDataPointer< ExpressionPtr
 A smart pointer wrapping mutable Expression instances. More...
 
typedef ::QAbstractXmlForwardIterator< Expression::PtrQAbstractXmlForwardIterator
 
typedef QVector< Expression::PtrVector
 
- Static Public Functions inherited from QPatternist::Expression
static void rewrite (Expression::Ptr &old, const Expression::Ptr &New, const StaticContext::Ptr &context)
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 
- Protected Variables inherited from QPatternist::UnlimitedContainer
Expression::List m_operands
 

Detailed Description

Implements the function fn:distinct-values().

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

Definition at line 190 of file qsequencefns_p.h.

Constructors and Destructors

◆ DistinctValuesFN()

QPatternist::DistinctValuesFN::DistinctValuesFN ( )
inline

Definition at line 194 of file qsequencefns_p.h.

194  : ComparisonPlatform<IndexOfFN, false>()
195  {
196  }

Functions

◆ evaluateSequence()

Item::Iterator::Ptr DistinctValuesFN::evaluateSequence ( const DynamicContext::Ptr context) const
virtual

Evaluate this Expression by iterating over it. This is a central function for evaluating expressions.

Expressions must always always return a valid QAbstractXmlForwardIterator and may never return 0. If an empty result is of interest to be returned, the EmptyIterator should be returned.

The default implementation returns a SingletonIterator over the item returned from evaluateSingleton().

Note
This function may raise an exception when calling, not only when QAbstractXmlForwardIterator::next() is called on the return value. This is because in some cases evaluateSingleton() is called directly.

Reimplemented from QPatternist::Expression.

Definition at line 100 of file qsequencefns.cpp.

101 {
103  comparator(),
104  ConstPtr(this),
105  context));
106 }
Filters another sequence by removing duplicates such that the items are unique.
QExplicitlySharedDataPointer< const Expression > ConstPtr
A smart pointer wrapping const Expression instances.
const AtomicComparator::Ptr & comparator() const
QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< Item > > Ptr
A smart pointer wrapping an instance of a QAbstractXmlForwardIterator subclass.
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
virtual Item::Iterator::Ptr evaluateSequence(const DynamicContext::Ptr &context) const

◆ operatorID()

AtomicComparator::Operator QPatternist::DistinctValuesFN::operatorID ( ) const
inlineprotected

◆ staticType()

SequenceType::Ptr DistinctValuesFN::staticType ( ) const
virtual
Returns
a type whose item type is the type of the first operand, and a cardinality which is non-empty if the first operand's type is non-empty and allows exactly-one. The latter is needed for operands which has the cardinality 2+, since distinct-values possibly removes items from the source sequence.

Reimplemented from QPatternist::FunctionCall.

Definition at line 127 of file qsequencefns.cpp.

128 {
130  return makeGenericSequenceType(t->itemType(),
131  t->cardinality().allowsMany() ? Cardinality::oneOrMore()
132  : Cardinality::exactlyOne());
133 }
static Cardinality oneOrMore()
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
virtual SequenceType::Ptr staticType() const =0
Represents a cardinality, a possible , often represented by occurrence indicators.

◆ typeCheck()

Expression::Ptr DistinctValuesFN::typeCheck ( const StaticContext::Ptr context,
const SequenceType::Ptr reqType 
)
virtual

Performs necessary type checks, but also implements the optimization of rewriting to its operand if the operand's cardinality is zero-or-one or exactly-one.

Reimplemented from QPatternist::FunctionCall.

Definition at line 108 of file qsequencefns.cpp.

110 {
111  const Expression::Ptr me(FunctionCall::typeCheck(context, reqType));
113 
114  if(*CommonSequenceTypes::Empty == *t1)
115  return EmptySequence::create(this, context);
116  else if(!m_operands.first()->staticType()->cardinality().allowsMany())
117  return m_operands.first();
118  else if(BuiltinTypes::xsAnyAtomicType->xdtTypeMatches(t1))
119  return me;
120  else
121  {
122  prepareComparison(fetchComparator(t1, t1, context));
123  return me;
124  }
125 }
virtual Expression::Ptr typeCheck(const StaticContext::Ptr &context, const SequenceType::Ptr &reqType)
static Expression::Ptr create(const Expression *const replacementFor, const StaticContext::Ptr &context)
Creates an EmptySequence that is a replacement for replacementFor.
AtomicComparator::Ptr fetchComparator(const ItemType::Ptr &type1, const ItemType::Ptr &type2, const ReportContext::Ptr &context) const
virtual Cardinality cardinality() const =0
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
virtual SequenceType::Ptr staticType() const =0
static const EmptySequenceType::Ptr Empty
static const AtomicType::Ptr xsAnyAtomicType
virtual ItemType::Ptr itemType() const =0
void prepareComparison(const AtomicComparator::Ptr &comparator)

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