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

Constructs simple content as specified for attributes in direct element constructors in XQuery. More...

#include <qsimplecontentconstructor_p.h>

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

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 &context) const
 
virtual SequenceType::List expectedOperandTypes () const
 
 SimpleContentConstructor (const Expression::Ptr &operand)
 
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
 
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 ()
 

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

Constructs simple content as specified for attributes in direct element constructors in XQuery.

Note
Sometimes you want XSLTSimpleContentConstructor.
See also
XSLTSimpleContentConstructor
XQuery 1.0: An XML Query Language, 3.7.1.1 Attributes
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 76 of file qsimplecontentconstructor_p.h.

Constructors and Destructors

◆ SimpleContentConstructor()

SimpleContentConstructor::SimpleContentConstructor ( const Expression::Ptr operand)

Definition at line 51 of file qsimplecontentconstructor.cpp.

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

Functions

◆ accept()

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

Implements QPatternist::Expression.

Definition at line 109 of file qsimplecontentconstructor.cpp.

110 {
111  return visitor->visit(this);
112 }

◆ compress()

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

compress() is the last stage performs in compiling an expression, done after the initial AST build and calling typeCheck(). compress() performs crucial simplifications, either by having drastic performance implications or that some expressions depend on it for proper behavior.

The default implementation performs a sparse conditional constant propagation. In short, a recursive process is performed in the AST which examines if the Expression's operands are constant values, and if so, performs a const fold(AST rewrite) into the result of evaluating the expression in question. This default behavior can be disabled by letting properties() return DisableElimination.

This compress() stage can be relative effective due to the design of XPath, in part because intrinsic functions are heavily used. Many Expressions override compress() and do optimizations specific to what they do. Also, many Expressions performs optimizations in their typeCheck().

Parameters
contextthe static context. Supplies compile time information, and is the channel for communicating error messages.
See also
Wikipedia, the free encyclopedia, Sparse conditional constant propagation
Wikipedia, the free encyclopedia, Intrinsic function
Wikipedia, the free encyclopedia, Compiler optimization

Reimplemented from QPatternist::Expression.

Definition at line 79 of file qsimplecontentconstructor.cpp.

80 {
81  const Expression::Ptr me(SingleContainer::compress(context));
82 
83  if(me.data() == this)
84  {
85  /* Optimization: if we will evaluate to a single string, we're not
86  * necessary. */
88  return m_operand;
89  }
90 
91  return me;
92 }
static const SequenceType::Ptr ExactlyOneString
virtual Expression::Ptr compress(const StaticContext::Ptr &context)
virtual SequenceType::Ptr staticType() const =0

◆ evaluateSingleton()

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

Reimplemented from QPatternist::Expression.

Reimplemented in QPatternist::XSLTSimpleContentConstructor.

Definition at line 55 of file qsimplecontentconstructor.cpp.

56 {
58  Item next(it->next());
59  QString result;
60 
61  if(next)
62  {
63  result = next.stringValue();
64  next = it->next();
65  }
66  else
67  return Item();
68 
69  while(next)
70  {
71  result += QLatin1Char(' ');
72  result += next.stringValue();
73  next = it->next();
74  }
75 
76  return AtomicString::fromValue(result);
77 }
#define it(className, varName)
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
The QString class provides a Unicode character string.
Definition: qstring.h:83
static AtomicString::Ptr fromValue(const QString &value)
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
virtual Item::Iterator::Ptr evaluateSequence(const DynamicContext::Ptr &context) const

◆ expectedOperandTypes()

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

Reimplemented in QPatternist::XSLTSimpleContentConstructor.

Definition at line 94 of file qsimplecontentconstructor.cpp.

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

◆ staticType()

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

Implements QPatternist::Expression.

Reimplemented in QPatternist::XSLTSimpleContentConstructor.

Definition at line 101 of file qsimplecontentconstructor.cpp.

102 {
105  else
107 }
static const SequenceType::Ptr ExactlyOneString
static const SequenceType::Ptr ZeroOrOneString
virtual Cardinality cardinality() const =0
virtual SequenceType::Ptr staticType() const =0

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