Qt 4.8
qconstructorfunctionsfactory.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 "qatomictype_p.h"
43 #include "qbuiltintypes_p.h"
44 #include "qcastas_p.h"
45 #include "qcommonnamespaces_p.h"
46 #include "qcommonsequencetypes_p.h"
47 #include "qfunctionargument_p.h"
48 #include "qfunctioncall_p.h"
49 #include "qgenericsequencetype_p.h"
50 #include "qschematype_p.h"
51 #include "qschematypefactory_p.h"
52 
54 
56 
57 using namespace QPatternist;
58 
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 }
92 
94  const Expression::List &args,
95  const FunctionSignature::Ptr &sign) const
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 }
107 
109 {
110  Q_UNUSED(np);
111  return functionSignatures().value(name);
112 }
113 
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define it(className, varName)
virtual Expression::Ptr retrieveExpression(const QXmlName name, const Expression::List &args, const FunctionSignature::Ptr &sign) const
#define at(className, varName)
Implements XPath 2.0&#39;s cast as expression.
Definition: qcastas_p.h:79
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
static int sign(int x)
virtual FunctionSignature::Ptr retrieveFunctionSignature(const NamePool::Ptr &np, const QXmlName name)
T * data() const
Returns a pointer to the shared data object.
Definition: qshareddata.h:145
virtual FunctionSignature::Hash functionSignatures() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
const char * name
Represents the signature of an XPath function.
The namespace for the internal API of QtXmlPatterns.
Carries meta data for a function argument as found in XPath&#39;s builtin functions and user declared fun...
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.
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
virtual SchemaType::Ptr createSchemaType(const QXmlName name) const =0
static const AtomicType::Ptr xsAnyAtomicType
static const SequenceType::Ptr ZeroOrOneAtomicType
static const KeyPair *const end
static const AtomicType::Ptr xsNOTATION
#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
ConstructorFunctionsFactory(const NamePool::Ptr &np, const SchemaTypeFactory::Ptr &)