source: trunk/src/xmlpatterns/utils/qnamepool.cpp@ 729

Last change on this file since 729 was 651, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 19.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtXmlPatterns module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this 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 have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include <QtDebug>
43
44#include "private/qxmlutils_p.h"
45#include "qxpathhelper_p.h"
46
47#include "qnamepool_p.h"
48
49QT_BEGIN_NAMESPACE
50
51using namespace QPatternist;
52
53NamePool::NamePool()
54{
55 m_localNameMapping .reserve(DefaultLocalNameCapacity + StandardLocalNameCount);
56 m_localNames .reserve(DefaultLocalNameCapacity + StandardLocalNameCount);
57 m_namespaceMapping .reserve(DefaultURICapacity + StandardNamespaceCount);
58 m_namespaces .reserve(DefaultURICapacity + StandardNamespaceCount);
59 m_prefixes .reserve(DefaultPrefixCapacity + StandardPrefixCount);
60 m_prefixMapping .reserve(DefaultPrefixCapacity + StandardPrefixCount);
61
62 /* Namespaces. */
63 {
64 unlockedAllocateNamespace(QString());
65 unlockedAllocateNamespace(QLatin1String("http://www.w3.org/2005/xpath-functions"));
66 unlockedAllocateNamespace(QLatin1String("http://www.w3.org/2005/xquery-local-functions"));
67 unlockedAllocateNamespace(QLatin1String("http://www.w3.org/XML/1998/namespace"));
68 unlockedAllocateNamespace(QLatin1String("http://www.w3.org/2000/xmlns/"));
69 unlockedAllocateNamespace(QLatin1String("http://www.w3.org/2001/XMLSchema"));
70 unlockedAllocateNamespace(QLatin1String("http://www.w3.org/2001/XMLSchema-instance"));
71 unlockedAllocateNamespace(QLatin1String("http://www.w3.org/1999/XSL/Transform"));
72
73 /* For UndeclarePrefix, StopNamespaceInheritance and InternalXSLT. We use two
74 * arbitrary strings that aren't used. For instance, if we just used an
75 * empty QString, unlockedAllocateNamespace() would assign it
76 * StandardNamespaces::empty. However, it's important that the string
77 * is an invalid namespace, since otherwise user strings would get
78 * assigned the same IDs. */
79 unlockedAllocateNamespace(QLatin1String(" | 1 "));
80 unlockedAllocateNamespace(QLatin1String(" | 2 "));
81 unlockedAllocateNamespace(QLatin1String(" | InternalXSLT"));
82
83 Q_ASSERT_X(m_namespaces.count() == StandardNamespaceCount, Q_FUNC_INFO,
84 qPrintable(QString::fromLatin1("Expected is %1, actual is %2.").arg(StandardNamespaceCount).arg(m_namespaces.count())));
85 }
86
87 /* Prefixes. */
88 {
89 unlockedAllocatePrefix(QString());
90 unlockedAllocatePrefix(QLatin1String("fn"));
91 unlockedAllocatePrefix(QLatin1String("local"));
92 unlockedAllocatePrefix(QLatin1String("xml"));
93 unlockedAllocatePrefix(QLatin1String("xmlns"));
94 unlockedAllocatePrefix(QLatin1String("xs"));
95 unlockedAllocatePrefix(QLatin1String("xsi"));
96 unlockedAllocatePrefix(QLatin1String("ns0"));
97 unlockedAllocatePrefix(QLatin1String("|||")); /* Invalid NCName, for StopNamespaceInheritance. */
98
99 Q_ASSERT_X(m_prefixes.count() == StandardPrefixCount, Q_FUNC_INFO,
100 qPrintable(QString::fromLatin1("Expected is %1, actual is %2.").arg(StandardPrefixCount).arg(m_prefixes.count())));
101 }
102
103 /* Local names. */
104 {
105 /* Same order as the enum in StandardLocalNames. That is, alphabetically. */
106 unlockedAllocateLocalName(QLatin1String("abs"));
107 unlockedAllocateLocalName(QLatin1String("adjust-dateTime-to-timezone"));
108 unlockedAllocateLocalName(QLatin1String("adjust-date-to-timezone"));
109 unlockedAllocateLocalName(QLatin1String("adjust-time-to-timezone"));
110 unlockedAllocateLocalName(QLatin1String("all"));
111 unlockedAllocateLocalName(QLatin1String("arity"));
112 unlockedAllocateLocalName(QLatin1String("avg"));
113 unlockedAllocateLocalName(QLatin1String("base"));
114 unlockedAllocateLocalName(QLatin1String("base-uri"));
115 unlockedAllocateLocalName(QLatin1String("boolean"));
116 unlockedAllocateLocalName(QLatin1String("ceiling"));
117 unlockedAllocateLocalName(QLatin1String("codepoint-equal"));
118 unlockedAllocateLocalName(QLatin1String("codepoints-to-string"));
119 unlockedAllocateLocalName(QLatin1String("collection"));
120 unlockedAllocateLocalName(QLatin1String("compare"));
121 unlockedAllocateLocalName(QLatin1String("concat"));
122 unlockedAllocateLocalName(QLatin1String("contains"));
123 unlockedAllocateLocalName(QLatin1String("count"));
124 unlockedAllocateLocalName(QLatin1String("current"));
125 unlockedAllocateLocalName(QLatin1String("current-date"));
126 unlockedAllocateLocalName(QLatin1String("current-dateTime"));
127 unlockedAllocateLocalName(QLatin1String("current-time"));
128 unlockedAllocateLocalName(QLatin1String("data"));
129 unlockedAllocateLocalName(QLatin1String("dateTime"));
130 unlockedAllocateLocalName(QLatin1String("day-from-date"));
131 unlockedAllocateLocalName(QLatin1String("day-from-dateTime"));
132 unlockedAllocateLocalName(QLatin1String("days-from-duration"));
133 unlockedAllocateLocalName(QLatin1String("deep-equal"));
134 unlockedAllocateLocalName(QLatin1String("default"));
135 unlockedAllocateLocalName(QLatin1String("default-collation"));
136 unlockedAllocateLocalName(QLatin1String("distinct-values"));
137 unlockedAllocateLocalName(QLatin1String("doc"));
138 unlockedAllocateLocalName(QLatin1String("doc-available"));
139 unlockedAllocateLocalName(QLatin1String("document"));
140 unlockedAllocateLocalName(QLatin1String("document-uri"));
141 unlockedAllocateLocalName(QLatin1String("element-available"));
142 unlockedAllocateLocalName(QLatin1String("empty"));
143 unlockedAllocateLocalName(QLatin1String("encode-for-uri"));
144 unlockedAllocateLocalName(QLatin1String("ends-with"));
145 unlockedAllocateLocalName(QLatin1String("error"));
146 unlockedAllocateLocalName(QLatin1String("escape-html-uri"));
147 unlockedAllocateLocalName(QLatin1String("exactly-one"));
148 unlockedAllocateLocalName(QLatin1String("exists"));
149 unlockedAllocateLocalName(QLatin1String("false"));
150 unlockedAllocateLocalName(QLatin1String("floor"));
151 unlockedAllocateLocalName(QLatin1String("function-available"));
152 unlockedAllocateLocalName(QLatin1String("function-name"));
153 unlockedAllocateLocalName(QLatin1String("generate-id"));
154 unlockedAllocateLocalName(QLatin1String("generic-string-join"));
155 unlockedAllocateLocalName(QLatin1String("hours-from-dateTime"));
156 unlockedAllocateLocalName(QLatin1String("hours-from-duration"));
157 unlockedAllocateLocalName(QLatin1String("hours-from-time"));
158 unlockedAllocateLocalName(QLatin1String("id"));
159 unlockedAllocateLocalName(QLatin1String("idref"));
160 unlockedAllocateLocalName(QLatin1String("implicit-timezone"));
161 unlockedAllocateLocalName(QLatin1String("index-of"));
162 unlockedAllocateLocalName(QLatin1String("in-scope-prefixes"));
163 unlockedAllocateLocalName(QLatin1String("insert-before"));
164 unlockedAllocateLocalName(QLatin1String("iri-to-uri"));
165 unlockedAllocateLocalName(QLatin1String("is-schema-aware"));
166 unlockedAllocateLocalName(QLatin1String("key"));
167 unlockedAllocateLocalName(QLatin1String("lang"));
168 unlockedAllocateLocalName(QLatin1String("last"));
169 unlockedAllocateLocalName(QLatin1String("local-name"));
170 unlockedAllocateLocalName(QLatin1String("local-name-from-QName"));
171 unlockedAllocateLocalName(QLatin1String("lower-case"));
172 unlockedAllocateLocalName(QLatin1String("matches"));
173 unlockedAllocateLocalName(QLatin1String("max"));
174 unlockedAllocateLocalName(QLatin1String("min"));
175 unlockedAllocateLocalName(QLatin1String("minutes-from-dateTime"));
176 unlockedAllocateLocalName(QLatin1String("minutes-from-duration"));
177 unlockedAllocateLocalName(QLatin1String("minutes-from-time"));
178 unlockedAllocateLocalName(QLatin1String("month-from-date"));
179 unlockedAllocateLocalName(QLatin1String("month-from-dateTime"));