source: trunk/src/xmlpatterns/schema/qxsdfacet_p.h@ 769

Last change on this file since 769 was 561, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.1 sources.

  • Property svn:eol-style set to native
File size: 9.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtXmlPatterns module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
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_XsdFacet_H
53#define Patternist_XsdFacet_H
54
55#include "qitem_p.h"
56#include "qnamedschemacomponent_p.h"
57#include "qxsdannotated_p.h"
58#include "qxsdassertion_p.h"
59
60#include <QtCore/QList>
61
62QT_BEGIN_HEADER
63
64QT_BEGIN_NAMESPACE
65
66namespace QPatternist
67{
68 /**
69 * @short Represents a XSD facet object.
70 *
71 * This class represents one of the following XML schema objects:
72 *
73 * <ul>
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>
87 * </ul>
88 *
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 <[email protected]>
92 */
93 class XsdFacet : public NamedSchemaComponent, public XsdAnnotated
94 {
95 public:
96 typedef QExplicitlySharedDataPointer<XsdFacet> Ptr;
97
98 /**
99 * Describes the type of the facet.
100 */
101 enum Type
102 {
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>)
117 };
118 typedef QHash<XsdFacet::Type, XsdFacet::Ptr> Hash;
119 typedef QHashIterator<XsdFacet::Type, XsdFacet::Ptr> HashIterator;
120
121 /**
122 * Creates a new facet object of type None.
123 */
124 XsdFacet();
125
126 /**
127 * Sets the @p type of the facet.
128 *
129 * @see Type
130 */
131 void setType(Type type);
132
133 /**
134 * Returns the type of the facet.
135 */
136 Type type() const;
137
138 /**
139 * Sets the @p value of the facet.
140 *
141 * Depending on the type of the facet the
142 * value can be a string, interger, double etc.
143 *
144 * @note This method should be used for all types of facets
145 * except Pattern, Enumeration and Assertion.
146 */
147 void setValue(const AtomicValue::Ptr &value);
148
149 /**
150 * Returns the value of the facet or an empty pointer if facet
151 * type is Pattern, Enumeration or Assertion.
152 */
153 AtomicValue::Ptr value() const;
154
155 /**
156 * Sets the @p value of the facet.
157 *
158 * @note This method should be used for if the type of the
159 * facet is Pattern or Enumeration.
160 */
161 void setMultiValue(const AtomicValue::List &value);
162
163 /**
164 * Returns the value of the facet or an empty pointer if facet
165 * type is not of type Pattern or Enumeration.
166 */
167 AtomicValue::List multiValue() const;
168
169 /**
170 * Sets the @p assertions of the facet.
171 *
172 * @note This method should be used if the type of the
173 * facet is Assertion.
174 */
175 void setAssertions(const XsdAssertion::List &assertions);
176
177 /**
178 * Returns the assertions of the facet or an empty pointer if facet
179 * type is not of type Assertion.
180 */
181 XsdAssertion::List assertions() const;
182
183 /**
184 * Sets whether the facet is @p fixed.
185 *
186 * All facets except pattern, enumeration and assertion can be fixed.
187 */
188 void setFixed(bool fixed);
189
190 /**
191 * Returns whether the facet is fixed.
192 */
193 bool fixed() const;
194
195 /**
196 * Returns the textual description of the facet @p type.
197 */
198 static QString typeName(Type type);
199
200 private:
201 Type m_type;
202 AtomicValue::Ptr m_value;
203 AtomicValue::List m_multiValue;
204 XsdAssertion::List m_assertions;
205 bool m_fixed;
206 };
207}
208
209QT_END_NAMESPACE
210
211QT_END_HEADER
212
213#endif
Note: See TracBrowser for help on using the repository browser.