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

Constructs a text node. This covers both computed and directly constructed text nodes. More...

#include <qdocumentconstructor_p.h>

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

Public Functions

virtual ExpressionVisitorResult::Ptr accept (const ExpressionVisitor::Ptr &visitor) const
 
 DocumentConstructor (const Expression::Ptr &operand)
 
virtual Item evaluateSingleton (const DynamicContext::Ptr &context) const
 
virtual void evaluateToSequenceReceiver (const DynamicContext::Ptr &context) const
 
virtual SequenceType::List expectedOperandTypes () const
 
virtual Properties properties () const
 
virtual SequenceType::Ptr staticType () const
 
virtual Expression::Ptr typeCheck (const StaticContext::Ptr &context, const SequenceType::Ptr &reqType)
 
- 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)
 
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 Item::Iterator::Ptr evaluateSequence (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
 
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 ()
 

Properties

QUrl m_staticBaseURI
 

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 a text node. This covers both computed and directly constructed text nodes.

See also
XQuery 1.0: An XML Query Language, 3.7 Constructors
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 74 of file qdocumentconstructor_p.h.

Constructors and Destructors

◆ DocumentConstructor()

DocumentConstructor::DocumentConstructor ( const Expression::Ptr operand)

Definition at line 52 of file qdocumentconstructor.cpp.

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

Functions

◆ accept()

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

Implements QPatternist::Expression.

Definition at line 111 of file qdocumentconstructor.cpp.

112 {
113  return visitor->visit(this);
114 }

◆ evaluateSingleton()

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

Reimplemented from QPatternist::Expression.

Definition at line 56 of file qdocumentconstructor.cpp.

57 {
58  NodeBuilder::Ptr nodeBuilder(context->nodeBuilder(m_staticBaseURI));
59 
60  DocumentContentValidator validator(nodeBuilder.data(), context, ConstPtr(this));
61  const DynamicContext::Ptr receiverContext(context->createReceiverContext(&validator));
62 
63  validator.startDocument();
64  m_operand->evaluateToSequenceReceiver(receiverContext);
65  validator.endDocument();
66 
67  const QAbstractXmlNodeModel::Ptr nm(nodeBuilder->builtDocument());
68  context->addNodeModel(nm);
69 
70  return nm->root(QXmlNodeModelIndex());
71 }
The QXmlNodeModelIndex class identifies a node in an XML node model subclassed from QAbstractXmlNodeM...
virtual void addNodeModel(const QAbstractXmlNodeModel::Ptr &nm)=0
QExplicitlySharedDataPointer< const Expression > ConstPtr
A smart pointer wrapping const Expression instances.
Receives QAbstractXmlReceiver events and validates that they are correct, before sending them on to a...
DynamicContext::Ptr createReceiverContext(QAbstractXmlReceiver *const receiver)
virtual NodeBuilder::Ptr nodeBuilder(const QUrl &baseURI) const =0
virtual void evaluateToSequenceReceiver(const DynamicContext::Ptr &context) const

◆ evaluateToSequenceReceiver()

void DocumentConstructor::evaluateToSequenceReceiver ( const DynamicContext::Ptr context) const
virtual

Evaluates this Expression by sending its output to DynamicContext::outputReceiver().

Reimplemented from QPatternist::Expression.

Definition at line 73 of file qdocumentconstructor.cpp.

74 {
75  QAbstractXmlReceiver *const receiver = context->outputReceiver();
76 
77  DocumentContentValidator validator(receiver, context, ConstPtr(this));
78 
79  const DynamicContext::Ptr receiverContext(context->createReceiverContext(&validator));
80 
81  validator.startDocument();
82  m_operand->evaluateToSequenceReceiver(receiverContext);
83  validator.endDocument();
84 }
A push interface for the XPath Data Model. Similar to SAX&#39;s ContentHandler.
QExplicitlySharedDataPointer< const Expression > ConstPtr
A smart pointer wrapping const Expression instances.
Receives QAbstractXmlReceiver events and validates that they are correct, before sending them on to a...
DynamicContext::Ptr createReceiverContext(QAbstractXmlReceiver *const receiver)
virtual QAbstractXmlReceiver * outputReceiver() const =0
virtual void evaluateToSequenceReceiver(const DynamicContext::Ptr &context) const

◆ expectedOperandTypes()

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

The first operand must be exactly one xs:string.

Implements QPatternist::Expression.

Definition at line 98 of file qdocumentconstructor.cpp.

99 {
100  SequenceType::List result;
102  return result;
103 }
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

◆ properties()

Expression::Properties DocumentConstructor::properties ( ) const
virtual
Returns
a bitwise OR'd value of properties, describing the characteristics of the expression. These properties affects how this Expression is treated in for example type checking stages.

The default implementation returns 0. Override and let the function return a different value, if that's of interest.

An important decision when re-implementing properties() is whether to OR in the properties() of ones operands. For instance, if an operand has RequiresFocus set, that flag nost likely applies to the apparent as well, since it depends on its operand.

See also
deepProperties()
Returns
Expression::None, meaning no special properties

Reimplemented from QPatternist::Expression.

Definition at line 105 of file qdocumentconstructor.cpp.

◆ staticType()

SequenceType::Ptr DocumentConstructor::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 93 of file qdocumentconstructor.cpp.

94 {
96 }
static const SequenceType::Ptr ExactlyOneDocumentNode

◆ typeCheck()

Expression::Ptr DocumentConstructor::typeCheck ( const StaticContext::Ptr context,
const SequenceType::Ptr reqType 
)
virtual

This implementation guarantees to never rewrite away this Expression, but at most rewrite it as a child of another expression(that presumably have a type checking role). It is therefore always safe to override this function and call this implementation and not worry about that this Expression becomes deleted.

Many Expressions override typeCheck() and performs optimizations, as opposed to doing it in the compress() stage. This is due to that the design of those Expressions often are tied to that certain simplifications are done at the typeCheck() stage of the compilation process or that it in some other way is related to what the typeCheck() do. Also, the earlier the AST can be simplified, the better the chances are for subsequent optimizations.

It is important that the super class's typeCheck() is called before doing any custom type checking, since the call can change the children(notably, the childrens' static types). For example, if the Expression, MyExpression in the example, does not match the required type, typeCheck returns the Expression wrapped in for example ItemVerifier, CardinalityVerifier, or both.

typeCheck() may be called many times. typeCheck() must either raise an error if this Expression is an invalid expression. Thus, it is guaranteed that an Expression is valid after typeCheck() is called.

Parameters
contextsupplies information, such as namespace bindings and available function signatures, that can be needed at compilation time. context is guaranteed by the caller to never null.
reqTypethe static type that this Expression must match when evaluated. reqType is guaranteed by the caller to never null.
Returns
an Expression that can be this Expression, or another expression, which somehow is necessary for making this Expression conforming to reqType

Reimplemented from QPatternist::Expression.

Definition at line 86 of file qdocumentconstructor.cpp.

88 {
89  m_staticBaseURI = context->baseURI();
90  return SingleContainer::typeCheck(context, reqType);
91 }
virtual Expression::Ptr typeCheck(const StaticContext::Ptr &context, const SequenceType::Ptr &reqType)
Definition: qexpression.cpp:70
virtual QUrl baseURI() const =0

Properties

◆ m_staticBaseURI

QUrl QPatternist::DocumentConstructor::m_staticBaseURI
private

Definition at line 95 of file qdocumentconstructor_p.h.

Referenced by evaluateSingleton(), and typeCheck().


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