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

Implements the function fn:error(). More...

#include <qerrorfn_p.h>

Inheritance diagram for QPatternist::ErrorFN:
QPatternist::FunctionCall QPatternist::UnlimitedContainer QPatternist::Expression QSharedData QPatternist::CppCastingHelper< Expression > QPatternist::SourceLocationReflection

Public Functions

virtual Item evaluateSingleton (const DynamicContext::Ptr &context) const
 
virtual FunctionSignature::Ptr signature () const
 
- Public Functions inherited from QPatternist::FunctionCall
virtual ExpressionVisitorResult::Ptr accept (const ExpressionVisitor::Ptr &visitor) const
 
virtual SequenceType::List expectedOperandTypes () const
 
virtual ID id () const
 
virtual Expression::Properties properties () const
 
virtual void setSignature (const FunctionSignature::Ptr &sign)
 
virtual SequenceType::Ptr staticType () const
 
virtual Expression::Ptr typeCheck (const StaticContext::Ptr &context, const SequenceType::Ptr &reqType)
 
- Public Functions inherited from QPatternist::UnlimitedContainer
virtual bool compressOperands (const StaticContext::Ptr &)
 
virtual Expression::List operands () const
 
virtual void setOperands (const Expression::List &list)
 
 UnlimitedContainer (const Expression::List &operands=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 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
 
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 ()
 

Additional Inherited Members

- Public Types inherited from QPatternist::FunctionCall
typedef QExplicitlySharedDataPointer< FunctionCallPtr
 
- Public Types inherited from QPatternist::UnlimitedContainer
enum  CardinalityComputation { ProductOfCardinality, UnionOfCardinality }
 
- 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::UnlimitedContainer
template<CardinalityComputation suppliedCard>
SequenceType::Ptr operandsUnionType () const
 
- 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::UnlimitedContainer
Expression::List m_operands
 

Detailed Description

Implements the function fn:error().

fn:error() is a bit special in that its first argument varies between the different signatures. This is implemented by changing the function signature if the amount of arguments is one.

fn:error() has as return type the peculiar "none" type, which is handled by NoneType.

See also
CommonSequenceTypes::none
XQuery 1.0 and XPath 2.0 Functions and Operators, 3 The Error Function
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 79 of file qerrorfn_p.h.

Functions

◆ evaluateSingleton()

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

Reimplemented from QPatternist::Expression.

Definition at line 53 of file qerrorfn.cpp.

54 {
55  QString msg;
56 
57  switch(m_operands.count())
58  {
59  case 0: /* No args. */
60  {
61  context->error(QtXmlPatterns::tr("%1 was called.").arg(formatFunction(context->namePool(), signature())),
63  return Item();
64  }
65  case 3:
66  /* Fallthrough, we don't use the 'error object' param. */
67  case 2:
68  msg = m_operands.at(1)->evaluateSingleton(context).stringValue();
69  /* Fall through. */
70  case 1:
71  {
72  const QNameValue::Ptr qName(m_operands.first()->evaluateSingleton(context).as<QNameValue>());
73 
74  if(qName)
75  context->error(msg, qName->qName(), this);
76  else
77  context->error(msg, ReportContext::FOER0000, this);
78 
79  return Item();
80  }
81  default:
82  {
83  Q_ASSERT_X(false, Q_FUNC_INFO,
84  "Invalid number of arguments passed to fn:error.");
85  return Item();
86  }
87  }
88 }
virtual NamePool::Ptr namePool() const =0
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
void error(const QString &message, const ReportContext::ErrorCode errorCode, const QSourceLocation &sourceLocation)
static QString formatFunction(const NamePool::Ptr &np, const FunctionSignature::Ptr &func)
Formats FunctionSignature.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QString stringValue() const
Returns the string value of this Item.
Definition: qitem_p.h:302
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
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
TCastTarget * as() const
Definition: qitem_p.h:278
virtual FunctionSignature::Ptr signature() const
Definition: qerrorfn.cpp:90
virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ signature()

FunctionSignature::Ptr ErrorFN::signature ( ) const
virtual

Reimplemented from QPatternist::FunctionCall.

Definition at line 90 of file qerrorfn.cpp.

Referenced by evaluateSingleton().

91 {
93 
94  if(m_operands.count() != 1)
95  return e;
96 
98  e->minimumArguments(),
99  e->maximumArguments(),
100  e->returnType(),
101  e->properties())));
102  const FunctionArgument::List args(e->arguments());
106  nargs.append(args[1]);
107  nargs.append(args[2]);
108  nev->setArguments(nargs);
109 
110  return nev;
111 }
static const SequenceType::Ptr ExactlyOneQName
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
Represents the signature of an XPath function.
virtual FunctionSignature::Ptr signature() const
Carries meta data for a function argument as found in XPath&#39;s builtin functions and user declared fun...
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58

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