source: trunk/tools/designer/data/generate_header.xsl@ 1030

Last change on this file since 1030 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 17.7 KB
Line 
1<!DOCTYPE xsl:stylesheet [
2 <!ENTITY endl "&#10;">
3]>
4<xsl:stylesheet version="1.0"
5 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6 xmlns:xs="http://www.w3.org/2001/XMLSchema">
7
8 <xsl:output method="text"/>
9
10 <xsl:include href="generate_shared.xsl"/>
11
12<!-- Forward declaration -->
13
14 <xsl:template name="class-forward-declaration">
15 <xsl:param name="node"/>
16 <xsl:variable name="name" select="concat('Dom', $node/attribute::name)"/>
17
18 <xsl:text>class </xsl:text>
19 <xsl:value-of select="$name"/>
20 <xsl:text>;&endl;</xsl:text>
21 </xsl:template>
22
23<!-- Class declaration: child element accessors -->
24
25 <xsl:template name="child-element-accessors">
26 <xsl:param name="node"/>
27
28 <xsl:variable name="isChoice" select="name($node)='xs:choice'"/>
29
30 <xsl:if test="$isChoice">
31 <xsl:text> enum Kind { Unknown = 0</xsl:text>
32 <xsl:for-each select="$node/xs:element">
33 <xsl:variable name="camel-case-name">
34 <xsl:call-template name="camel-case">
35 <xsl:with-param name="text" select="@name"/>
36 </xsl:call-template>
37 </xsl:variable>
38
39 <xsl:variable name="cap-name">
40 <xsl:call-template name="cap-first-char">
41 <xsl:with-param name="text" select="$camel-case-name"/>
42 </xsl:call-template>
43 </xsl:variable>
44 <xsl:text>, </xsl:text>
45 <xsl:value-of select="$cap-name"/>
46 </xsl:for-each>
47 <xsl:text> };&endl;</xsl:text>
48 <xsl:text> inline Kind kind() const { return m_kind; }&endl;&endl;</xsl:text>
49 </xsl:if>
50
51 <xsl:for-each select="$node/xs:element">
52 <xsl:variable name="array" select="@maxOccurs='unbounded'"/>
53 <xsl:variable name="camel-case-name">
54 <xsl:call-template name="camel-case">
55 <xsl:with-param name="text" select="@name"/>
56 </xsl:call-template>
57 </xsl:variable>
58 <xsl:variable name="cap-name">
59 <xsl:call-template name="cap-first-char">
60 <xsl:with-param name="text" select="$camel-case-name"/>
61 </xsl:call-template>
62 </xsl:variable>
63 <xsl:variable name="return-cpp-type">
64 <xsl:call-template name="xs-type-to-cpp-return-type">
65 <xsl:with-param name="xs-type" select="@type"/>
66 <xsl:with-param name="array" select="$array"/>
67 </xsl:call-template>
68 </xsl:variable>
69 <xsl:variable name="argument-cpp-type">
70 <xsl:call-template name="xs-type-to-cpp-argument-type">
71 <xsl:with-param name="xs-type" select="@type"/>
72 <xsl:with-param name="array" select="$array"/>
73 </xsl:call-template>
74 </xsl:variable>
75 <xsl:variable name="xs-type-cat">
76 <xsl:call-template name="xs-type-category">
77 <xsl:with-param name="xs-type" select="@type"/>
78 <xsl:with-param name="array" select="$array"/>
79 </xsl:call-template>
80 </xsl:variable>
81
82 <xsl:text> inline </xsl:text>
83 <xsl:value-of select="$return-cpp-type"/>
84 <xsl:text> element</xsl:text>
85 <xsl:value-of select="$cap-name"/>
86 <xsl:text>() const { return m_</xsl:text>
87 <xsl:value-of select="$camel-case-name"/>
88 <xsl:text>; }&endl;</xsl:text>
89
90 <xsl:if test="$xs-type-cat = 'pointer'">
91 <xsl:text> </xsl:text>
92 <xsl:value-of select="$return-cpp-type"/>
93 <xsl:text> takeElement</xsl:text>
94 <xsl:value-of select="$cap-name"/>
95 <xsl:text>();&endl;</xsl:text>
96 </xsl:if>
97
98 <xsl:text> void setElement</xsl:text>
99 <xsl:value-of select="$cap-name"/>
100 <xsl:text>(</xsl:text>
101 <xsl:value-of select="$argument-cpp-type"/>
102 <xsl:text> a);&endl;</xsl:text>
103
104 <xsl:if test="not($isChoice) and not(@maxOccurs='unbounded')">
105 <xsl:text> inline bool hasElement</xsl:text>
106 <xsl:value-of select="$cap-name"/>
107 <xsl:text>() const { return m_children &amp; </xsl:text>
108 <xsl:value-of select="$cap-name"/>
109 <xsl:text>; }&endl;</xsl:text>
110 <xsl:text> void clearElement</xsl:text>
111 <xsl:value-of select="$cap-name"/>
112 <xsl:text>();&endl;</xsl:text>
113 </xsl:if>
114 <xsl:text>&endl;</xsl:text>
115
116 </xsl:for-each>
117 </xsl:template>
118
119<!-- Class declaration: child element data -->
120
121 <xsl:template name="child-element-data">
122 <xsl:param name="node"/>
123
124 <xsl:variable name="isChoice" select="$node[name()='xs:choice']"/>
125
126 <xsl:for-each select="$node/xs:element">
127 <xsl:variable name="camel-case-name">
128 <xsl:call-template name="camel-case">
129 <xsl:with-param name="text" select="@name"/>
130 </xsl:call-template>
131 </xsl:variable>
132 <xsl:variable name="cpp-type">
133 <xsl:call-template name="xs-type-to-cpp-return-type">
134 <xsl:with-param name="xs-type" select="@type"/>
135 <xsl:with-param name="array" select="@maxOccurs='unbounded'"/>
136 </xsl:call-template>
137 </xsl:variable>
138 <xsl:text> </xsl:text>
139 <xsl:value-of select="$cpp-type"/>
140 <xsl:text> m_</xsl:text>
141 <xsl:value-of select="$camel-case-name"/>
142 <xsl:text>;&endl;</xsl:text>
143 </xsl:for-each>
144
145 <xsl:if test="not($isChoice) and not(@macOccurs='unbounded')">
146 <xsl:text> enum Child {&endl;</xsl:text>
147 <xsl:for-each select="$node/xs:element">
148 <xsl:variable name="camel-case-name">
149 <xsl:call-template name="camel-case">
150 <xsl:with-param name="text" select="@name"/>
151 </xsl:call-template>
152 </xsl:variable>
153
154 <xsl:text> </xsl:text>
155 <xsl:call-template name="cap-first-char">
156 <xsl:with-param name="text" select="$camel-case-name"/>
157 </xsl:call-template>
158 <xsl:text> = </xsl:text>
159 <xsl:call-template name="powers-of-two">
160 <xsl:with-param name="num" select="position() - 1"/>
161 </xsl:call-template>
162 <xsl:if test="position()!=last()">
163 <xsl:text>,</xsl:text>
164 </xsl:if>
165 <xsl:text>&endl;</xsl:text>
166
167 </xsl:for-each>
168 <xsl:text> };&endl;</xsl:text>
169 </xsl:if>
170 </xsl:template>
171
172<!-- Class declaration: attribute accessors -->
173
174 <xsl:template name="attribute-accessors">
175 <xsl:param name="node"/>
176
177 <xsl:for-each select="$node/xs:attribute">
178 <xsl:variable name="camel-case-name">
179 <xsl:call-template name="camel-case">
180 <xsl:with-param name="text" select="@name"/>
181 </xsl:call-template>
182 </xsl:variable>
183 <xsl:variable name="cap-name">
184 <xsl:call-template name="cap-first-char">
185 <xsl:with-param name="text" select="$camel-case-name"/>
186 </xsl:call-template>
187 </xsl:variable>
188 <xsl:variable name="cpp-return-type">
189 <xsl:call-template name="xs-type-to-cpp-return-type">
190 <xsl:with-param name="xs-type" select="@type"/>
191 </xsl:call-template>
192 </xsl:variable>
193 <xsl:variable name="cpp-argument-type">
194 <xsl:call-template name="xs-type-to-cpp-argument-type">
195 <xsl:with-param name="xs-type" select="@type"/>
196 </xsl:call-template>
197 </xsl:variable>
198
199 <xsl:text> inline bool hasAttribute</xsl:text>
200 <xsl:value-of select="$cap-name"/>
201 <xsl:text>() const { return m_has_attr_</xsl:text>
202 <xsl:value-of select="$camel-case-name"/>
203 <xsl:text>; }&endl;</xsl:text>
204
205 <xsl:text> inline </xsl:text>
206 <xsl:value-of select="$cpp-return-type"/>
207 <xsl:text> attribute</xsl:text>
208 <xsl:value-of select="$cap-name"/>
209 <xsl:text>() const { return m_attr_</xsl:text>
210 <xsl:value-of select="$camel-case-name"/>
211 <xsl:text>; }&endl;</xsl:text>
212
213 <xsl:text> inline void setAttribute</xsl:text>
214 <xsl:value-of select="$cap-name"/>
215 <xsl:text>(</xsl:text>
216 <xsl:value-of select="$cpp-argument-type"/>
217 <xsl:text> a) { m_attr_</xsl:text>
218 <xsl:value-of select="$camel-case-name"/>
219 <xsl:text> = a; m_has_attr_</xsl:text>
220 <xsl:value-of select="$camel-case-name"/>
221 <xsl:text> = true; }&endl;</xsl:text>
222
223 <xsl:text> inline void clearAttribute</xsl:text>
224 <xsl:value-of select="$cap-name"/>
225 <xsl:text>() { m_has_attr_</xsl:text>
226 <xsl:value-of select="$camel-case-name"/>
227 <xsl:text> = false; }&endl;&endl;</xsl:text>
228 </xsl:for-each>
229 </xsl:template>
230
231<!-- Class declaration -->
232
233 <xsl:template name="class-declaration">
234 <xsl:param name="node"/>
235 <xsl:variable name="name" select="concat('Dom', $node/@name)"/>
236<!-- <xsl:variable name="hasText" select="$node[@mixed='true']"/>-->
237 <xsl:variable name="hasText" select="true()"/>
238
239 <xsl:text>class QDESIGNER_UILIB_EXPORT </xsl:text>
240 <xsl:value-of select="$name"/>
241 <xsl:text> {&endl;</xsl:text>
242 <xsl:text>public:&endl;</xsl:text>
243 <xsl:text> </xsl:text>
244 <xsl:value-of select="$name"/>
245 <xsl:text>();&endl;</xsl:text>
246 <xsl:text> ~</xsl:text>
247 <xsl:value-of select="$name"/>
248 <xsl:text>();&endl;&endl;</xsl:text>
249
250 <xsl:text> void read(QXmlStreamReader &amp;reader);&endl;</xsl:text>
251 <xsl:text>#ifdef QUILOADER_QDOM_READ&endl;</xsl:text>
252 <xsl:text> void read(const QDomElement &amp;node);&endl;</xsl:text>
253 <xsl:text>#endif&endl;</xsl:text>
254 <xsl:text> void write(QXmlStreamWriter &amp;writer, const QString &amp;tagName = QString()) const;&endl;</xsl:text>
255
256 <xsl:if test="$hasText">
257 <xsl:text> inline QString text() const { return m_text; }&endl;</xsl:text>
258 <xsl:text> inline void setText(const QString &amp;s) { m_text = s; }&endl;</xsl:text>
259 </xsl:if>
260
261 <xsl:text>&endl;</xsl:text>
262
263 <xsl:text> // attribute accessors&endl;</xsl:text>
264 <xsl:call-template name="attribute-accessors">
265 <xsl:with-param name="node" select="$node"/>
266 </xsl:call-template>
267
268 <xsl:text> // child element accessors&endl;</xsl:text>
269
270 <xsl:for-each select="$node/xs:sequence | $node/xs:choice | $node/xs:all">
271 <xsl:call-template name="child-element-accessors">
272 <xsl:with-param name="node" select="."/>
273 </xsl:call-template>
274 </xsl:for-each>
275
276 <xsl:text>private:&endl;</xsl:text>
277
278 <xsl:if test="$hasText">
279 <xsl:text> QString m_text;&endl;</xsl:text>
280 </xsl:if>
281
282 <xsl:text> void clear(bool clear_all = true);&endl;&endl;</xsl:text>
283
284 <xsl:text> // attribute data&endl;</xsl:text>
285 <xsl:for-each select="$node/xs:attribute">
286 <xsl:variable name="camel-case-name">
287 <xsl:call-template name="camel-case">
288 <xsl:with-param name="text" select="@name"/>
289 </xsl:call-template>
290 </xsl:variable>
291 <xsl:variable name="cpp-type">
292 <xsl:call-template name="xs-type-to-cpp-type">
293 <xsl:with-param name="xs-type" select="@type"/>
294 </xsl:call-template>
295 </xsl:variable>
296 <xsl:text> </xsl:text>
297 <xsl:value-of select="$cpp-type"/>
298 <xsl:text> m_attr_</xsl:text>
299 <xsl:value-of select="$camel-case-name"/>
300 <xsl:text>;&endl;</xsl:text>
301 <xsl:text> bool m_has_attr_</xsl:text>
302 <xsl:value-of select="$camel-case-name"/>
303 <xsl:text>;&endl;&endl;</xsl:text>
304 </xsl:for-each>
305
306 <xsl:text> // child element data&endl;</xsl:text>
307 <xsl:if test="boolean($node/xs:choice)">
308 <xsl:text> Kind m_kind;&endl;</xsl:text>
309 </xsl:if>
310 <xsl:if test="not($node/xs:choice)">
311 <!-- TODO: if there are no elements with maxOccurs='1', m_children is never used-->
312 <xsl:text> uint m_children;&endl;</xsl:text>
313 </xsl:if>
314 <xsl:for-each select="$node/xs:sequence | $node/xs:choice | $node/xs:all">
315 <xsl:call-template name="child-element-data">
316 <xsl:with-param name="node" select="."/>
317 </xsl:call-template>
318 </xsl:for-each>
319
320 <xsl:text>&endl;</xsl:text>
321 <xsl:text> </xsl:text>
322 <xsl:value-of select="$name"/>
323 <xsl:text>(const </xsl:text>
324 <xsl:value-of select="$name"/>
325 <xsl:text> &amp;other);&endl;</xsl:text>
326 <xsl:text> void operator = (const </xsl:text>
327 <xsl:value-of select="$name"/>
328 <xsl:text>&amp;other);&endl;</xsl:text>
329
330 <xsl:text>};&endl;&endl;</xsl:text>
331 </xsl:template>
332
333<!-- Root -->
334
335 <xsl:template match="xs:schema">
336
337<xsl:text>/****************************************************************************
338**
339** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
340** All rights reserved.
341** Contact: Nokia Corporation ([email protected])
342**
343** This file is part of the tools applications of the Qt Toolkit.
344**
345** $QT_BEGIN_LICENSE:LGPL$
346** Commercial Usage
347** Licensees holding valid Qt Commercial licenses may use this file in
348** accordance with the Qt Commercial License Agreement provided with the
349** Software or, alternatively, in accordance with the terms contained in
350** a written agreement between you and Nokia.
351**
352** GNU Lesser General Public License Usage
353** Alternatively, this file may be used under the terms of the GNU Lesser
354** General Public License version 2.1 as published by the Free Software
355** Foundation and appearing in the file LICENSE.LGPL included in the
356** packaging of this file. Please review the following information to
357** ensure the GNU Lesser General Public License version 2.1 requirements
358** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
359**
360** In addition, as a special exception, Nokia gives you certain additional
361** rights. These rights are described in the Nokia Qt LGPL Exception
362** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
363**
364** GNU General Public License Usage
365** Alternatively, this file may be used under the terms of the GNU
366** General Public License version 3.0 as published by the Free Software
367** Foundation and appearing in the file LICENSE.GPL included in the
368** packaging of this file. Please review the following information to
369** ensure the GNU General Public License version 3.0 requirements will be
370** met: http://www.gnu.org/copyleft/gpl.html.
371**
372** If you have questions regarding the use of this file, please contact
373** Nokia at [email protected].
374** $QT_END_LICENSE$
375**
376****************************************************************************/
377
378//
379// W A R N I N G
380// -------------
381//
382// This file is not part of the Qt API. It exists for the convenience
383// of Qt Designer. This header
384// file may change from version to version without notice, or even be removed.
385//
386// We mean it.
387//
388
389// THIS FILE IS AUTOMATICALLY GENERATED
390
391#ifndef UI4_H
392#define UI4_H
393
394#include &lt;QtCore/QList&gt;
395#include &lt;QtCore/QString&gt;
396#include &lt;QtCore/QStringList&gt;
397#include &lt;QtCore/QXmlStreamReader&gt;
398#include &lt;QtCore/QXmlStreamWriter&gt;
399#include &lt;QtCore/qglobal.h&gt;
400
401#if defined(QT_UIC3)
402 #define QUILOADER_QDOM_READ
403#endif
404
405QT_BEGIN_NAMESPACE
406
407#ifdef QUILOADER_QDOM_READ
408 class QDomElement;
409#endif
410
411
412#define QDESIGNER_UILIB_EXTERN Q_DECL_EXPORT
413#define QDESIGNER_UILIB_IMPORT Q_DECL_IMPORT
414
415#if defined(QT_DESIGNER_STATIC) || defined(QT_UIC) || defined(QT_UIC3)
416# define QDESIGNER_UILIB_EXPORT
417#elif defined(QDESIGNER_UILIB_LIBRARY)
418# define QDESIGNER_UILIB_EXPORT QDESIGNER_UILIB_EXTERN
419#else
420# define QDESIGNER_UILIB_EXPORT QDESIGNER_UILIB_IMPORT
421#endif
422
423#ifndef QDESIGNER_UILIB_EXPORT
424# define QDESIGNER_UILIB_EXPORT
425#endif
426
427#ifdef QFORMINTERNAL_NAMESPACE
428namespace QFormInternal
429{
430#endif
431
432</xsl:text>
433
434 <xsl:text>&endl;</xsl:text>
435 <xsl:text>/*******************************************************************************&endl;</xsl:text>
436 <xsl:text>** Forward declarations&endl;</xsl:text>
437 <xsl:text>*/&endl;&endl;</xsl:text>
438
439 <xsl:for-each select="xs:complexType">
440 <xsl:call-template name="class-forward-declaration">
441 <xsl:with-param name="node" select="."/>
442 </xsl:call-template>
443 </xsl:for-each>
444
445 <xsl:text>&endl;</xsl:text>
446 <xsl:text>/*******************************************************************************&endl;</xsl:text>
447 <xsl:text>** Declarations&endl;</xsl:text>
448 <xsl:text>*/&endl;&endl;</xsl:text>
449
450 <xsl:for-each select="xs:complexType">
451 <xsl:call-template name="class-declaration">
452 <xsl:with-param name="node" select="."/>
453 </xsl:call-template>
454 </xsl:for-each>
455 <xsl:text>
456#ifdef QFORMINTERNAL_NAMESPACE
457}
458#endif
459
460QT_END_NAMESPACE
461
462#endif // UI4_H
463</xsl:text>
464 </xsl:template>
465</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.