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

Houses an AtomicValue, making it available as an Expression. More...

#include <qliteral_p.h>

Inheritance diagram for QPatternist::Literal:
QPatternist::EmptyContainer QPatternist::Expression QSharedData QPatternist::CppCastingHelper< Expression > QPatternist::SourceLocationReflection DelegatingReflectionExpression

Public Functions

virtual ExpressionVisitorResult::Ptr accept (const ExpressionVisitor::Ptr &visitor) const
 
virtual QString description () const
 
virtual bool evaluateEBV (const DynamicContext::Ptr &context) const
 
virtual Item evaluateSingleton (const DynamicContext::Ptr &context) const
 
void evaluateToSequenceReceiver (const DynamicContext::Ptr &context) const
 
virtual ID id () const
 
Item item () const
 
 Literal (const Item &item)
 
virtual Properties properties () const
 
virtual SequenceType::Ptr staticType () const
 
- Public Functions inherited from QPatternist::EmptyContainer
virtual Expression::List operands () const
 
virtual void setOperands (const Expression::List &)
 
- 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 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 ()
 

Properties

const Item m_item
 

Related Functions

(Note that these are not member functions.)

Expression::Ptr wrapLiteral (const Item &item, const StaticContext::Ptr &context, const SourceLocationReflection *const r)
 Creates a Literal that wraps item, and returns it. More...
 

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::EmptyContainer
virtual bool compressOperands (const StaticContext::Ptr &context)
 
virtual SequenceType::List expectedOperandTypes () const
 
- Protected Functions inherited from QPatternist::Expression
void typeCheckOperands (const StaticContext::Ptr &context)
 
- Protected Functions inherited from QPatternist::CppCastingHelper< Expression >
 CppCastingHelper ()
 

Detailed Description

Houses an AtomicValue, making it available as an Expression.

This is not only literals that can be created via the XQuery syntax(strings and numbers), but all other atomic values, such as xs:date or xs:time.

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

Definition at line 74 of file qliteral_p.h.

Constructors and Destructors

◆ Literal()

Literal::Literal ( const Item item)

Creates a Literal that represents item.

Parameters
itemmust be non-null and cannot be a QXmlNodeModelIndex.

Definition at line 53 of file qliteral.cpp.

Referenced by wrapLiteral().

53  : m_item(i)
54 {
57 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool isAtomicValue() const
Determines whether this item is an atomic value, or a node.
Definition: qitem_p.h:335

Functions

◆ accept()

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

Implements QPatternist::Expression.

Definition at line 79 of file qliteral.cpp.

80 {
81  return visitor->visit(this);
82 }

◆ description()

QString Literal::description ( ) const
virtual

Reimplementation of SourceLocationReflection::description().

Reimplemented from QPatternist::Expression.

Definition at line 109 of file qliteral.cpp.

110 {
111  return m_item.stringValue();
112 }
QString stringValue() const
Returns the string value of this Item.
Definition: qitem_p.h:302

◆ evaluateEBV()

bool Literal::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 64 of file qliteral.cpp.

65 {
66  return Boolean::evaluateEBV(m_item, context);
67 }
static bool evaluateEBV(const Item::Iterator::Ptr &e, const QExplicitlySharedDataPointer< DynamicContext > &)
Definition: qboolean.cpp:55

◆ evaluateSingleton()

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

Reimplemented from QPatternist::Expression.

Definition at line 59 of file qliteral.cpp.

60 {
61  return m_item;
62 }

◆ evaluateToSequenceReceiver()

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

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

Reimplemented from QPatternist::Expression.

Definition at line 69 of file qliteral.cpp.

70 {
71  context->outputReceiver()->item(m_item);
72 }
virtual void item(const Item &item)=0
Sends an Item to this QAbstractXmlReceiver that may be a QXmlNodeModelIndex or an AtomicValue...
virtual QAbstractXmlReceiver * outputReceiver() const =0

◆ id()

Expression::ID Literal::id ( ) const
virtual

This property, which has no setter, returns an enum value that uniquely identifies this Expression. Patternist makes no use of C++'s dynamic_cast feature, but uses this polymorphic function instead.

Returns
always IgnorableExpression.

Reimplemented from QPatternist::Expression.

Definition at line 84 of file qliteral.cpp.

85 {
88  const ItemType::Ptr t(m_item.type());
89 
90  if(BuiltinTypes::xsBoolean->xdtTypeMatches(t))
91  return IDBooleanValue;
92  else if(BuiltinTypes::xsString->xdtTypeMatches(t) ||
93  BuiltinTypes::xsAnyURI->xdtTypeMatches(t) ||
94  BuiltinTypes::xsUntypedAtomic->xdtTypeMatches(t))
95  {
96  return IDStringValue;
97  }
98  else if(BuiltinTypes::xsInteger->xdtTypeMatches(t))
99  return IDIntegerValue;
100  else
101  return IDFloat;
102 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static const AtomicType::Ptr xsString
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
static const AtomicType::Ptr xsInteger
static const AtomicType::Ptr xsBoolean
static const AtomicType::Ptr xsAnyURI

◆ item()

Item QPatternist::Literal::item ( ) const
inline

Declaring the return value of this function a const reference, leads to crashes in patternistview, for a to me unknown reason.

Definition at line 102 of file qliteral_p.h.

Referenced by QPatternist::CastAs::castToQName().

103  {
104  return m_item;
105  }

◆ properties()

Expression::Properties Literal::properties ( ) const
virtual
Returns
Expression::DisableElimination and Expression::IsEvaluated

Reimplemented from QPatternist::Expression.

Definition at line 104 of file qliteral.cpp.

◆ staticType()

SequenceType::Ptr Literal::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 74 of file qliteral.cpp.

75 {
76  return makeGenericSequenceType(m_item.type(), Cardinality::exactlyOne());
77 }
QExplicitlySharedDataPointer< ItemType > type() const
Returns the ItemType this Item is of.
Definition: qitem_p.h:365
static Cardinality exactlyOne()

Friends and Related Functions

◆ wrapLiteral()

Expression::Ptr wrapLiteral ( const Item item,
const StaticContext::Ptr context,
const SourceLocationReflection *const  r 
)
related

Creates a Literal that wraps item, and returns it.

This simplifies code. Instead of writing:

One can write:

This function is not declared static, because it breaks the build on at least aix-xlc-64.

Definition at line 131 of file qliteral_p.h.

134  {
135  Q_ASSERT(item);
136 
137  const Expression::Ptr retval(new Literal(item));
138  context->addLocation(retval.data(), context->locationFor(r));
139 
140  return retval;
141  }
Literal(const Item &item)
Definition: qliteral.cpp:53
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QExplicitlySharedDataPointer< Expression > Ptr
A smart pointer wrapping mutable Expression instances.

Properties

◆ m_item

const Item QPatternist::Literal::m_item
private

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