3 Transform dia UML objects to C++ classes
5 Copyright(c) 2002 Matthieu Sozeau <mattam@netcourrier.com>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform" version=
"1.0">
25 <xsl:output method=
"text"/>
27 <xsl:param name=
"directory"/>
29 <xsl:param name=
"ident">
30 <xsl:text> </xsl:text>
33 <!-- Visibility indentation -->
34 <xsl:param name=
"visident">
35 <xsl:text> </xsl:text>
38 <xsl:template match=
"class">
39 <xsl:document href=
"{$directory}{@name}.hh" method=
"text">
40 <xsl:if test=
"comment">
41 <xsl:text>/*

 </xsl:text>
42 <xsl:value-of select=
"comment"/>
43 <xsl:text>
 */


</xsl:text>
46 <xsl:text>#ifndef _
</xsl:text>
47 <xsl:value-of select=
"@name"/>
48 <xsl:text>_hh_

</xsl:text>
50 <xsl:text>#define _
</xsl:text>
51 <xsl:value-of select=
"@name"/>
52 <xsl:text>_hh_


</xsl:text>
54 <xsl:text>class
</xsl:text>
55 <xsl:value-of select=
"@name"/>
56 <xsl:if test=
"@stereotype!=''">
57 <xsl:text> : public
</xsl:text>
58 <xsl:value-of select=
"@stereotype"/>
60 <xsl:text> {


</xsl:text>
61 <xsl:apply-templates select=
"attributes"/>
62 <xsl:text>
</xsl:text>
63 <xsl:apply-templates select=
"operations"/>
64 <xsl:text>
};

</xsl:text>
65 <xsl:text>
#endif /* _
</xsl:text>
66 <xsl:value-of select=
"@name"/>
67 <xsl:text>_hh_ */


</xsl:text>
72 <xsl:template match=
"operations|attributes">
73 <xsl:if test=
"*[@visibility='private']">
74 <xsl:value-of select=
"$visident"/>
75 <xsl:text>private:

</xsl:text>
76 <xsl:apply-templates select=
"*[@visibility='private']"/>
77 <xsl:text>
</xsl:text>
79 <xsl:if test=
"*[@visibility='protected']">
80 <xsl:value-of select=
"$visident"/>
81 <xsl:text>protected:

</xsl:text>
82 <xsl:apply-templates select=
"*[@visibility='protected']"/>
83 <xsl:text>
</xsl:text>
85 <xsl:if test=
"*[@visibility='public']">
86 <xsl:value-of select=
"$visident"/>
87 <xsl:text>public:

</xsl:text>
88 <xsl:apply-templates select=
"*[@visibility='public']"/>
89 <xsl:text>
</xsl:text>
91 <xsl:if test=
"*[not(@visibility)]">
92 <xsl:apply-templates select=
"*[not(@visibility)]"/>
93 <xsl:text>
</xsl:text>
98 <xsl:template match=
"attribute">
99 <xsl:if test=
"comment!=''">
100 <xsl:text>
</xsl:text>
101 <xsl:value-of select=
"$ident"/>
102 <xsl:text>/*

</xsl:text>
103 <xsl:value-of select=
"$ident"/>
104 <xsl:text> *
</xsl:text>
105 <xsl:value-of select=
"comment"/>
106 <xsl:text>
</xsl:text>
107 <xsl:value-of select=
"$ident"/>
108 <xsl:text> */


</xsl:text>
111 <xsl:value-of select=
"$ident"/>
112 <xsl:if test=
"@class_scope">
113 <xsl:text>static
</xsl:text>
115 <xsl:value-of select=
"type"/>
116 <xsl:text> </xsl:text>
117 <xsl:value-of select=
"name"/>
118 <xsl:text>;

</xsl:text>
121 <xsl:template match=
"operation">
123 <xsl:if test=
"comment!=''">
124 <xsl:text>
</xsl:text>
125 <xsl:value-of select=
"$ident"/>
126 <xsl:text>/*

</xsl:text>
127 <xsl:value-of select=
"$ident"/>
128 <xsl:text> *
</xsl:text>
129 <xsl:value-of select=
"comment"/>
130 <xsl:text>
</xsl:text>
131 <xsl:for-each select=
"parameters/parameter/comment">
132 <xsl:value-of select=
"$ident"/>
133 <xsl:text> * @
</xsl:text>
134 <xsl:value-of select=
"../name"/>
135 <xsl:text>
</xsl:text>
137 <xsl:value-of select=
"$ident"/>
138 <xsl:text> */


</xsl:text>
141 <xsl:value-of select=
"$ident"/>
143 <xsl:when test=
"@inheritance='polymorphic'">
144 <xsl:text>virtual
</xsl:text>
146 <xsl:when test=
"@inheritance='abstract'">
147 <xsl:text>virtual
</xsl:text>
151 <xsl:if test=
"@class_scope">
152 <xsl:text>static
</xsl:text>
155 <!-- Constructor has no type -->
157 <xsl:value-of select=
"type"/>
158 <xsl:text> </xsl:text>
161 <xsl:value-of select=
"name"/>
162 <xsl:text>(
</xsl:text>
163 <xsl:for-each select=
"parameters/*">
165 <xsl:when test=
"@kind='in'">
166 <xsl:text>const
</xsl:text>
170 <xsl:value-of select=
"type"/>
171 <xsl:if test=
"@kind">
172 <xsl:text>&</xsl:text>
175 <xsl:text> </xsl:text>
176 <xsl:value-of select=
"name"/>
177 <xsl:if test=
"value">
178 <xsl:text> =
</xsl:text>
179 <xsl:value-of select=
"value"/>
181 <xsl:if test=
"not(position()=last())">
182 <xsl:text>,
</xsl:text>
186 <xsl:text>)
</xsl:text>
187 <xsl:if test=
"@inheritance='abstract'">
188 <xsl:text> =
0</xsl:text>
190 <xsl:if test=
"@query=1">
191 <xsl:text> const
</xsl:text>
193 <xsl:text>;

</xsl:text>
197 <xsl:template match=
"text()">
200 <xsl:template match=
"node()|@*">
201 <xsl:apply-templates match=
"node()|@*"/>
205 <!-- Keep this comment at the end of the file
210 sgml-namecase-general:nil
211 sgml-general-insert-case:lower
212 sgml-minimize-attributes:nil
213 sgml-always-quote-attributes:t
216 sgml-parent-document:nil
217 sgml-exposed-tags:nil
218 sgml-local-catalogs:nil
219 sgml-local-ecat-files:nil