Qt 4.8
Public Functions | Static Private Functions | List of all members
QPatternist::AttributeConstructor Class Reference

Constructs an element node. This covers both computed and directly constructed element nodes. More...

#include <qattributeconstructor_p.h>

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

Public Functions

virtual ExpressionVisitorResult::Ptr accept (const ExpressionVisitor::Ptr &visitor) const
 
 AttributeConstructor (const Expression::Ptr &operand1, const Expression::Ptr &operand2)
 
virtual Item evaluateSingleton (const DynamicContext::Ptr &context) const
 
virtual void evaluateToSequenceReceiver (const DynamicContext::Ptr &context) const
 
virtual SequenceType::List expectedOperandTypes () const
 
virtual ID id () 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 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
 
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::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 Private Functions

static QString processValue (const QXmlName name, const Item &value)
 

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::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

Constructs an element node. This covers both computed and directly constructed element 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 72 of file qattributeconstructor_p.h.

Constructors and Destructors

◆ AttributeConstructor()

AttributeConstructor::AttributeConstructor ( const Expression::Ptr operand1,
const Expression::Ptr operand2 
)

Definition at line 54 of file qattributeconstructor.cpp.

55  : PairContainer(op1, op2)
56 {
57 }
PairContainer(const Expression::Ptr &operand1, const Expression::Ptr &operand2)

Functions

◆ accept()

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

Implements QPatternist::Expression.

Definition at line 117 of file qattributeconstructor.cpp.

118 {
119  return visitor->visit(this);
120 }

◆ evaluateSingleton()

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

Reimplemented from QPatternist::Expression.

Definition at line 70 of file qattributeconstructor.cpp.

71 {
72  const Item nameItem(m_operand1->evaluateSingleton(context));
73  const Item content(m_operand2->evaluateSingleton(context));
74 
75  const QXmlName name(nameItem.as<QNameValue>()->qName());
76  const QString value(processValue(name, content));
77  const NodeBuilder::Ptr nodeBuilder(context->nodeBuilder(QUrl()));
78 
79  nodeBuilder->attribute(name, QStringRef(&value));
80 
81  const QAbstractXmlNodeModel::Ptr nm(nodeBuilder->builtDocument());
82  context->addNodeModel(nm);
83  return nm->root(QXmlNodeModelIndex());
84 }
The QXmlNodeModelIndex class identifies a node in an XML node model subclassed from QAbstractXmlNodeM...
virtual void addNodeModel(const QAbstractXmlNodeModel::Ptr &nm)=0
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
QXmlName qName() const
Definition: qqnamevalue_p.h:96
const char * name
static QString processValue(const QXmlName name, const Item &value)
The QStringRef class provides a thin wrapper around QString substrings.
Definition: qstring.h:1099
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
Implements the value instance of the xs:QName type.
Definition: qqnamevalue_p.h:73
virtual NodeBuilder::Ptr nodeBuilder(const QUrl &baseURI) const =0
virtual void attribute(const QXmlName name, const QString &value)=0
Signals the presence of an attribute node.
virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const

◆ evaluateToSequenceReceiver()

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

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

Reimplemented from QPatternist::Expression.

Definition at line 86 of file qattributeconstructor.cpp.

87 {
88  QAbstractXmlReceiver *const receiver = context->outputReceiver();
89  const Item nameItem(m_operand1->evaluateSingleton(context));
90 
91  const Item content(m_operand2->evaluateSingleton(context));
92  const QXmlName name(nameItem.as<QNameValue>()->qName());
93  const QString value(processValue(name, content));
94 
95  receiver->attribute(name, QStringRef(&value));
96 }
A push interface for the XPath Data Model. Similar to SAX&#39;s ContentHandler.
The QString class provides a Unicode character string.
Definition: qstring.h:83
QXmlName qName() const
Definition: qqnamevalue_p.h:96
const char * name
static QString processValue(const QXmlName name, const Item &value)
The QStringRef class provides a thin wrapper around QString substrings.
Definition: qstring.h:1099
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
Implements the value instance of the xs:QName type.
Definition: qqnamevalue_p.h:73
virtual QAbstractXmlReceiver * outputReceiver() const =0
virtual void attribute(const QXmlName name, const QString &value)=0
Signals the presence of an attribute node.
virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const

◆ expectedOperandTypes()

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

The first operand must be exactly one xs:QName, and the second argument can be zero or more items.

Implements QPatternist::Expression.

Definition at line 103 of file qattributeconstructor.cpp.

104 {
105  SequenceType::List result;
108  return result;
109 }
static const SequenceType::Ptr ZeroOrMoreItems
static const SequenceType::Ptr ExactlyOneQName
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

◆ id()

Expression::ID AttributeConstructor::id ( ) const
virtual
Returns
always IDAttributeConstructor.

Reimplemented from QPatternist::Expression.

Definition at line 122 of file qattributeconstructor.cpp.

◆ processValue()

QString AttributeConstructor::processValue ( const QXmlName  name,
const Item value 
)
inlinestaticprivate

Definition at line 59 of file qattributeconstructor.cpp.

Referenced by evaluateSingleton(), and evaluateToSequenceReceiver().

61 {
62  if(!value)
63  return QString();
65  return value.stringValue().simplified();
66  else
67  return value.stringValue();
68 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString stringValue() const
Returns the string value of this Item.
Definition: qitem_p.h:302
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
QString simplified() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end, and that has each sequence o...
Definition: qstring.cpp:4415

◆ properties()

Expression::Properties AttributeConstructor::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 111 of file qattributeconstructor.cpp.

◆ staticType()

SequenceType::Ptr AttributeConstructor::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 98 of file qattributeconstructor.cpp.

99 {
101 }
static const SequenceType::Ptr ExactlyOneAttribute

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