Qt 4.8
Public Types | Public Functions | Static Public Functions | List of all members
QPatternist::FunctionFactoryCollection Class Reference

A FunctionFactoryCollection instance is a FunctionFactory in its own right, but looks in its contained collection of factories for requested functions. More...

#include <qfunctionfactorycollection_p.h>

Inheritance diagram for QPatternist::FunctionFactoryCollection:
QPatternist::FunctionFactory QList< T > QSharedData

Public Types

typedef QExplicitlySharedDataPointer< FunctionFactoryCollectionPtr
 
- Public Types inherited from QPatternist::FunctionFactory
typedef QList< FunctionFactory::PtrList
 
typedef QExplicitlySharedDataPointer< FunctionFactoryPtr
 
- Public Types inherited from QList< T >
typedef const value_typeconst_pointer
 Typedef for const T *. More...
 
typedef const value_typeconst_reference
 Typedef for const T &. More...
 
typedef const_iterator ConstIterator
 Qt-style synonym for QList::const_iterator. More...
 
typedef qptrdiff difference_type
 Typedef for ptrdiff_t. More...
 
typedef iterator Iterator
 Qt-style synonym for QList::iterator. More...
 
typedef value_typepointer
 Typedef for T *. More...
 
typedef value_typereference
 Typedef for T &. More...
 
typedef int size_type
 Typedef for int. More...
 
typedef T value_type
 Typedef for T. More...
 

Public Functions

virtual Expression::Ptr createFunctionCall (const QXmlName, const Expression::List &arguments, const StaticContext::Ptr &context, const SourceLocationReflection *const r)
 
virtual FunctionSignature::Hash functionSignatures () const
 
virtual bool isAvailable (const NamePool::Ptr &np, const QXmlName name, const xsInteger arity)
 
virtual FunctionSignature::Ptr retrieveFunctionSignature (const NamePool::Ptr &np, const QXmlName name)
 
- Public Functions inherited from QPatternist::FunctionFactory
bool hasSignature (const FunctionSignature::Ptr &signature) const
 
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...
 
- Public Functions inherited from QList< T >
void append (const T &t)
 Inserts value at the end of the list. More...
 
void append (const QList< T > &t)
 Appends the items of the value list to this list. More...
 
const T & at (int i) const
 Returns the item at index position i in the list. More...
 
T & back ()
 This function is provided for STL compatibility. More...
 
const T & back () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
iterator begin ()
 Returns an STL-style iterator pointing to the first item in the list. More...
 
const_iterator begin () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void clear ()
 Removes all items from the list. More...
 
const_iterator constBegin () const
 Returns a const STL-style iterator pointing to the first item in the list. More...
 
const_iterator constEnd () const
 Returns a const STL-style iterator pointing to the imaginary item after the last item in the list. More...
 
QBool contains (const T &t) const
 Returns true if the list contains an occurrence of value; otherwise returns false. More...
 
int count (const T &t) const
 Returns the number of occurrences of value in the list. More...
 
int count () const
 Returns the number of items in the list. More...
 
void detach ()
 
void detachShared ()
 This prevents needless mallocs, and makes QList more exception safe in case of cleanup work done in destructors on empty lists. More...
 
bool empty () const
 This function is provided for STL compatibility. More...
 
iterator end ()
 Returns an STL-style iterator pointing to the imaginary item after the last item in the list. More...
 
const_iterator end () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
bool endsWith (const T &t) const
 Returns true if this list is not empty and its last item is equal to value; otherwise returns false. More...
 
iterator erase (iterator pos)
 Removes the item associated with the iterator pos from the list, and returns an iterator to the next item in the list (which may be end()). More...
 
iterator erase (iterator first, iterator last)
 Removes all the items from begin up to (but not including) end. More...
 
T & first ()
 Returns a reference to the first item in the list. More...
 
const T & first () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
T & front ()
 This function is provided for STL compatibility. More...
 
const T & front () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
int indexOf (const T &t, int from=0) const
 Returns the index position of the first occurrence of value in the list, searching forward from index position from. More...
 
void insert (int i, const T &t)
 Inserts value at index position i in the list. More...
 
iterator insert (iterator before, const T &t)
 Inserts value in front of the item pointed to by the iterator before. More...
 
bool isDetached () const
 
bool isEmpty () const
 Returns true if the list contains no items; otherwise returns false. More...
 
bool isSharedWith (const QList< T > &other) const
 
T & last ()
 Returns a reference to the last item in the list. More...
 
const T & last () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
int lastIndexOf (const T &t, int from=-1) const
 Returns the index position of the last occurrence of value in the list, searching backward from index position from. More...
 
int length () const
 This function is identical to count(). More...
 
QList< T > mid (int pos, int length=-1) const
 Returns a list whose elements are copied from this list, starting at position pos. More...
 
void move (int from, int to)
 Moves the item at index position from to index position to. More...
 
