Update copyright year in license headers.
[profile/ivi/qtxmlpatterns.git] / src / xmlpatterns / schema / qxsdcomplextype_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 //
43 //  W A R N I N G
44 //  -------------
45 //
46 // This file is not part of the Qt API.  It exists purely as an
47 // implementation detail.  This header file may change from version to
48 // version without notice, or even be removed.
49 //
50 // We mean it.
51
52 #ifndef Patternist_XsdComplexType_H
53 #define Patternist_XsdComplexType_H
54
55 #include <private/qanytype_p.h>
56 #include <private/qxsdassertion_p.h>
57 #include <private/qxsdattributeuse_p.h>
58 #include <private/qxsdparticle_p.h>
59 #include <private/qxsdsimpletype_p.h>
60 #include <private/qxsduserschematype_p.h>
61 #include <private/qxsdwildcard_p.h>
62
63 #include <QtCore/QSet>
64
65 QT_BEGIN_HEADER
66
67 QT_BEGIN_NAMESPACE
68
69 namespace QPatternist
70 {
71     /**
72      * @short Represents a XSD complexType object.
73      *
74      * This class represents the <em>complexType</em> object of a XML schema as described
75      * <a href="http://www.w3.org/TR/xmlschema11-1/#Complex_Type_Definitions">here</a>.
76      *
77      * It contains information from either a top-level complex type declaration (as child of a <em>schema</em> object)
78      * or a local complex type declaration (as descendant of an <em>element</em> object).
79      *
80      * @see <a href="http://www.w3.org/Submission/2004/SUBM-xmlschema-api-20040309/xml-schema-api.html#Interface-XSComplexType">XML Schema API reference</a>
81      * @ingroup Patternist_schema
82      * @author Tobias Koenig <tobias.koenig@nokia.com>
83      */
84     class XsdComplexType : public XsdUserSchemaType<AnyType>
85     {
86         public:
87             typedef QExplicitlySharedDataPointer<XsdComplexType> Ptr;
88
89             /**
90              * @short Describes the open content object of a complex type.
91              *
92              * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ct-open_content">Open Content Definition</a>
93              */
94             class OpenContent : public QSharedData, public XsdAnnotated
95             {
96                 public:
97                     typedef QExplicitlySharedDataPointer<OpenContent> Ptr;
98
99                     /**
100                      * Describes the mode of the open content.
101                      *
102                      * @see <a href="http://www.w3.org/TR/xmlschema11-1/#oc-mode">Mode Definition</a>
103                      */
104                     enum Mode
105                     {
106                         None,
107                         Interleave,
108                         Suffix
109                     };
110
111                     /**
112                      * Sets the @p mode of the open content.
113                      *
114                      * @see <a href="http://www.w3.org/TR/xmlschema11-1/#oc-mode">Mode Definition</a>
115                      */
116                     void setMode(Mode mode);
117
118                     /**
119                      * Returns the mode of the open content.
120                      */
121                     Mode mode() const;
122
123                     /**
124                      * Sets the @p wildcard of the open content.
125                      *
126                      * @see <a href="http://www.w3.org/TR/xmlschema11-1/#oc-wildcard">Wildcard Definition</a>
127                      */
128                     void setWildcard(const XsdWildcard::Ptr &wildcard);
129
130                     /**
131                      * Returns the wildcard of the open content.
132                      */
133                     XsdWildcard::Ptr wildcard() const;
134
135                 private:
136                     Mode             m_mode;
137                     XsdWildcard::Ptr m_wildcard;
138             };
139
140             /**
141              * @short Describes the content type of a complex type.
142              */
143             class ContentType : public QSharedData
144             {
145                 public:
146                     typedef QExplicitlySharedDataPointer<ContentType> Ptr;
147
148                     /**
149                      * Describes the variety of the content type.
150                      */
151                     enum Variety
152                     {
153                         Empty = 0,    ///< The complex type has no further content.
154                         Simple,       ///< The complex type has only simple type content (e.g. text, number etc.)
155                         ElementOnly,  ///< The complex type has further elements or attributes but no text as content.
156                         Mixed         ///< The complex type has further elements or attributes and text as content.
157                     };
158
159                     /**
160                      * Sets the @p variety of the content type.
161                      *
162                      * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ct-variety">Variety Definition</a>
163                      */
164                     void setVariety(Variety variety);
165
166                     /**
167                      * Returns the variety of the content type.
168                      */
169                     Variety variety() const;
170
171                     /**
172                      * Sets the @p particle object of the content type.
173                      *
174                      * The content type has only a particle object if
175                      * its variety is ElementOnly or Mixed.
176                      *
177                      * @see XsdParticle
178                      * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ct-particle">Particle Declaration</a>
179                      */
180                     void setParticle(const XsdParticle::Ptr &particle);
181
182                     /**
183                      * Returns the particle object of the content type,
184                      * or an empty pointer if its variety is neither
185                      * ElementOnly nor Mixed.
186                      */
187                     XsdParticle::Ptr particle() const;
188
189                     /**
190                      * Sets the open @p content object of the content type.
191                      *
192                      * The content type has only an open content object if
193                      * its variety is ElementOnly or Mixed.
194                      *
195                      * @see OpenContent
196                      * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ct-open_content">Open Content Declaration</a>
197                      */
198                     void setOpenContent(const OpenContent::Ptr &content);
199
200                     /**
201                      * Returns the open content object of the content type,
202                      * or an empty pointer if its variety is neither
203                      * ElementOnly nor Mixed.
204                      */
205                     OpenContent::Ptr openContent() const;
206
207                     /**
208                      * Sets the simple @p type object of the content type.
209                      *
210                      * The content type has only a simple type object if
211                      * its variety is Simple.
212                      *
213                      * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ct-simple_type_definition">Simple Type Definition</a>
214                      */
215                     void setSimpleType(const AnySimpleType::Ptr &type);
216
217                     /**
218                      * Returns the simple type object of the content type,
219                      * or an empty pointer if its variety is not Simple.
220                      */
221                     AnySimpleType::Ptr simpleType() const;
222
223                 private:
224                     Variety            m_variety;
225                     XsdParticle::Ptr   m_particle;
226                     OpenContent::Ptr   m_openContent;
227                     XsdSimpleType::Ptr m_simpleType;
228             };
229
230
231             /**
232              * Creates a complex type object with empty content.
233              */
234             XsdComplexType();
235
236             /**
237              * Destroys the complex type object.
238              */
239             ~XsdComplexType() {};
240
241             /**
242              * Returns the display name of the complex type.
243              *
244              * The display name can be used to show the type name
245              * to the user.
246              *
247              * @param namePool The name pool where the type name is stored in.
248              */
249             virtual QString displayName(const NamePool::Ptr &namePool) const;
250
251             /**
252              * Sets the base type of the complex type.
253              *
254              * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-base_type_definition">Base Type Definition</a>
255              */
256             void setWxsSuperType(const SchemaType::Ptr &type);
257
258             /**
259              * Returns the base type of the complex type.
260              */
261             virtual SchemaType::Ptr wxsSuperType() const;
262
263             /**
264              * Sets the context @p component of the complex type.
265              *
266              * The component is either an element declaration or a complex type definition.
267              */
268             void setContext(const NamedSchemaComponent::Ptr &component);
269
270             /**
271              * Returns the context component of the complex type.
272              */
273             NamedSchemaComponent::Ptr context() const;
274
275             /**
276              * Sets the derivation @p method of the complex type.
277              *
278              * The derivation method depends on whether the complex
279              * type object has an extension or restriction object as child.
280              *
281              * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-derivation_method">Derivation Method Definition</a>
282              * @see DerivationMethod
283              */
284             void setDerivationMethod(DerivationMethod method);
285
286             /**
287              * Returns the derivation method of the complex type.
288              */
289             virtual DerivationMethod derivationMethod() const;
290
291             /**
292              * Sets whether the complex type is @p abstract.
293              *
294              * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-abstract">Abstract Definition</a>
295              */
296             void setIsAbstract(bool abstract);
297
298             /**
299              * Returns whether the complex type is abstract.
300              */
301             virtual bool isAbstract() const;
302
303             /**
304              * Sets the list of all attribute @p uses of the complex type.
305              *
306              * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-attribute_uses">Attribute Uses Declaration</a>
307              */
308             void setAttributeUses(const XsdAttributeUse::List &uses);
309
310             /**
311              * Adds a new attribute @p use to the complex type.
312              */
313             void addAttributeUse(const XsdAttributeUse::Ptr &use);
314
315             /**
316              * Returns the list of all attribute uses of the complex type.
317              */
318             XsdAttributeUse::List attributeUses() const;
319
320             /**
321              * Sets the attribute @p wildcard of the complex type.
322              *
323              * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-attribute_wildcard">Attribute Wildcard Declaration</a>
324              */
325             void setAttributeWildcard(const XsdWildcard::Ptr &wildcard);
326
327             /**
328              * Returns the attribute wildcard of the complex type.
329              */
330             XsdWildcard::Ptr attributeWildcard() const;
331
332             /**
333              * Always returns SchemaType::ComplexType
334              */
335             virtual TypeCategory category() const;
336
337             /**
338              * Sets the content @p type of the complex type.
339              *
340              * @see ContentType
341              */
342             void setContentType(const ContentType::Ptr &type);
343
344             /**
345              * Returns the content type of the complex type.
346              */
347             ContentType::Ptr contentType() const;
348
349             /**
350              * Sets the prohibited @p substitutions of the complex type.
351              *
352              * Only ExtensionConstraint and RestrictionConstraint are allowed.
353              *
354              * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-prohibited_substitutions">Prohibited Substitutions Definition</a>
355              */
356             void setProhibitedSubstitutions(const BlockingConstraints &substitutions);
357
358             /**
359              * Returns the prohibited substitutions of the complex type.
360              */
361             BlockingConstraints prohibitedSubstitutions() const;
362
363             /**
364              * Sets the @p assertions of the complex type.
365              *
366              * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-assertions">Assertions Definition</a>
367              */
368             void setAssertions(const XsdAssertion::List &assertions);
369
370             /**
371              * Adds an @p assertion to the complex type.
372              *
373              * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-assertions">Assertions Definition</a>
374              */
375             void addAssertion(const XsdAssertion::Ptr &assertion);
376
377             /**
378              * Returns the assertions of the complex type.
379              */
380             XsdAssertion::List assertions() const;
381
382             /**
383              * Always returns @c true.
384              */
385             virtual bool isDefinedBySchema() const;
386
387         private:
388             SchemaType::Ptr           m_superType;
389             NamedSchemaComponent::Ptr m_context;
390             DerivationMethod          m_derivationMethod;
391             bool                      m_isAbstract;
392             XsdAttributeUse::List     m_attributeUses;
393             XsdWildcard::Ptr          m_attributeWildcard;
394             ContentType::Ptr          m_contentType;
395             BlockingConstraints       m_prohibitedSubstitutions;
396             XsdAssertion::List        m_assertions;
397     };
398 }
399
400 QT_END_NAMESPACE
401
402 QT_END_HEADER
403
404 #endif