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

A predicate that always selects the first item from its sequence. More...

#include <qfirstitempredicate_p.h>

Inheritance diagram for QPatternist::FirstItemPredicate:
QPatternist::SingleContainer QPatternist::Expression QSharedData QPatternist::CppCastingHelper< Expression > QPatternist::SourceLocationReflection

Public Functions

virtual ExpressionVisitorResult::Ptr accept (const ExpressionVisitor::Ptr &visitor) const
 
virtual Expression::Ptr compress (const StaticContext::Ptr &context)
 
virtual Item evaluateSingleton (const DynamicContext::Ptr &) const
 
virtual SequenceType::List expectedOperandTypes () const
 
 FirstItemPredicate (const Expression::Ptr &source)
 
virtual ID id () const
 
virtual SequenceType::Ptr staticType () const
 
- Public Functions inherited from QPatternist::SingleContainer
virtual bool compressOperands (const StaticContext::Ptr &)
 
virtual Expression::List operands () const
 
virtual void setOperands (const Expression::List &operands)
 
- Public Functions inherited from QPatternist::Expression
virtual const SourceLocationReflectionactualReflection () const
 Returns this. More...
 
virtual void announceFocusType (const ItemType::Ptr &itemType)
 
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::Iterator::Ptr evaluateSequence (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
 
virtual Properties properties () const
 
const Expression::Ptrrewrite (const Expression::Ptr &to, const StaticContext::Ptr &context) const
 Rewrites this Expression to to, and return to. More...
 
virtual Expression::Ptr typeCheck (const StaticContext::Ptr &context, const SequenceType::Ptr &reqType)
 
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 ()
 

Additional Inherited Members

- 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 Functions inherited from QPatternist::SingleContainer
 SingleContainer (const Expression::Ptr &operand)
 
- Protected Functions inherited from QPatternist::Expression
void typeCheckOperands (const StaticContext::Ptr &context)
 
- Protected Functions inherited from QPatternist::CppCastingHelper< Expression >
 CppCastingHelper ()
 
- Protected Variables inherited from QPatternist::SingleContainer
Expression::Ptr m_operand
 

Detailed Description

A predicate that always selects the first item from its sequence.

FirstItemPredicate corresponds exactly to the predicate in the expression input[1].

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

Definition at line 72 of file qfirstitempredicate_p.h.

Constructors and Destructors

◆ FirstItemPredicate()

FirstItemPredicate::FirstItemPredicate ( const Expression::Ptr source)

Creates a FirstItemPredicate that filters source.

Definition at line 51 of file qfirstitempredicate.cpp.

51  : SingleContainer(source)
52 {
53 }
SingleContainer(const Expression::Ptr &operand)

Functions

◆ accept()

ExpressionVisitorResult::Ptr FirstItemPredicate::accept ( const ExpressionVisitor::Ptr visitor) const
virtual

Implements QPatternist::Expression.

Definition at line 87 of file qfirstitempredicate.cpp.

88 {
89  return visitor->visit(this);
90 }

◆ compress()

Expression::Ptr FirstItemPredicate::compress ( const StaticContext::Ptr context)
virtual

Rewrites expression[1][1] into expression[1].

Reimplemented from QPatternist::Expression.

Definition at line 68 of file qfirstitempredicate.cpp.

69 {
70  const Expression::Ptr me(SingleContainer::compress(context));
71  if(me != this)
72  return me;
73 
76 
77  return me;
78 }
virtual Expression::Ptr compress(const StaticContext::Ptr &context)
virtual Expression::List operands() const =0
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
bool is(const ID id) const

◆ evaluateSingleton()

Item FirstItemPredicate::evaluateSingleton ( const DynamicContext::Ptr context) const
virtual
Returns
the first item, if any, from evaluating the source expression.

Reimplemented from QPatternist::Expression.

Definition at line 55 of file qfirstitempredicate.cpp.

56 {
57  /* If our operand allows the empty sequence, this function can return Item(), otherwise
58  * it returns the first item. As simple as that. */
59  return m_operand->evaluateSequence(context)->next();
60 }
virtual Item::Iterator::Ptr evaluateSequence(const DynamicContext::Ptr &context) const

◆ expectedOperandTypes()

SequenceType::List FirstItemPredicate::expectedOperandTypes ( ) const
virtual
Returns
a list containing one CommonSequenceTypes::ZeroOrMoreItems instance.

Implements QPatternist::Expression.

Definition at line 80 of file qfirstitempredicate.cpp.

81 {
82  SequenceType::List result;
84  return result;
85 }
static const SequenceType::Ptr ZeroOrMoreItems
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ id()

Expression::ID FirstItemPredicate::id ( ) const
virtual
Returns
always IDFirstItemPredicate.

Reimplemented from QPatternist::Expression.

Definition at line 92 of file qfirstitempredicate.cpp.

◆ staticType()

SequenceType::Ptr FirstItemPredicate::staticType ( ) const
virtual
Returns
a SequenceType where the item type is the same as the source expression and where the cardinality is either Cardinality::zeroOrOne() or Cardinality::exactlyOne(), depending on the source expression.

Implements QPatternist::Expression.

Definition at line 62 of file qfirstitempredicate.cpp.

63 {
65  return makeGenericSequenceType(t->itemType(), t->cardinality().toWithoutMany());
66 }
virtual SequenceType::Ptr staticType() const =0

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