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

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

#include <qsequencegeneratingfns_p.h>

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

Public Functions

virtual Item evaluateSingleton (const DynamicContext::Ptr &context) const
 
virtual SequenceType::Ptr staticType () const
 
virtual Expression::Ptr typeCheck (const StaticContext::Ptr &context, const SequenceType::Ptr &reqType)
 
- 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 FunctionSignature::Ptr signature () const
 
- 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 ()
 

Properties

SequenceType::Ptr m_type
 

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::StaticBaseUriContainer
void prepareStaticBaseURI (const StaticContext::Ptr &context)
 
const QUrlstaticBaseURI () const
 
 StaticBaseUriContainer ()
 
- 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:doc().

Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 117 of file qsequencegeneratingfns_p.h.

Functions

◆ evaluateSingleton()

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

Reimplemented from QPatternist::Expression.

Definition at line 226 of file qsequencegeneratingfns.cpp.

227 {
228  const Item itemURI(m_operands.first()->evaluateSingleton(context));
229 
230  if(!itemURI)
231  return Item();
232 
233  /* These two lines were previously in a separate function but are now duplicated
234  * in DocAvailableFN::evaluateEBV() and DocFN::typeCheck(),
235  * as part of a workaround for solaris-cc-64. DocFN::typeCheck() is in qsequencefns.cpp
236  * as part of that workaround. */
237  const QUrl mayRela(AnyURI::toQUrl<ReportContext::FODC0005>(itemURI.stringValue(), context, this));
238  const QUrl uri(resolveScheme(context->resolveURI(mayRela, staticBaseURI())));
239 
240  Q_ASSERT(uri.isValid());
241  Q_ASSERT(!uri.isRelative());
242 
243  const Item doc(context->resourceLoader()->openDocument(uri, context));
244 
245  return doc;
246 }
static QUrl resolveScheme(const QUrl &url)
Attemps to resolve scheme if URL does not have scheme defined.
QUrl resolveURI(const QUrl &relative, const QUrl &baseURI) const
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
virtual ResourceLoader::Ptr resourceLoader() const =0
virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const
virtual Item openDocument(const QUrl &uri, const ReportContext::Ptr &context)
Calls to this function are generated by calls to the fn:document() or fn:doc() function.

◆ staticType()

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

Reimplemented from QPatternist::FunctionCall.

Definition at line 248 of file qsequencegeneratingfns.cpp.

249 {
250  if(m_type)
251  return m_type;
252  else
254 }
static const SequenceType::Ptr ZeroOrOneDocumentNode

◆ typeCheck()

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

The implementation of this function is placed in a different compilation unit, namely qsequencefns.cpp, to workaround a compiler bug on solaris-cc-64, suspected to be related to the instantiation of QUrl::toQUrl().

See also
Sun, multiply-defined label for template instance, bug 6532605

Reimplemented from QPatternist::StaticBaseUriContainer.

Definition at line 308 of file qsequencefns.cpp.

310 {
311  /* See the doxygen documentation for this function for the explanation
312  * to why this implementation is here, as opposed to in
313  * qsequencegeneratingfns.cpp. */
314 
315  Q_ASSERT(context);
316 
317  prepareStaticBaseURI(context);
318 
319  const Expression::Ptr uriOp(m_operands.first());
320 
321  if(!uriOp->isEvaluated())
322  return Expression::Ptr(FunctionCall::typeCheck(context, reqType));
323 
324  const Item uriItem(uriOp->evaluateSingleton(context->dynamicContext()));
325 
326  if(!uriItem)
327  return EmptySequence::create(this, context)->typeCheck(context, reqType); // TODO test this
328 
329  /* These two lines were previously in a separate function but are now duplicated
330  * in DocFN::evaluateSingleton(), as part of a workaround for solaris-cc-64. */
331  const QUrl mayRela(AnyURI::toQUrl<ReportContext::FODC0005>(uriItem.stringValue(), context, this));
332  const QUrl uri(context->resolveURI(mayRela, staticBaseURI()));
333 
334  /* The URI is supplied statically, so, let's try to be clever. */
336  "No resource loader is set in the StaticContext.");
338 
339  if(m_type)
340  {
342  return Expression::Ptr(FunctionCall::typeCheck(context, reqType));
343  }
344  else
345  {
346  context->error(QtXmlPatterns::tr("It will not be possible to retrieve %1.").arg(formatURI(uri)),
348  return Expression::Ptr();
349  }
350 }
virtual Expression::Ptr typeCheck(const StaticContext::Ptr &context, const SequenceType::Ptr &reqType)
QUrl resolveURI(const QUrl &relative, const QUrl &baseURI) const
virtual Expression::Ptr typeCheck(const StaticContext::Ptr &context, const SequenceType::Ptr &reqType)
Definition: qexpression.cpp:70
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
static Expression::Ptr create(const Expression *const replacementFor, const StaticContext::Ptr &context)
Creates an EmptySequence that is a replacement for replacementFor.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual SequenceType::Ptr announceDocument(const QUrl &uri, const Usage usageHint)
May be called by the compilation framework at compile time to report that an XML document referenced ...
void error(const QString &message, const ReportContext::ErrorCode errorCode, const QSourceLocation &sourceLocation)
virtual ResourceLoader::Ptr resourceLoader() const =0
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QExplicitlySharedDataPointer< Expression > Ptr
A smart pointer wrapping mutable Expression instances.
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
static const SequenceType::Ptr ZeroOrOneDocumentNode
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
void prepareStaticBaseURI(const StaticContext::Ptr &context)
virtual QExplicitlySharedDataPointer< DynamicContext > dynamicContext() const =0
static QString formatURI(const NamePool::Ptr &np, const QXmlName::NamespaceCode &uri)
Formats uri, that&#39;s considered to be a URI, for display.
Definition: qanyuri_p.h:202
#define Q_FUNC_INFO
Definition: qglobal.h:1871

Properties

◆ m_type

SequenceType::Ptr QPatternist::DocFN::m_type
private

Definition at line 136 of file qsequencegeneratingfns_p.h.


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