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

A function factory that handles the builtin constructor functions, such as xs:time(). More...

#include <qconstructorfunctionsfactory_p.h>

Inheritance diagram for QPatternist::ConstructorFunctionsFactory:
QPatternist::AbstractFunctionFactory QPatternist::FunctionFactory QSharedData

Public Functions

 ConstructorFunctionsFactory (const NamePool::Ptr &np, const SchemaTypeFactory::Ptr &)
 
virtual FunctionSignature::Ptr retrieveFunctionSignature (const NamePool::Ptr &np, const QXmlName name)
 
- Public Functions inherited from QPatternist::AbstractFunctionFactory
virtual Expression::Ptr createFunctionCall (const QXmlName name, const Expression::List &arguments, const StaticContext::Ptr &context, const SourceLocationReflection *const r)
 
virtual FunctionSignature::Hash functionSignatures () const
 
- Public Functions inherited from QPatternist::FunctionFactory
bool hasSignature (const FunctionSignature::Ptr &signature) const
 
virtual bool isAvailable (const NamePool::Ptr &np, const QXmlName name, const xsInteger arity)
 
virtual ~FunctionFactory ()
 
- 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...
 

Protected Functions

virtual Expression::Ptr retrieveExpression (const QXmlName name, const Expression::List &args, const FunctionSignature::Ptr &sign) const
 
- Protected Functions inherited from QPatternist::AbstractFunctionFactory
FunctionSignature::Ptr addFunction (const QXmlName::LocalNameCode localName, const FunctionSignature::Arity minArgs, const FunctionSignature::Arity maxArgs, const SequenceType::Ptr &returnType, const Expression::Properties props)
 
FunctionSignature::Ptr addFunction (const QXmlName::LocalNameCode &localName, const FunctionSignature::Arity minArgs, const FunctionSignature::Arity maxArgs, const SequenceType::Ptr &returnType, const Expression::ID id=Expression::IDIgnorableExpression, const Expression::Properties props=Expression::Properties(), const StandardNamespaces::ID ns=StandardNamespaces::fn)
 
- Protected Functions inherited from QPatternist::FunctionFactory
 FunctionFactory ()
 This constructor cannot be removed, because it can't be synthesized, for some reason. More...
 

Properties

const SchemaTypeFactory::Ptr m_typeFactory
 

Additional Inherited Members

- Public Types inherited from QPatternist::FunctionFactory
typedef QList< FunctionFactory::PtrList
 
typedef QExplicitlySharedDataPointer< FunctionFactoryPtr
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 
- Static Protected Functions inherited from QPatternist::AbstractFunctionFactory
static QXmlName::LocalNameCode argument (const NamePool::Ptr &np, const char *const name)
 
- Protected Variables inherited from QPatternist::AbstractFunctionFactory
FunctionSignature::Hash m_signatures
 

Detailed Description

A function factory that handles the builtin constructor functions, such as xs:time().

See also
XML Path Language (XPath) 2.0, 3.10.4 Constructor Functions
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 74 of file qconstructorfunctionsfactory_p.h.

Constructors and Destructors

◆ ConstructorFunctionsFactory()

ConstructorFunctionsFactory::ConstructorFunctionsFactory ( const NamePool::Ptr np,
const SchemaTypeFactory::Ptr f 
)

Definition at line 59 of file qconstructorfunctionsfactory.cpp.

59  : m_typeFactory(f)
60 {
62  Q_ASSERT(np);
65 
68 
69  args.append(FunctionArgument::Ptr(new FunctionArgument(argName,
71 
72  while(it != end)
73  {
75  *BuiltinTypes::xsAnyAtomicType == *static_cast<const AtomicType *>((*it).data()) ||
76  *BuiltinTypes::xsNOTATION == *static_cast<const AtomicType *>((*it).data()))
77  {
78  /* It's not a valid type for a constructor function -- skip it. */
79  ++it;
80  continue;
81  }
82 
83  const QXmlName name((*it)->name(np));
85  makeGenericSequenceType(AtomicType::Ptr(*it),
87  s->setArguments(args);
89  ++it;
90  }
91 }
#define it(className, varName)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
const char * name
Represents the signature of an XPath function.
Carries meta data for a function argument as found in XPath&#39;s builtin functions and user declared fun...
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
static Cardinality zeroOrOne()
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
static bool wxsTypeMatches(const SchemaType::Ptr &type, const SchemaType::Ptr &otherType, QSet< SchemaType::Ptr > &visitedTypes, SchemaType::Ptr &conflictingType)
virtual SchemaType::Hash types() const =0
static const AtomicType::Ptr xsAnyAtomicType
static const SequenceType::Ptr ZeroOrOneAtomicType
static const KeyPair *const end
static const AtomicType::Ptr xsNOTATION

Functions

◆ retrieveExpression()

Expression::Ptr ConstructorFunctionsFactory::retrieveExpression ( const QXmlName  name,
const Expression::List args,
const FunctionSignature::Ptr sign 
) const
protectedvirtual

This function is responsible for creating the actual Expression, corresponding to localName and the function signature sign. It is called by createFunctionCall(), once it have been determined the function actually exists and have the correct arity.

This function will only be called for names in the fn namespace.

Implements QPatternist::AbstractFunctionFactory.

Definition at line 93 of file qconstructorfunctionsfactory.cpp.

96 {
97  Q_UNUSED(sign);
98 
99  /* This function is only called if the callsite is valid, so createSchemaType() will always
100  * return an AtomicType. */
101  const AtomicType::Ptr at(static_cast<AtomicType *>(m_typeFactory->createSchemaType(name).data()));
102 
103  return Expression::Ptr(new CastAs(args.first(),
104  makeGenericSequenceType(at,
106 }
#define at(className, varName)
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
Implements XPath 2.0&#39;s cast as expression.
Definition: qcastas_p.h:79
T * data() const
Returns a pointer to the shared data object.
Definition: qshareddata.h:145
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.
static Cardinality zeroOrOne()
virtual SchemaType::Ptr createSchemaType(const QXmlName name) const =0
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ retrieveFunctionSignature()

FunctionSignature::Ptr ConstructorFunctionsFactory::retrieveFunctionSignature ( const NamePool::Ptr np,
const QXmlName  name 
)
virtual

This is a convenience function for sub-classes. It retrieves the function signature for function with name name.

According to the specifications are function signatures identified by their name and arity, but currently is the arity not part of the signature.

If no function could be found for the given name, null is returned.

Implements QPatternist::FunctionFactory.

Definition at line 108 of file qconstructorfunctionsfactory.cpp.

109 {
110  Q_UNUSED(np);
111  return functionSignatures().value(name);
112 }
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
virtual FunctionSignature::Hash functionSignatures() const
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

Properties

◆ m_typeFactory

const SchemaTypeFactory::Ptr QPatternist::ConstructorFunctionsFactory::m_typeFactory
private

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