1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #include "qbuiltintypes_p.h"
|
---|
43 | #include "qcommonnamespaces_p.h"
|
---|
44 | #include "qcommonsequencetypes_p.h"
|
---|
45 | #include "qcommonvalues_p.h"
|
---|
46 | #include "qpatternistlocale_p.h"
|
---|
47 | #include "qxmlname.h"
|
---|
48 |
|
---|
49 | /* Functions */
|
---|
50 | #include "qaccessorfns_p.h"
|
---|
51 | #include "qaggregatefns_p.h"
|
---|
52 | #include "qbooleanfns_p.h"
|
---|
53 | #include "qcomparestringfns_p.h"
|
---|
54 | #include "qcontextfns_p.h"
|
---|
55 | #include "qnodefns_p.h"
|
---|
56 | #include "qnumericfns_p.h"
|
---|
57 | #include "qsequencefns_p.h"
|
---|
58 | #include "qsequencegeneratingfns_p.h"
|
---|
59 | #include "qstringvaluefns_p.h"
|
---|
60 | #include "qsubstringfns_p.h"
|
---|
61 |
|
---|
62 | #include "qxpath10corefunctions_p.h"
|
---|
63 |
|
---|
64 | QT_BEGIN_NAMESPACE
|
---|
65 |
|
---|
66 | using namespace QPatternist;
|
---|
67 |
|
---|
68 | Expression::Ptr XPath10CoreFunctions::retrieveExpression(const QXmlName name,
|
---|
69 | const Expression::List &args,
|
---|
70 | const FunctionSignature::Ptr &sign) const
|
---|
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);
|
---|
96 | testFN(position, PositionFN);
|
---|
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 | }
|
---|
115 |
|
---|
116 | FunctionSignature::Ptr XPath10CoreFunctions::retrieveFunctionSignature(const NamePool::Ptr &np, const QXmlName name)
|
---|
117 | {
|
---|
118 | if(StandardNamespaces::fn != name.namespaceURI())
|
---|
119 | return FunctionSignature::Ptr();
|
---|
120 |
|
---|
121 | FunctionSignature::Ptr s(functionSignatures().value(name));
|
---|
122 |
|
---|
123 | if(!s)
|
---|
124 | {
|
---|
125 | const QXmlName::LocalNameCode localName(name.localName());
|
---|
126 |
|
---|
127 | /* Alphabetic order. */
|
---|
128 | if(StandardLocalNames::boolean == localName)
|
---|
129 | {
|
---|
130 | s = addFunction(StandardLocalNames::boolean, 1, 1, CommonSequenceTypes::ExactlyOneBoolean);
|
---|
131 | s->appendArgument(argument(np, "arg"), CommonSequenceTypes::EBV);
|
---|
132 | }
|
---|
133 | else if(StandardLocalNames::ceiling == localName)
|
---|
|
---|