Qt 4.8
qfunctionsignature.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 "qxmlname.h"
43 
44 #include "qfunctionsignature_p.h"
45 
47 
48 using namespace QPatternist;
49 
51  const Arity minArgs,
52  const Arity maxArgs,
53  const SequenceType::Ptr &returnTypeP,
54  const Expression::Properties props,
55  const Expression::ID idP) : CallTargetDescription(nameP)
56  , m_minArgs(minArgs)
57  , m_maxArgs(maxArgs)
58  , m_returnType(returnTypeP)
59  , m_arguments()
60  , m_props(props)
61  , m_id(idP)
62 {
63  Q_ASSERT(minArgs <= maxArgs || maxArgs == FunctionSignature::UnlimitedArity);
64  Q_ASSERT(m_maxArgs >= -1);
65  Q_ASSERT(returnTypeP);
66 }
67 
69  const SequenceType::Ptr &type)
70 {
71  Q_ASSERT(type);
72 
74 }
75 
77 {
78  QString result;
79  result += np->displayName(name());
80  result += QLatin1Char('(');
81 
84 
85  if(it != end)
86  {
87  while(true)
88  {
89  result += QLatin1Char('$');
90  result += np->displayName((*it)->name());
91  result += QLatin1String(" as ");
92  result += (*it)->type()->displayName(np);
93 
94  ++it;
95  if(it == end)
96  break;
97 
98  result += QLatin1String(", ");
99  }
100  }
101 
103  result += QLatin1String(", ...");
104 
105  result += QLatin1String(") as ");
106  result += m_returnType->displayName(np);
107 
108  return result;
109 }
110 
112 {
113  return name() == other.name() &&
114  isArityValid(other.maximumArguments()) &&
116 }
117 
119 {
120  m_arguments = args;
121 }
122 
124 {
125  return m_arguments;
126 }
127 
129 {
130  return arity >= m_minArgs && arity <= m_maxArgs;
131 }
132 
134 {
135  return m_minArgs;
136 }
137 
139 {
140  return m_maxArgs;
141 }
142 
144 {
145  return m_returnType;
146 }
147 
149 {
150  return m_props;
151 }
152 
154 {
155  return m_id;
156 }
157 
FunctionSignature(const QXmlName name, const Arity minArgs, const Arity maxArgs, const SequenceType::Ptr &returnType, const Expression::Properties chars=Expression::Properties(), const Expression::ID id=Expression::IDIgnorableExpression)
QString displayName(const QXmlName qName) const
Definition: qnamepool.cpp:347
Contains metadata for a callable component, such as a function or template.
int type
Definition: qmetatype.cpp:239
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
NamespaceCode LocalNameCode
Definition: qxmlname.h:84
#define it(className, varName)
qint64 xsInteger
void appendArgument(const QXmlName::LocalNameCode name, const SequenceType::Ptr &type)
virtual QString displayName(const NamePool::Ptr &np) const =0
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
SequenceType::Ptr returnType() const
friend class const_iterator
Definition: qlist.h:264
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
FunctionArgument::List arguments() const
bool operator==(const FunctionSignature &other) const
QString displayName(const NamePool::Ptr &np) const
Represents the signature of an XPath function.
The namespace for the internal API of QtXmlPatterns.
const SequenceType::Ptr m_returnType
Carries meta data for a function argument as found in XPath&#39;s builtin functions and user declared fun...
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
Expression::Properties properties() const
bool isArityValid(const xsInteger arity) const
The QFlags class provides a type-safe way of storing OR-combinations of enum values.
Definition: qglobal.h:2313
const Expression::Properties m_props
static const KeyPair *const end
FunctionArgument::List m_arguments
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
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
void setArguments(const FunctionArgument::List &args)