VirtualBox

source: vbox/trunk/src/VBox/Main/xml/SchemaDefs.xsl@ 105006

Last change on this file since 105006 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 KB
Line 
1<?xml version="1.0"?>
2
3<!--
4 * A template to generate a header that will contain some important constraints
5 * extracted from the VirtualBox XML Schema (VirtualBox-settings-*.xsd).
6 * The output file name must be SchemaDefs.h.
7 *
8 * This template depends on XML Schema structure (type names and constraints)
9 * and should be reviewed on every Schema change.
10-->
11<!--
12 Copyright (C) 2006-2023 Oracle and/or its affiliates.
13
14 This file is part of VirtualBox base platform packages, as
15 available from https://www.virtualbox.org.
16
17 This program is free software; you can redistribute it and/or
18 modify it under the terms of the GNU General Public License
19 as published by the Free Software Foundation, in version 3 of the
20 License.
21
22 This program is distributed in the hope that it will be useful, but
23 WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 General Public License for more details.
26
27 You should have received a copy of the GNU General Public License
28 along with this program; if not, see <https://www.gnu.org/licenses>.
29
30 SPDX-License-Identifier: GPL-3.0-only
31-->
32
33<xsl:stylesheet version="1.0"
34 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
35 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
36>
37<xsl:output method="text"/>
38
39<xsl:strip-space elements="*"/>
40
41<xsl:param name="mode" expr=''/>
42
43<!--
44// helpers
45////////////////////////////////////////////////////////////////////////////////
46-->
47
48<!--
49 * Extract the specified value and assign it to an enum member with the given
50 * name
51-->
52<xsl:template name="defineEnumMember">
53 <xsl:param name="member"/>
54 <xsl:param name="select"/>
55 <xsl:if test="$select">
56 <xsl:value-of select="concat(' ', $member, ' = ', $select, ',&#x0A;')"/>
57 </xsl:if>
58</xsl:template>
59
60<!--
61// templates
62////////////////////////////////////////////////////////////////////////////////
63-->
64
65<!--
66 * shut down all implicit templates
67-->
68<xsl:template match="*"/>
69<xsl:template match="*" mode="declare"/>
70<xsl:template match="*" mode="declare.enum"/>
71<xsl:template match="*" mode="define"/>
72
73<xsl:template match="/">
74 <xsl:choose>
75 <xsl:when test="$mode='declare'">
76 <xsl:apply-templates select="/" mode="declare"/>
77 </xsl:when>
78 <xsl:when test="$mode='define'">
79 <xsl:apply-templates select="/" mode="define"/>
80 </xsl:when>
81 <xsl:otherwise>
82 <xsl:message terminate="yes">
83Value '<xsl:value-of select="$mode"/>' of parameter 'mode' is invalid!
84 </xsl:message>
85 </xsl:otherwise>
86 </xsl:choose>
87</xsl:template>
88
89<!--
90 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
91 * declare mode (C++ header file)
92 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
93-->
94
95<xsl:template match="/" mode="declare">
96<xsl:text>
97/*
98 * DO NOT EDIT.
99 *
100 * This header is automatically generated from the VirtualBox XML Settings
101 * Schema and contains selected schema constraints declared in C++.
102 */
103
104#ifndef ____H_SCHEMADEFS
105#define ____H_SCHEMADEFS
106
107namespace SchemaDefs
108{
109 enum
110 {
111</xsl:text>
112
113 <xsl:apply-templates select="xsd:schema" mode="declare.enum"/>
114
115<xsl:text> DummyTerminator
116 };
117</xsl:text>
118
119<xsl:apply-templates select="xsd:schema" mode="declare"/>
120
121<xsl:text>}
122
123#endif // !____H_SCHEMADEFS
124</xsl:text>
125</xsl:template>
126
127<!--
128 * enumeration values
129-->
130<xsl:template match="xsd:schema" mode="declare.enum">
131
132 <!-- process include statements -->
133 <xsl:for-each select="xsd:include">
134 <xsl:apply-templates select="document(@schemaLocation)/xsd:schema" mode="declare.enum"/>
135 </xsl:for-each>
136
137 <xsl:call-template name="defineEnumMember">
138 <xsl:with-param name="member" select="'MinGuestRAM'"/>
139 <xsl:with-param name="select" select="
140 xsd:complexType[@name='TMemory']/xsd:attribute[@name='RAMSize']//xsd:minInclusive/@value
141 "/>
142 </xsl:call-template>
143 <xsl:call-template name="defineEnumMember">
144 <xsl:with-param name="member" select="'MaxGuestRAM'"/>
145 <xsl:with-param name="select" select="
146 xsd:complexType[@name='TMemory']/xsd:attribute[@name='RAMSize']//xsd:maxInclusive/@value
147 "/>
148 </xsl:call-template>
149
150 <xsl:call-template name="defineEnumMember">
151 <xsl:with-param name="member" select="'MinGuestVRAM'"/>
152 <xsl:with-param name="select" select="
153 xsd:complexType[@name='TDisplay']/xsd:attribute[@name='VRAMSize']//xsd:minInclusive/@value
154 "/>
155 </xsl:call-template>
156 <xsl:call-template name="defineEnumMember">
157 <xsl:with-param name="member" select="'MaxGuestVRAM'"/>
158 <xsl:with-param name="select" select="
159 xsd:complexType[@name='TDisplay']/xsd:attribute[@name='VRAMSize']//xsd:maxInclusive/@value
160 "/>
161 </xsl:call-template>
162
163 <xsl:call-template name="defineEnumMember">
164 <xsl:with-param name="member" select="'MinCPUCount'"/>
165 <xsl:with-param name="select" select="
166 xsd:simpleType[@name='TCPUCount']//xsd:minInclusive/@value
167 "/>
168 </xsl:call-template>
169 <xsl:call-template name="defineEnumMember">
170 <xsl:with-param name="member" select="'MaxCPUCount'"/>
171 <xsl:with-param name="select" select="
172 xsd:simpleType[@name='TCPUCount']//xsd:maxInclusive/@value
173 "/>
174 </xsl:call-template>
175
176 <xsl:call-template name="defineEnumMember">
177 <xsl:with-param name="member" select="'MaxGuestMonitors'"/>
178 <xsl:with-param name="select" select="
179 xsd:simpleType[@name='TMonitorCount']//xsd:maxInclusive/@value
180 "/>
181 </xsl:call-template>
182
183 <xsl:call-template name="defineEnumMember">
184 <xsl:with-param name="member" select="'SerialPortCount'"/>
185 <xsl:with-param name="select" select="
186 xsd:complexType[@name='TUARTPort']/xsd:attribute[@name='slot']//xsd:maxExclusive/@value
187 "/>
188 </xsl:call-template>
189
190 <xsl:call-template name="defineEnumMember">
191 <xsl:with-param name="member" select="'ParallelPortCount'"/>
192 <xsl:with-param name="select" select="
193 xsd:complexType[@name='TLPTPort']/xsd:attribute[@name='slot']//xsd:maxExclusive/@value
194 "/>
195 </xsl:call-template>
196
197 <xsl:call-template name="defineEnumMember">
198 <xsl:with-param name="member" select="'MaxBootPosition'"/>
199 <xsl:with-param name="select" select="
200 xsd:complexType[@name='TBoot']//xsd:element[@name='Order']//xsd:attribute[@name='position']//xsd:maxInclusive/@value
201 "/>
202 </xsl:call-template>
203
204 <xsl:call-template name="defineEnumMember">
205 <xsl:with-param name="member" select="'DefaultHardwareVersion'"/>
206 <xsl:with-param name="select" select="
207 xsd:complexType[@name='THardware']/xsd:attribute[@name='version']/@default
208 "/>
209 </xsl:call-template>
210
211</xsl:template>
212
213<!--
214 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
215 * define mode (C++ source file)
216 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
217-->
218
219<xsl:template match="/" mode="define">
220<xsl:text>
221/*
222 * DO NOT EDIT.
223 *
224 * This source is automatically generated from the VirtualBox XML Settings
225 * Schema and contains selected schema constraints defined in C++.
226 */
227
228#include "SchemaDefs.h"
229
230namespace SchemaDefs
231{
232</xsl:text>
233
234<xsl:apply-templates select="xsd:schema" mode="define"/>
235
236<xsl:text>}
237</xsl:text>
238</xsl:template>
239
240<!--
241 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
242 * END
243 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
244-->
245
246</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette