Qt 4.8
Public Types | Public Functions | Static Public Functions | Private Types | Properties | List of all members
QPatternist::QuantifiedExpression Class Reference

Implements XPath 2.0's quantification expressions some and every. More...

#include <qquantifiedexpression_p.h>

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

Public Types

enum  Operator { Some = 1, Every }
 
- 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
 

Public Functions

virtual ExpressionVisitorResult::Ptr accept (const ExpressionVisitor::Ptr &visitor) const
 
virtual bool evaluateEBV (const DynamicContext::Ptr &context) const
 
virtual SequenceType::List expectedOperandTypes () const
 
Item mapToItem (const Item &item, const DynamicContext::Ptr &context) const
 
Operator operatorID () const
 
 QuantifiedExpression (const VariableSlotID varSlot, const Operator quantifier, const Expression::Ptr &inClause, const Expression::Ptr &testExpression)
 
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 QString description () const
 
virtual Item::Iterator::Ptr evaluateSequence (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
 
virtual ID id () 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 ()
 

Static Public Functions

static QString displayName (const Operator quantifier)
 
- Static Public Functions inherited from QPatternist::Expression
static void rewrite (Expression::Ptr &old, const Expression::Ptr &New, const StaticContext::Ptr &context)
 

Private Types

typedef QExplicitlySharedDataPointer< const QuantifiedExpressionConstPtr
 

Properties

const Operator m_quantifier
 
const VariableSlotID m_varSlot
 

Additional Inherited Members

- Public Variables inherited from QSharedData
QAtomicInt ref
 
- 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

Implements XPath 2.0's quantification expressions some and every.

See also
XML Path Language (XPath) 2.0, 3.9 Quantified Expressions
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 71 of file qquantifiedexpression_p.h.

Typedefs

◆ ConstPtr

Definition at line 104 of file qquantifiedexpression_p.h.

Enumerations

◆ Operator

Constructors and Destructors

◆ QuantifiedExpression()

QuantifiedExpression::QuantifiedExpression ( const VariableSlotID  varSlot,
const Operator  quantifier,
const Expression::Ptr inClause,
const Expression::Ptr testExpression 
)

Definition at line 52 of file qquantifiedexpression.cpp.

56  : PairContainer(inClause, testExpression),
57  m_varSlot(varSlot),
58  m_quantifier(quantifier)
59 {
60  Q_ASSERT(quantifier == Some || quantifier == Every);
61 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
PairContainer(const Expression::Ptr &operand1, const Expression::Ptr &operand2)

Functions

◆ accept()

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

Implements QPatternist::Expression.

Definition at line 135 of file qquantifiedexpression.cpp.

136 {
137  return visitor->visit(this);
138 }

◆ displayName()

QString QuantifiedExpression::displayName ( const Operator  quantifier)
static

Determines the string representation for a quantification operator.

Returns
"some" if quantifier is Some, or "every" if quantifier is Every

Definition at line 106 of file qquantifiedexpression.cpp.

107 {
108  if(quantifier == Some)
109  return QLatin1String("some");
110  else
111  {
112  Q_ASSERT(quantifier == Every);
113  return QLatin1String("every");
114  }
115 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ evaluateEBV()

bool QuantifiedExpression::evaluateEBV ( const DynamicContext::Ptr context) const
virtual

Determines the Effective Boolean Value of the expression.

The Effective Boolean Value of a value is not necessarily the same as converting the value to a new value of type xs:boolean.

Note that this function cannot return the empty sequence, evaluateSingleton() must be overridden in order to be able to do that.

The default implementation results in a type error. Hence, this function must be overridden if such behavior is not of interest.

See also
XML Path Language (XPath) 2.0, 2.4.3 Effective Boolean Value

Reimplemented from QPatternist::Expression.

Definition at line 70 of file qquantifiedexpression.cpp.

71 {
72  const Item::Iterator::Ptr it(makeItemMappingIterator<Item>(ConstPtr(this),
73  m_operand1->evaluateSequence(context),
74  context));
75 
76  Item item(it->next());
77 
78  if(m_quantifier == Some)
79  {
80  while(item)
81  {
82  if(m_operand2->evaluateEBV(context))
83  return true;
84  else
85  item = it->next();
86  };
87 
88  return false;
89  }
90  else
91  {
93 
94  while(item)
95  {
96  if(m_operand2->evaluateEBV(context))
97  item = it->next();
98  else
99  return false;
100  }
101 
102  return true;
103  }
104 }
#define it(className, varName)
virtual bool evaluateEBV(const DynamicContext::Ptr &context) const
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
QExplicitlySharedDataPointer< const QuantifiedExpression > ConstPtr
virtual Item::Iterator::Ptr evaluateSequence(const DynamicContext::Ptr &context) const

◆ expectedOperandTypes()

SequenceType::List QuantifiedExpression::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.

Implements QPatternist::Expression.

Definition at line 122 of file qquantifiedexpression.cpp.

123 {
124  SequenceType::List result;
127  return result;
128 }
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

◆ mapToItem()

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

Definition at line 63 of file qquantifiedexpression.cpp.

65 {
66  context->setRangeVariable(m_varSlot, item);
67  return item;
68 }
virtual void setRangeVariable(const VariableSlotID slot, const Item &newValue)=0

◆ operatorID()

QuantifiedExpression::Operator QuantifiedExpression::operatorID ( ) const

Definition at line 130 of file qquantifiedexpression.cpp.

131 {
132  return m_quantifier;
133 }

◆ staticType()

SequenceType::Ptr QuantifiedExpression::staticType ( ) const
virtual
Returns
the static type of this Expression. For example, an 'and' expression have as static type xs:boolean

Implements QPatternist::Expression.

Definition at line 117 of file qquantifiedexpression.cpp.

118 {
120 }
static const SequenceType::Ptr ExactlyOneBoolean

Properties

◆ m_quantifier

const Operator QPatternist::QuantifiedExpression::m_quantifier
private

Definition at line 106 of file qquantifiedexpression_p.h.

Referenced by evaluateEBV(), and operatorID().

◆ m_varSlot

const VariableSlotID QPatternist::QuantifiedExpression::m_varSlot
private

Definition at line 105 of file qquantifiedexpression_p.h.

Referenced by mapToItem().


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