Qt 4.8
Protected Functions | List of all members
QPatternist::XPath10CoreFunctions Class Reference

Supplies the functions available in XPath 1.0. More...

#include <qxpath10corefunctions_p.h>

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

Protected Functions

virtual Expression::Ptr retrieveExpression (const QXmlName name, const Expression::List &args, const FunctionSignature::Ptr &sign) const
 
virtual FunctionSignature::Ptr retrieveFunctionSignature (const NamePool::Ptr &np, const QXmlName name)
 
- 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...
 

Additional Inherited Members

- Public Types inherited from QPatternist::FunctionFactory
typedef QList< FunctionFactory::PtrList
 
typedef QExplicitlySharedDataPointer< FunctionFactoryPtr
 
- 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...
 
- 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

Supplies the functions available in XPath 1.0.

See also
XML Path Language (XPath) Version 1.0, 4 Core Function Library
XPath20CoreFunctions
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 73 of file qxpath10corefunctions_p.h.

Functions

◆ retrieveExpression()

Expression::Ptr XPath10CoreFunctions::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.

Implements QPatternist::AbstractFunctionFactory.

Definition at line 68 of file qxpath10corefunctions.cpp.

71 {
72  Q_ASSERT(sign);
73 
74  Expression::Ptr fn;
75 #define testFN(ln, cname) else if(name.localName() == StandardLocalNames::ln) fn = Expression::Ptr(new cname())
76 
77  if(false) /* Dummy for the macro handling. Will be optimized away anyway. */
78  return Expression::Ptr();
79  /* Alphabetic order. */
80  testFN(boolean, BooleanFN);
81  testFN(ceiling, CeilingFN);
82  testFN(concat, ConcatFN);
83  testFN(contains, ContainsFN);
84  testFN(count, CountFN);
85  testFN(False, FalseFN);
86  testFN(floor, FloorFN);
87  testFN(id, IdFN);
88  testFN(lang, LangFN);
89  testFN(last, LastFN);
90  testFN(local_name, LocalNameFN);
91  testFN(name, NameFN);
92  testFN(namespace_uri, NamespaceURIFN);
93  testFN(normalize_space, NormalizeSpaceFN);
94  testFN(Not, NotFN);
95  testFN(number, NumberFN);
97  testFN(round, RoundFN);
98  testFN(starts_with, StartsWithFN);
99  testFN(string, StringFN);
100  testFN(string_length, StringLengthFN);
101  testFN(substring, SubstringFN);
102  testFN(substring_after, SubstringAfterFN);
103  testFN(substring_before, SubstringBeforeFN);
104  testFN(sum, SumFN);
105  testFN(translate, TranslateFN);
106  testFN(True, TrueFN);
107 #undef testFN
108 
109  Q_ASSERT(fn);
110  fn->setOperands(args);
111  fn->as<FunctionCall>()->setSignature(sign);
112 
113  return fn;
114 }
Base class for implementations of builtin functions.
virtual void setOperands(const Expression::List &operands)=0
Implements the function fn:concat().
Implements the function fn:string().
Implements the function fn:number().
Definition: qnodefns_p.h:117
#define testFN(ln, cname)
Implements the function fn:name().
Definition: qnodefns_p.h:79
Implements the function fn:sum().
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
Implements the function fn:last().
Definition: qcontextfns_p.h:94
Implements the function fn:ceiling().
Implements the function fn:normalize-space().
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Implements the function fn:lang().
Definition: qnodefns_p.h:146
Implements the function fn:starts-with().
Implements the function fn:local-name().
Definition: qnodefns_p.h:91
const TCastTarget * as() const
Implements the function fn:false().
Definition: qbooleanfns_p.h:95
Implements the function fn:substring-before().
Implements the function fn:substring().
Implements the function fn:namespace-uri().
Definition: qnodefns_p.h:103
Implements the function fn:round().
Implements the function fn:true().
Definition: qbooleanfns_p.h:81
QExplicitlySharedDataPointer< Expression > Ptr
A smart pointer wrapping mutable Expression instances.
Implements the function fn:string-length().
Implements the function fn:count().
Implements the function fn:contains().
Implements the function fn:id().
Implements the function fn:floor().
Definition: qnumericfns_p.h:79
Implements the function fn:substring-after().
Implements the function fn:position().
Definition: qcontextfns_p.h:80
Implements the function fn:boolean().
Implements the function fn:not().
Implements the function fn:translate().

