1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40//
41// W A R N I N G
42// -------------
43//
44// This file is not part of the Qt API. It exists purely as an
45// implementation detail. This header file may change from version to
46// version without notice, or even be removed.
47//
48// We mean it.
49
50#ifndef Patternist_XsdSimpleType_H
51#define Patternist_XsdSimpleType_H
52
53#include <private/qanysimpletype_p.h>
54#include <private/qxsdfacet_p.h>
55#include <private/qxsduserschematype_p.h>
56
57#include <QtCore/QSet>
58
59QT_BEGIN_NAMESPACE
60
61namespace QPatternist
62{
63 /**
64 * @short Represents a XSD simpleType object.
65 *
66 * This class represents the <em>simpleType</em> object of a XML schema as described
67 * <a href="http://www.w3.org/TR/xmlschema-2/#rf-defn">here</a>.
68 *
69 * It contains information from either a top-level simple type declaration (as child of a <em>schema</em> object)
70 * or a local simple type declaration (as descendant of an <em>element</em> or <em>complexType</em> object).
71 *
72 * @see <a href="http://www.w3.org/Submission/2004/SUBM-xmlschema-api-20040309/xml-schema-api.html#Interface-XSSimpleType">XML Schema API reference</a>
73 * @ingroup Patternist_schema
74 * @author Tobias Koenig <tobias.koenig@nokia.com>
75 */
76 class XsdSimpleType : public XsdUserSchemaType<AnySimpleType>
77 {
78 public:
79 typedef QExplicitlySharedDataPointer<XsdSimpleType> Ptr;
80
81 /**
82 * Returns the display name of the simple type.
83 *
84 * @param namePool The name pool the type name is stored in.
85 */
86 virtual QString displayName(const NamePool::Ptr &namePool) const;
87
88 /**
89 * Sets the base @p type of the simple type.
90 *
91 * @see <a href="http://www.w3.org/TR/xmlschema-2/#defn-basetype">Base Type Definition</a>
92 */
93 void setWxsSuperType(const SchemaType::Ptr &type);
94
95 /**
96 * Returns the base type of the simple type or an empty pointer if no base type is
97 * set.
98 */
99 virtual SchemaType::Ptr wxsSuperType() const;
100
101 /**
102 * Sets the context @p component of the simple type.
103 *
104 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#std-context">Context Definition</a>
105 */
106 void setContext(const NamedSchemaComponent::Ptr &component);
107
108 /**
109 * Returns the context component of the simple type.
110 */
111 NamedSchemaComponent::Ptr context() const;
112
113 /**
114 * Sets the primitive @p type of the simple type.
115 *
116 * The primitive type is only specified if the category is SimpleTypeAtomic.
117 *
118 * @see <a href="http://www.w3.org/TR/xmlschema-2/#defn-primitive">Primitive Type Definition</a>
119 */
120 void setPrimitiveType(const AnySimpleType::Ptr &type);
121
122 /**
123 * Returns the primitive type of the simple type or an empty pointer if the category is
124 * not SimpleTypeAtomic.
125 */
126 AnySimpleType::Ptr primitiveType() const;
127
128 /**
129 * Sets the list item @p type of the simple type.
130 *
131 * The list item type is only specified if the category is SimpleTypeList.
132 *
133 * @see <a href="http://www.w3.org/TR/xmlschema-2/#defn-itemType">Item Type Definition</a>
134 */
135 void setItemType(const AnySimpleType::Ptr &type);
136
137 /**
138 * Returns the list item type of the simple type or an empty pointer if the category is
139 * not SimpleTypeList.
140 */
141 AnySimpleType::Ptr itemType() const;
142
143 /**
144 * Sets the member @p types of the simple type.
145 *
146 * The member types are only specified if the category is SimpleTypeUnion.
147 *
148 * @see <a href="http://www.w3.org/TR/xmlschema-2/#defn-memberTypes">Member Types Definition</a>
149 */
150 void setMemberTypes(const AnySimpleType::List &types);
151
152 /**
153 * Returns the list member types of the simple type or an empty list if the category is
154 * not SimpleTypeUnion.
155 */
156 AnySimpleType::List memberTypes() const;
157
158 /**
159 * Sets the @p facets of the simple type.
160 *
161 * @see <a href="http://www.w3.org/TR/xmlschema-2/#defn-facets">Facets Definition</a>
162 */
163 void setFacets(const XsdFacet::Hash &facets);
164
165 /**
166 * Returns the facets of the simple type.
167 */
168 XsdFacet::Hash facets() const;
169
170 /**
171 * Sets the @p category (variety) of the simple type.
172 *
173 * @see <a href="http://www.w3.org/TR/xmlschema-2/#defn-variety">Variety Definition</a>
174 */
175 void setCategory(TypeCategory category);
176
177 /**
178 * Returns the category (variety) of the simple type.
179 */
180 virtual TypeCategory category() const;
181
182 /**
183 * Sets the derivation @p method of the simple type.
184 *
185 * @see DerivationMethod
186 */
187 void setDerivationMethod(DerivationMethod method);
188
189 /**
190 * Returns the derivation method of the simple type.
191 */
192 virtual DerivationMethod derivationMethod() const;
193
194 /**
195 * Always returns @c true.
196 */
197 virtual bool isDefinedBySchema() const;
198
199 private:
200 SchemaType::Ptr m_superType;
201 NamedSchemaComponent::Ptr m_context;
202 AnySimpleType::Ptr m_primitiveType;
203 AnySimpleType::Ptr m_itemType;
204 AnySimpleType::List m_memberTypes;
205 XsdFacet::Hash m_facets;
206 TypeCategory m_typeCategory;
207 DerivationMethod m_derivationMethod;
208 };
209}
210
211QT_END_NAMESPACE
212
213#endif
214

source code of qtxmlpatterns/src/xmlpatterns/schema/qxsdsimpletype_p.h