Qt 4.8
qxslt20corefunctions.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qanyuri_p.h"
43 #include "qcommonnamespaces_p.h"
44 #include "qcommonsequencetypes_p.h"
45 #include "qcurrentfn_p.h"
46 #include "qdocumentfn_p.h"
47 #include "qelementavailablefn_p.h"
48 #include "qfunctionavailablefn_p.h"
49 #include "qgenerateidfn_p.h"
50 #include "qsystempropertyfn_p.h"
51 #include "qtypeavailablefn_p.h"
53 #include "qunparsedentityurifn_p.h"
55 #include "qunparsedtextfn_p.h"
56 
57 #include "qxslt20corefunctions_p.h"
58 
60 
61 using namespace QPatternist;
62 
64  const Expression::List &args,
65  const FunctionSignature::Ptr &sign) const
66 {
67  Q_ASSERT(sign);
68 
69  Expression::Ptr fn;
70 #define testXSLTFN(ln, cname) else if(lname.localName() == StandardLocalNames::ln) fn = Expression::Ptr(new cname())
71 
72  if(false) /* Dummy for the macro handling. Will be optimized away anyway. */
73  return Expression::Ptr();
74  /* Alphabetic order. */
75  testXSLTFN(current, CurrentFN);
76  testXSLTFN(document, DocumentFN);
77  testXSLTFN(element_available, ElementAvailableFN);
78  testXSLTFN(function_available, FunctionAvailableFN);
79  testXSLTFN(generate_id, GenerateIDFN);
80  testXSLTFN(system_property, SystemPropertyFN);
81  testXSLTFN(type_available, TypeAvailableFN);
82  testXSLTFN(unparsed_entity_public_id, UnparsedEntityPublicIDFN);
83  testXSLTFN(unparsed_entity_uri, UnparsedEntityURIFN);
84  testXSLTFN(unparsed_text_available, UnparsedTextAvailableFN);
85  testXSLTFN(unparsed_text, UnparsedTextFN);
86 #undef testXSLTFN
87 
88  Q_ASSERT(fn);
89  fn->setOperands(args);
90  fn->as<FunctionCall>()->setSignature(sign);
91 
92  return fn;
93 }
94 
96 {
98  return FunctionSignature::Ptr();
99 
101 
102  if(!s)
103  {
104  /* Alphabetic order. */
106  {
109  }
111  {
115  }
117  {
120  }
122  {
125  }
126  else if(name.localName() == StandardLocalNames::generate_id)
127  {
131  }
133  {
138  }
140  {
145  }
146  else if(name.localName() == StandardLocalNames::current)
147  {
150  }
151  else if(name.localName() == StandardLocalNames::document)
152  {
157  }
159  {
163  }
165  {
169  }
170  }
171 
172  return s;
173 }
174 
Base class for implementations of builtin functions.
Implements XSL-T&#39;s function fn:current().
Definition: qcurrentfn_p.h:71
static const SequenceType::Ptr ZeroOrOneNode
virtual void setOperands(const Expression::List &operands)=0
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
static QXmlName::LocalNameCode argument(const NamePool::Ptr &np, const char *const name)
virtual FunctionSignature::Ptr retrieveFunctionSignature(const NamePool::Ptr &np, const QXmlName name)
Implements XSL-T 2.0&#39;s XPath function fn:unparsed-entity-uri().
void appendArgument(const QXmlName::LocalNameCode name, const SequenceType::Ptr &type)
static const SequenceType::Ptr ExactlyOneString
Implements the function fn:generate-id().
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
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 int sign(int x)
static const SequenceType::Ptr OneOrMoreDocumentNodes
static const SequenceType::Ptr ExactlyOneInteger
Implements the function fn:unparsed-text().
virtual FunctionSignature::Hash functionSignatures() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
const TCastTarget * as() const
Implements XSL-T 2.0&#39;s XPath function fn:system-property().
static const SequenceType::Ptr ExactlyOneAnyURI
Implements XSL-T 2.0&#39;s XPath function fn:type-available().
Implements XSL-T 2.0&#39;s XPath function fn:function-available().
const char * name
Implements XSL-T&#39;s function fn:document().
The namespace for the internal API of QtXmlPatterns.
Implements XSL-T 2.0&#39;s XPath function fn:unparsed-entity-public-id().
#define testXSLTFN(ln, cname)
QString localName(const QXmlNamePool &query) const
Returns the local name.
Definition: qxmlname.cpp:387
QExplicitlySharedDataPointer< Expression > Ptr
A smart pointer wrapping mutable Expression instances.
static const SequenceType::Ptr ExactlyOneBoolean
NamespaceCode namespaceURI() const
Definition: qnamepool_p.h:503
virtual Expression::Ptr retrieveExpression(const QXmlName name, const Expression::List &args, const FunctionSignature::Ptr &sign) const
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
static const SequenceType::Ptr ExactlyOneItem
Implements the function fn:unparsed-text().
Implements the function fn:unparsed-text-available().
static const SequenceType::Ptr ZeroOrMoreStrings
static const SequenceType::Ptr ExactlyOneNode