bool operator!= (const QList< T > &l) const
 Returns true if other is not equal to this list; otherwise returns false. More...
 
QList< T > operator+ (const QList< T > &l) const
 Returns a list that contains all the items in this list followed by all the items in the other list. More...
 
QList< T > & operator+= (const QList< T > &l)
 Appends the items of the other list to this list and returns a reference to this list. More...
 
QList< T > & operator+= (const T &t)
 Appends value to the list. More...
 
QList< T > & operator<< (const QList< T > &l)
 Appends the items of the other list to this list and returns a reference to this list. More...
 
QList< T > & operator<< (const T &t)
 Appends value to the list. More...
 
QList< T > & operator= (const QList< T > &l)
 Assigns other to this list and returns a reference to this list. More...
 
bool operator== (const QList< T > &l) const
 Returns true if other is equal to this list; otherwise returns false. More...
 
const T & operator[] (int i) const
 Same as at(). More...
 
T & operator[] (int i)
 Returns the item at index position i as a modifiable reference. More...
 
void pop_back ()
 This function is provided for STL compatibility. More...
 
void pop_front ()
 This function is provided for STL compatibility. More...
 
void prepend (const T &t)
 Inserts value at the beginning of the list. More...
 
void push_back (const T &t)
 This function is provided for STL compatibility. More...
 
void push_front (const T &t)
 This function is provided for STL compatibility. More...
 
 QList ()
 Constructs an empty list. More...
 
 QList (const QList< T > &l)
 Constructs a copy of other. More...
 
int removeAll (const T &t)
 Removes all occurrences of value in the list and returns the number of entries removed. More...
 
void removeAt (int i)
 Removes the item at index position i. More...
 
void removeFirst ()
 Removes the first item in the list. More...
 
void removeLast ()
 Removes the last item in the list. More...
 
bool removeOne (const T &t)
 Removes the first occurrence of value in the list and returns true on success; otherwise returns false. More...
 
void replace (int i, const T &t)
 Replaces the item at index position i with value. More...
 
void reserve (int size)
 Reserve space for alloc elements. More...
 
void setSharable (bool sharable)
 
int size () const
 Returns the number of items in the list. More...
 
bool startsWith (const T &t) const
 Returns true if this list is not empty and its first item is equal to value; otherwise returns false. More...
 
void swap (QList< T > &other)
 Swaps list other with this list. More...
 
void swap (int i, int j)
 Exchange the item at index position i with the item at index position j. More...
 
takeAt (int i)
 Removes the item at index position i and returns it. More...
 
takeFirst ()
 Removes the first item in the list and returns it. More...
 
takeLast ()
 Removes the last item in the list and returns it. More...
 
QSet< T > toSet () const
 Returns a QSet object with the data contained in this QList. More...
 
std::list< T > toStdList () const
 Returns a std::list object with the data contained in this QList. More...
 
QVector< T > toVector () const
 Returns a QVector object with the data contained in this QList. More...
 
value (int i) const
 Returns the value at index position i in the list. More...
 
value (int i, const T &defaultValue) const
 If the index i is out of bounds, the function returns defaultValue. More...
 
 ~QList ()
 Destroys the list. More...
 

Static Public Functions

static FunctionFactory::Ptr xpath10Factory ()
 
static FunctionFactory::Ptr xpath20Factory (const NamePool::Ptr &np)
 
static FunctionFactory::Ptr xslt20Factory (const NamePool::Ptr &np)
 
- Static Public Functions inherited from QList< T >
static QList< T > fromSet (const QSet< T > &set)
 Returns a QList object with the data contained in set. More...
 
static QList< T > fromStdList (const std::list< T > &list)
 Returns a QList object with the data contained in list. More...
 
static QList< T > fromVector (const QVector< T > &vector)
 Returns a QList object with the data contained in vector. More...
 

Additional Inherited Members

- Public Variables inherited from QSharedData
QAtomicInt ref
 
- Protected Functions inherited from QPatternist::FunctionFactory
 FunctionFactory ()
 This constructor cannot be removed, because it can't be synthesized, for some reason. More...
 

Detailed Description

A FunctionFactoryCollection instance is a FunctionFactory in its own right, but looks in its contained collection of factories for requested functions.

Note
the order of adding function libraries is significant.
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 73 of file qfunctionfactorycollection_p.h.

Typedefs

◆ Ptr

Definition at line 78 of file qfunctionfactorycollection_p.h.

Functions

◆ createFunctionCall()

Expression::Ptr FunctionFactoryCollection::createFunctionCall ( const QXmlName  name,
const Expression::List arguments,
const StaticContext::Ptr context,
const SourceLocationReflection *const  r 
)
virtual

Creates a function call node.

Implements QPatternist::FunctionFactory.

Definition at line 55 of file qfunctionfactorycollection.cpp.

