1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
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.
52 #ifndef Patternist_XsdFacet_H
53 #define Patternist_XsdFacet_H
55 #include <private/qitem_p.h>
56 #include <private/qnamedschemacomponent_p.h>
57 #include <private/qxsdannotated_p.h>
58 #include <private/qxsdassertion_p.h>
60 #include <QtCore/QList>
69 * @short Represents a XSD facet object.
71 * This class represents one of the following XML schema objects:
74 * <li><em>length</em> <a href="http://www.w3.org/TR/xmlschema-2/#rf-length">Definition</a></li>
75 * <li><em>minLength</em> <a href="http://www.w3.org/TR/xmlschema-2/#rf-minLength">Definition</a></li>
76 * <li><em>maxLength</em> <a href="http://www.w3.org/TR/xmlschema-2/#rf-maxLength">Definition</a></li>
77 * <li><em>pattern</em> <a href="http://www.w3.org/TR/xmlschema-2/#rf-pattern">Definition</a></li>
78 * <li><em>whiteSpace</em> <a href="http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace">Definition</a></li>
79 * <li><em>maxInclusive</em> <a href="http://www.w3.org/TR/xmlschema-2/#rf-maxInclusive">Definition</a></li>
80 * <li><em>maxExclusive</em> <a href="http://www.w3.org/TR/xmlschema-2/#rf-maxExclusive">Definition</a></li>
81 * <li><em>minInclusive</em> <a href="http://www.w3.org/TR/xmlschema-2/#rf-minInclusive">Definition</a></li>
82 * <li><em>minExclusive</em> <a href="http://www.w3.org/TR/xmlschema-2/#rf-minExclusive">Definition</a></li>
83 * <li><em>totalDigits</em> <a href="http://www.w3.org/TR/xmlschema-2/#rf-totalDigits">Definition</a></li>
84 * <li><em>fractionDigits</em> <a href="http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits">Definition</a></li>
85 * <li><em>enumeration</em> <a href="http://www.w3.org/TR/xmlschema-2/#rf-enumeration">Definition</a></li>
86 * <li><em>assertion</em> <a href="http://www.w3.org/TR/xmlschema-2/#rf-assertion">Definition</a></li>
89 * @see <a href="http://www.w3.org/Submission/2004/SUBM-xmlschema-api-20040309/xml-schema-api.html#Interface-XSFacet">XML Schema API reference</a>
90 * @ingroup Patternist_schema
91 * @author Tobias Koenig <tobias.koenig@nokia.com>
93 class XsdFacet : public NamedSchemaComponent, public XsdAnnotated
96 typedef QExplicitlySharedDataPointer<XsdFacet> Ptr;
99 * Describes the type of the facet.
103 None = 0, ///< An invalid facet.
104 Length = 1 << 0, ///< Match the exact length (<a href="http://www.w3.org/TR/xmlschema-2/#rf-length">Length Definition</a>)
105 MinimumLength = 1 << 1, ///< Match the minimum length (<a href="http://www.w3.org/TR/xmlschema-2/#rf-minLength">Minimum Length Definition</a>)
106 MaximumLength = 1 << 2, ///< Match the maximum length (<a href="http://www.w3.org/TR/xmlschema-2/#rf-maxLength">Maximum Length Definition</a>)
107 Pattern = 1 << 3, ///< Match a regular expression (<a href="http://www.w3.org/TR/xmlschema-2/#rf-pattern">Pattern Definition</a>)
108 WhiteSpace = 1 << 4, ///< Match a whitespace rule (<a href="http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace">White Space Definition</a>)
109 MaximumInclusive = 1 << 5, ///< Match a maximum inclusive (<a href="http://www.w3.org/TR/xmlschema-2/#rf-maxInclusive">Maximum Inclusive Definition</a>)
110 MaximumExclusive = 1 << 6, ///< Match a maximum exclusive (<a href="http://www.w3.org/TR/xmlschema-2/#rf-maxExclusive">Maximum Exclusive Definition</a>)
111 MinimumInclusive = 1 << 7, ///< Match a minimum inclusive (<a href="http://www.w3.org/TR/xmlschema-2/#rf-minInclusive">Minimum Inclusive Definition</a>)
112 MinimumExclusive = 1 << 8, ///< Match a minimum exclusive (<a href="http://www.w3.org/TR/xmlschema-2/#rf-minExclusive">Minimum Exclusive Definition</a>)
113 TotalDigits = 1 << 9, ///< Match some integer digits (<a href="http://www.w3.org/TR/xmlschema-2/#rf-totalDigits">Total Digits Definition</a>)
114 FractionDigits = 1 << 10, ///< Match some double digits (<a href="http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits">Fraction Digits Definition</a>)
115 Enumeration = 1 << 11, ///< Match an enumeration (<a href="http://www.w3.org/TR/xmlschema-2/#rf-enumeration">Enumeration Definition</a>)
116 Assertion = 1 << 12, ///< Match an assertion (<a href="http://www.w3.org/TR/xmlschema-2/#rf-assertion">Assertion Definition</a>)
118 typedef QHash<XsdFacet::Type, XsdFacet::Ptr> Hash;
119 typedef QHashIterator<XsdFacet::Type, XsdFacet::Ptr> HashIterator;
122 * Creates a new facet object of type None.
127 * Sets the @p type of the facet.
131 void setType(Type type);
134 * Returns the type of the facet.
139 * Sets the @p value of the facet.
141 * Depending on the type of the facet the
142 * value can be a string, interger, double etc.
144 * @note This method should be used for all types of facets
145 * except Pattern, Enumeration and Assertion.
147 void setValue(const AtomicValue::Ptr &value);
150 * Returns the value of the facet or an empty pointer if facet
151 * type is Pattern, Enumeration or Assertion.
153 AtomicValue::Ptr value() const;
156 * Sets the @p value of the facet.
158 * @note This method should be used for if the type of the
159 * facet is Pattern or Enumeration.
161 void setMultiValue(const AtomicValue::List &value);
164 * Returns the value of the facet or an empty pointer if facet
165 * type is not of type Pattern or Enumeration.
167 AtomicValue::List multiValue() const;
170 * Sets the @p assertions of the facet.
172 * @note This method should be used if the type of the
173 * facet is Assertion.
175 void setAssertions(const XsdAssertion::List &assertions);
178 * Returns the assertions of the facet or an empty pointer if facet
179 * type is not of type Assertion.
181 XsdAssertion::List assertions() const;
184 * Sets whether the facet is @p fixed.
186 * All facets except pattern, enumeration and assertion can be fixed.
188 void setFixed(bool fixed);
191 * Returns whether the facet is fixed.
196 * Returns the textual description of the facet @p type.
198 static QString typeName(Type type);
202 AtomicValue::Ptr m_value;
203 AtomicValue::List m_multiValue;
204 XsdAssertion::List m_assertions;