◆ retrieveFunctionSignature()

FunctionSignature::Ptr XPath10CoreFunctions::retrieveFunctionSignature ( const NamePool::Ptr np,
const QXmlName  name 
)
protectedvirtual

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 116 of file qxpath10corefunctions.cpp.

117 {
119  return FunctionSignature::Ptr();
120 
122 
123  if(!s)
124  {
125  const QXmlName::LocalNameCode localName(name.localName());
126 
127  /* Alphabetic order. */
128  if(StandardLocalNames::boolean == localName)
129  {
131  s->appendArgument(argument(np, "arg"), CommonSequenceTypes::EBV);
132  }
133  else if(StandardLocalNames::ceiling == localName)
134  {
137  s->appendArgument(argument(np, "arg"), CommonSequenceTypes::ZeroOrOneNumeric);
138  }
139  else if(StandardLocalNames::concat == localName)
140  {
143  s->appendArgument(argument(np, "arg1"), CommonSequenceTypes::ZeroOrOneAtomicType);
144  s->appendArgument(argument(np, "arg2"), CommonSequenceTypes::ZeroOrOneAtomicType);
145  }
146  else if(StandardLocalNames::contains == localName)
147  {
150  s->appendArgument(argument(np, "arg1"), CommonSequenceTypes::ZeroOrOneString);
151  s->appendArgument(argument(np, "arg2"), CommonSequenceTypes::ZeroOrOneString);
152  s->appendArgument(argument(np, "collation"), CommonSequenceTypes::ExactlyOneString);
153  }
154  else if(StandardLocalNames::count == localName)
155  {
157  s->appendArgument(argument(np, "arg"), CommonSequenceTypes::ZeroOrMoreItems);
158  }
159  else if(StandardLocalNames::False == localName)
160  {
162  }
163  else if(StandardLocalNames::floor == localName)
164  {
167  s->appendArgument(argument(np, "arg"), CommonSequenceTypes::ZeroOrOneNumeric);
168  }
169  else if(StandardLocalNames::id == localName)
170  {
173  s->appendArgument(argument(np, "idrefs"), CommonSequenceTypes::ZeroOrMoreStrings);
174  s->appendArgument(argument(np, "node"), CommonSequenceTypes::ExactlyOneNode);
175  }
176  else if(StandardLocalNames::lang == localName)
177  {
180  s->appendArgument(argument(np, "testLang"), CommonSequenceTypes::ZeroOrOneString);
181  s->appendArgument(argument(np, "node"), CommonSequenceTypes::ExactlyOneNode);
182  }
183  else if(StandardLocalNames::last == localName)
184  {
187  }
188  else if(StandardLocalNames::local_name == localName)
189  {
192  s->appendArgument(argument(np, "arg"), CommonSequenceTypes::ZeroOrOneNode);
193  }
194  else if(StandardLocalNames::name == localName)
195  {
198  s->appendArgument(argument(np, "arg"), CommonSequenceTypes::ZeroOrOneNode);
199  }
200  else if(StandardLocalNames::namespace_uri == localName)
201  {
204  s->appendArgument(argument(np, "arg"), CommonSequenceTypes::ZeroOrOneNode);
205  }
206  else if(StandardLocalNames::normalize_space == localName)
207  {
210  s->appendArgument(argument(np, "arg"), CommonSequenceTypes::ZeroOrOneString);
211  }
212  else if(StandardLocalNames::Not == localName)
213  {
215  s->appendArgument(argument(np, "arg"), CommonSequenceTypes::EBV);
216  }
217  else if(StandardLocalNames::number == localName)
218  {
221  s->appendArgument(argument(np, "arg"), CommonSequenceTypes::ZeroOrOneAtomicType);
222  }
223  else if(StandardLocalNames::position == localName)
224  {
227  }
228  else if(StandardLocalNames::round == localName)
229  {
232  s->appendArgument(argument(np, "arg"), CommonSequenceTypes::ZeroOrOneNumeric);
233  }
234  else if(StandardLocalNames::starts_with == localName)
235  {
238  s->appendArgument(argument(np, "arg1"), CommonSequenceTypes::ZeroOrOneString);
239  s->appendArgument(argument(np, "arg2"), CommonSequenceTypes::ZeroOrOneString);
240  s->appendArgument(argument(np, "collation"), CommonSequenceTypes::ExactlyOneString);
241  }
242  else if(StandardLocalNames::string == localName)
243  {
246  s->appendArgument(argument(np, "arg"), CommonSequenceTypes::ZeroOrOneItem);
247  }
248  else if(StandardLocalNames::string_length == localName)
249  {
253  s->appendArgument(argument(np, "arg"), CommonSequenceTypes::ZeroOrOneString);
254  }
255  else if(StandardLocalNames::substring == localName)
256  {
258  s->appendArgument(argument(np, "sourceString"), CommonSequenceTypes::ZeroOrOneString);
259  s->appendArgument(argument(np, "startingLoc"), CommonSequenceTypes::ExactlyOneDouble);
260  s->appendArgument(argument(np, "length"), CommonSequenceTypes::ExactlyOneDouble);
261  }
262  else if(StandardLocalNames::substring_after == localName)
263  {
266  s->appendArgument(argument(np, "arg1"), CommonSequenceTypes::ZeroOrOneString);
267  s->appendArgument(argument(np, "arg2"), CommonSequenceTypes::ZeroOrOneString);
268  s->appendArgument(argument(np, "collation"), CommonSequenceTypes::ExactlyOneString);
269  }
270  else if(StandardLocalNames::substring_before == localName)
271  {
274  s->appendArgument(argument(np, "arg1"), CommonSequenceTypes::ZeroOrOneString);
275  s->appendArgument(argument(np, "arg2"), CommonSequenceTypes::ZeroOrOneString);
276  s->appendArgument(argument(np, "collation"), CommonSequenceTypes::ExactlyOneString);
277  }
278  else if(StandardLocalNames::sum == localName)
279  {
281  s->appendArgument(argument(np, "arg"), CommonSequenceTypes::ZeroOrMoreAtomicTypes);
282  s->appendArgument(argument(np, "zero"), CommonSequenceTypes::ZeroOrOneAtomicType);
283  }
284  else if(StandardLocalNames::translate == localName)
285  {
287  s->appendArgument(argument(np, "arg"), CommonSequenceTypes::ZeroOrOneString);
288  s->appendArgument(argument(np, "mapString"), CommonSequenceTypes::ExactlyOneString);
289  s->appendArgument(argument(np, "transString"), CommonSequenceTypes::ExactlyOneString);
290  }
291  else if(StandardLocalNames::True == localName)
292  {
294  }
295  }
296 
297  return s;
298 }
static const SequenceType::Ptr ZeroOrOneNode
NamespaceCode LocalNameCode
Definition: qxmlname.h:84
static const SequenceType::Ptr ZeroOrMoreItems
static QXmlName::LocalNameCode argument(const NamePool::Ptr &np, const char *const name)
static const SequenceType::Ptr ExactlyOneString
FunctionSignature::Ptr addFunction(const QXmlName::LocalNameCode localName, const FunctionSignature::Arity minArgs, const FunctionSignature::Arity maxArgs, const SequenceType::Ptr &returnType, const Expression::Properties props)
static const SequenceType::Ptr ZeroOrOneString
static const SequenceType::Ptr ExactlyOneInteger
virtual FunctionSignature::Hash functionSignatures() const
static const SequenceType::Ptr ExactlyOneAnyURI
static const SequenceType::Ptr ZeroOrMoreElements
QString localName(const QXmlNamePool &query) const
Returns the local name.
Definition: qxmlname.cpp:387
static const SequenceType::Ptr ZeroOrOneNumeric
static const SequenceType::Ptr ExactlyOneBoolean
NamespaceCode namespaceURI() const
Definition: qnamepool_p.h:503
static const SequenceType::Ptr ExactlyOneDouble
static const SequenceType::Ptr EBV
static const SequenceType::Ptr ZeroOrOneAtomicType
static const SequenceType::Ptr ZeroOrMoreAtomicTypes
static const SequenceType::Ptr ZeroOrOneItem
static const SequenceType::Ptr ZeroOrMoreStrings
static const SequenceType::Ptr ExactlyOneNode

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