59 {
62  Expression::Ptr function;
63 
64  for(it = constBegin(); it != e; ++it)
65  {
66  function = (*it)->createFunctionCall(name, arguments, context, r);
67 
68  if(function)
69  break;
70  }
71 
72  return function;
73 }
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
friend class const_iterator
Definition: qlist.h:264
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272

◆ functionSignatures()

FunctionSignature::Hash FunctionFactoryCollection::functionSignatures ( ) const
virtual

Implements QPatternist::FunctionFactory.

Definition at line 87 of file qfunctionfactorycollection.cpp.

Referenced by retrieveFunctionSignature().

88 {
89  /* We simply grab the function signatures for each library, and
90  * put them all in one list. */
91 
92  const const_iterator e(constEnd());
94 
95  for(const_iterator it(constBegin()); it != e; ++it)
96  {
97  const FunctionSignature::Hash::const_iterator e2((*it)->functionSignatures().constEnd());
98  FunctionSignature::Hash::const_iterator sit((*it)->functionSignatures().constBegin());
99 
100  for(; sit != e2; ++sit)
101  result.insert(sit.key(), sit.value());
102  }
103 
104  return result;
105 }
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
friend class const_iterator
Definition: qlist.h:264
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272

◆ isAvailable()

bool FunctionFactoryCollection::isAvailable ( const NamePool::Ptr np,
const QXmlName  name,
const xsInteger  arity 
)
virtual

Determines whether a function with the name name and arity arity is available. The implementation operates on the result of retrieveFunctionSignature() to determine the result.

Parameters
npthe NamePool.
namethe name of the function. For example fn:string-join.
aritythe number of arguments the function must have.

Reimplemented from QPatternist::FunctionFactory.

Definition at line 75 of file qfunctionfactorycollection.cpp.

76 {
79 
80  for(it = constBegin(); it != e; ++it)
81  if((*it)->isAvailable(np, name, arity))
82  return true;
83 
84  return false;
85 }
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
friend class const_iterator
Definition: qlist.h:264
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272

◆ retrieveFunctionSignature()

FunctionSignature::Ptr FunctionFactoryCollection::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 107 of file qfunctionfactorycollection.cpp.

108 {
109  return functionSignatures().value(name);
110 }
virtual FunctionSignature::Hash functionSignatures() const
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606

◆ xpath10Factory()

FunctionFactory::Ptr FunctionFactoryCollection::xpath10Factory ( )
static
Returns
a FunctionFactory containing all core functions required for XPath 1.0.

Definition at line 112 of file qfunctionfactorycollection.cpp.

Referenced by xpath20Factory().

113 {
114  /* We don't use a global static for caching this, because AbstractFunctionFactory
115  * stores state specific to the NamePool, when being used. */
117 }
Supplies the functions available in XPath 1.0.
QExplicitlySharedDataPointer< FunctionFactory > Ptr

◆ xpath20Factory()

FunctionFactory::Ptr FunctionFactoryCollection::xpath20Factory ( const NamePool::Ptr np)
static
Returns
a FunctionFactory containing all core functions and constructor functions required for XPath 2.. The functions specified for XQuery 1.0 are the same as for XPath 2.0 so this FunctionFactory work for XQuery as well.

Definition at line 119 of file qfunctionfactorycollection.cpp.

Referenced by QXmlQueryPrivate::staticContext(), and xslt20Factory().

120 {
121  /* We don't use a global static for caching this, because AbstractFunctionFactory
122  * stores state specific to the NamePool, when being used. */
124  fact->append(xpath10Factory());
125  fact->append(FunctionFactory::Ptr(new XPath20CoreFunctions()));
126  fact->append(FunctionFactory::Ptr(
128  return fact;
129 }
static SchemaTypeFactory::Ptr self(const NamePool::Ptr &np)
Handles the functions defines in XQuery 1.0 and XPath 2.0 Function and Operators, except those also a...
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
A function factory that handles the builtin constructor functions, such as xs:time().
A FunctionFactoryCollection instance is a FunctionFactory in its own right, but looks in its containe...

◆ xslt20Factory()

FunctionFactory::Ptr FunctionFactoryCollection::xslt20Factory ( const NamePool::Ptr np)
static
Returns
a FunctionFactory containing all core functions required for XSL-T 2.0 functions.

Definition at line 131 of file qfunctionfactorycollection.cpp.

Referenced by QXmlQueryPrivate::staticContext().

132 {
133  const FunctionFactory::Ptr retval(xpath20Factory(np));
134  static_cast<FunctionFactoryCollection *>(retval.data())->append(FunctionFactory::Ptr(new XSLT20CoreFunctions()));
135  return retval;
136 }
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
Handles the functions defines in XSL-T 2.0, except those also available in XPath 2.0.
A FunctionFactoryCollection instance is a FunctionFactory in its own right, but looks in its containe...
static FunctionFactory::Ptr xpath20Factory(const NamePool::Ptr &np)

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