Qt 4.8
Public Functions | Private Types | List of all members
QPatternist::ArgumentConverter Class Reference

UntypedAtomicConverter for ArgumentReference, if needed. More...

#include <qargumentconverter_p.h>

Inheritance diagram for QPatternist::ArgumentConverter:
QPatternist::UntypedAtomicConverter QPatternist::SingleContainer QPatternist::CastingPlatform< UntypedAtomicConverter, true > QPatternist::Expression QSharedData QPatternist::CppCastingHelper< Expression > QPatternist::SourceLocationReflection

Public Functions

virtual ExpressionVisitorResult::Ptr accept (const ExpressionVisitor::Ptr &visitor) const
 
 ArgumentConverter (const Expression::Ptr &operand, const ItemType::Ptr &reqType)
 
virtual Item::Iterator::Ptr evaluateSequence (const DynamicContext::Ptr &) const
 
virtual Item evaluateSingleton (const DynamicContext::Ptr &) const
 
virtual SequenceType::List expectedOperandTypes () const
 
Item::Iterator::Ptr mapToSequence (const Item &item, const DynamicContext::Ptr &context) const
 
virtual SequenceType::Ptr staticType () const
 
- Public Functions inherited from QPatternist::UntypedAtomicConverter
virtual const SourceLocationReflectionactualReflection () const
 Returns this. More...
 
Item mapToItem (const Item &item, const DynamicContext::Ptr &context) const
 
ItemType::Ptr targetType () const
 
virtual Expression::Ptr typeCheck (const StaticContext::Ptr &context, const SequenceType::Ptr &reqType)
 
 UntypedAtomicConverter (const Expression::Ptr &operand, const ItemType::Ptr &reqType, const ReportContext::ErrorCode code=ReportContext::FORG0001)
 
- 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 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 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 ()
 
- 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 ()
 

Private Types

typedef QExplicitlySharedDataPointer< const ArgumentConverterConstPtr
 

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 Functions inherited from QPatternist::CastingPlatform< UntypedAtomicConverter, true >
Item cast (const Item &sourceValue, const ReportContext::Ptr &context) const
 
 CastingPlatform (const ReportContext::ErrorCode code=ReportContext::FORG0001)
 
void checkTargetType (const ReportContext::Ptr &context) const
 
bool prepareCasting (const ReportContext::Ptr &context, const ItemType::Ptr &sourceType)
 
- Protected Variables inherited from QPatternist::SingleContainer
Expression::Ptr m_operand
 

Detailed Description

UntypedAtomicConverter for ArgumentReference, if needed.

If an argument inside a user function has no type declared, its type is item(). It's atomized type would be inferred to xs:anyAtomicType, but that is not necessarily correct, since the actual value can be anything, nodes or atomic values.

This extremely dynamic case is handled by ArgumentConverter which is inserted for ArgumentReference that has the static type item(), when atomic value are asked for. At runtime it atomizes/let values through appropriately.

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

Definition at line 79 of file qargumentconverter_p.h.

Typedefs

◆ ConstPtr

Definition at line 94 of file qargumentconverter_p.h.

Constructors and Destructors

◆ ArgumentConverter()

ArgumentConverter::ArgumentConverter ( const Expression::Ptr operand,
const ItemType::Ptr reqType 
)

Definition at line 51 of file qargumentconverter.cpp.

52  : UntypedAtomicConverter(operand, reqType)
53 {
54 }
UntypedAtomicConverter(const Expression::Ptr &operand, const ItemType::Ptr &reqType, const ReportContext::ErrorCode code=ReportContext::FORG0001)

Functions

◆ accept()

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

Reimplemented from QPatternist::UntypedAtomicConverter.

Definition at line 56 of file qargumentconverter.cpp.

57 {
58  return visitor->visit(this);
59 }

◆ evaluateSequence()

Item::Iterator::Ptr ArgumentConverter::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::UntypedAtomicConverter.

Definition at line 75 of file qargumentconverter.cpp.

76 {
77  return makeSequenceMappingIterator<Item>(ConstPtr(this),
78  m_operand->evaluateSequence(context),
79  context);
80 }
QExplicitlySharedDataPointer< const ArgumentConverter > ConstPtr
virtual Item::Iterator::Ptr evaluateSequence(const DynamicContext::Ptr &context) const

◆ evaluateSingleton()

Item ArgumentConverter::evaluateSingleton ( const DynamicContext::Ptr context) const
virtual

Reimplemented from QPatternist::UntypedAtomicConverter.

Definition at line 82 of file qargumentconverter.cpp.

83 {
84  const Item item(m_operand->evaluateSingleton(context));
85 
86  if(item)
87  return mapToItem(item, context);
88  else /* Empty is allowed. ArgumentConverter doesn't care about cardinality. */
89  return Item();
90 }
Item mapToItem(const Item &item, const DynamicContext::Ptr &context) const
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const

◆ expectedOperandTypes()

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

Definition at line 92 of file qargumentconverter.cpp.

93 {
94  SequenceType::List result;
96  return result;
97 }
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

◆ mapToSequence()

Item::Iterator::Ptr ArgumentConverter::mapToSequence ( const Item item,
const DynamicContext::Ptr context 
) const
inline

Definition at line 61 of file qargumentconverter.cpp.

63 {
64  if(item.isAtomicValue() && !BuiltinTypes::xsUntypedAtomic->xdtTypeMatches(item.type()))
65  return makeSingletonIterator(item);
66  else
67  {
68  /* We're using UntypedAtomicConverter::mapToItem(). */
69  return makeItemMappingIterator<Item>(ConstPtr(this),
70  item.sequencedTypedValue(),
71  context);
72  }
73 }
QExplicitlySharedDataPointer< const ArgumentConverter > ConstPtr
QExplicitlySharedDataPointer< ItemType > type() const
Returns the ItemType this Item is of.
Definition: qitem_p.h:365
static const AtomicType::Ptr xsUntypedAtomic
bool isAtomicValue() const
Determines whether this item is an atomic value, or a node.
Definition: qitem_p.h:335
Item::Iterator::Ptr sequencedTypedValue() const
Returns the typed value of this item.
Definition: qitem.cpp:50

◆ staticType()

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

Reimplemented from QPatternist::UntypedAtomicConverter.

Definition at line 99 of file qargumentconverter.cpp.

100 {
102 }
static const SequenceType::Ptr ZeroOrMoreAtomicTypes

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