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

A predicate which is optimized for filter expressions that are of type xs:boolean. More...

#include <qtruthpredicate_p.h>

Inheritance diagram for QPatternist::TruthPredicate:
QPatternist::GenericPredicate QPatternist::PairContainer QPatternist::Expression QSharedData QPatternist::CppCastingHelper< Expression > QPatternist::SourceLocationReflection

Public Functions

virtual ExpressionVisitorResult::Ptr accept (const ExpressionVisitor::Ptr &visitor) const
 
virtual SequenceType::List expectedOperandTypes () const
 
Item::Iterator::Ptr map (const Item &item, const DynamicContext::Ptr &context) const
 
Item mapToItem (const Item &item, const DynamicContext::Ptr &context) const
 
 TruthPredicate (const Expression::Ptr &sourceExpression, const Expression::Ptr &predicate)
 
- Public Functions inherited from QPatternist::GenericPredicate
virtual QString description () const
 
virtual Item::Iterator::Ptr evaluateSequence (const DynamicContext::Ptr &context) const
 
virtual Item evaluateSingleton (const DynamicContext::Ptr &context) const
 
virtual ID id () const
 
Item mapToItem (const Item &subject, const DynamicContext::Ptr &) const
 
virtual Properties properties () const
 
virtual SequenceType::Ptr staticType () const
 
- Public Functions inherited from QPatternist::PairContainer
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)
 
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 bool evaluateEBV (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 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::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::GenericPredicate
static Expression::Ptr create (const Expression::Ptr &sourceExpression, const Expression::Ptr &predicateExpression, const StaticContext::Ptr &context, const QSourceLocation &location)
 
static Expression::Ptr createFirstItem (const Expression::Ptr &sourceExpression)
 
- 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::GenericPredicate
 GenericPredicate (const Expression::Ptr &sourceExpression, const Expression::Ptr &predicate)
 
virtual ItemType::Ptr newFocusType () const
 
- Protected Functions inherited from QPatternist::PairContainer
 PairContainer (const Expression::Ptr &operand1, const Expression::Ptr &operand2)
 
- 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::PairContainer
Expression::Ptr m_operand1
 
Expression::Ptr m_operand2
 

Detailed Description

A predicate which is optimized for filter expressions that are of type xs:boolean.

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

Definition at line 70 of file qtruthpredicate_p.h.

Constructors and Destructors

◆ TruthPredicate()

TruthPredicate::TruthPredicate ( const Expression::Ptr sourceExpression,
const Expression::Ptr predicate 
)

Creates a TruthPredicate which filters the items from the sourceExpression through predicate.

This constructor is protected. The proper way to create predicates is via the static create() function.

Definition at line 52 of file qtruthpredicate.cpp.

53  : GenericPredicate(sourceExpression,
54  predicate)
55 {
56 }
GenericPredicate(const Expression::Ptr &sourceExpression, const Expression::Ptr &predicate)

Functions

◆ accept()

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

Reimplemented from QPatternist::GenericPredicate.

Definition at line 66 of file qtruthpredicate.cpp.

Referenced by map().

67 {
68  return visitor->visit(this);
69 }

◆ expectedOperandTypes()

SequenceType::List TruthPredicate::expectedOperandTypes ( ) const
virtual

Returns a list of Sequence Types, describing the type of each of the expression's operands. Hence, this function has a relationship to the operands() function:

- The lengths of the lists returned by expectedOperandTypes()
and operands() should always be equal in length, since one
cannot describe the type of a non-existent operand(and all
operands must have type information).
- A significant difference between the two functions is that while
the type of objects in the list returned by operands() may vary
between compilations/static context, simply because the particular
Expression is part of different XPath expressions, the
types in the list returned by expectedOperandTypes is always the same
since the function/operator signature never changes.

This function should not be confused with staticType(), which returns the static type of the expression itself, not its operands. The function call is an expression where this is clear: the type of the return value is not the same as the arguments' types. The static type of the operands supplied to the expression can be determined via the staticType() function of the instances returned by operands().

If the expression has no operands, an empty list should be returned.

Reimplemented from QPatternist::GenericPredicate.

Definition at line 58 of file qtruthpredicate.cpp.

Referenced by map().

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

◆ map()

Item::Iterator::Ptr QPatternist::TruthPredicate::map ( const Item item,
const DynamicContext::Ptr context 
) const
inline

Definition at line 93 of file qtruthpredicate_p.h.

95  {
96  Q_ASSERT_X(false, Q_FUNC_INFO, "I don't expect this function to be called, for the same reasons as above.");
97  if(m_operand2->evaluateEBV(context))
98  return makeSingletonIterator(item);
99  else
101  }
static const EmptyIterator< Item >::Ptr emptyIterator
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ mapToItem()

Item QPatternist::TruthPredicate::mapToItem ( const Item item,
const DynamicContext::Ptr context 
) const
inline

Definition at line 83 of file qtruthpredicate_p.h.

84  {
85  Q_ASSERT_X(false, Q_FUNC_INFO, "This is practically dead code because it never gets called in GenericPredicate, "
86  "which binds to its own mapToItem for completely legitime reasons.");
87  if(m_operand2->evaluateEBV(context))
88  return item;
89  else
90  return Item();
91  }
The Item is the most basic of all visual items in QML.
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
#define Q_FUNC_INFO
Definition: qglobal.h:1871

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