/**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtXmlPatterns module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL3 included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or (at your option) the GNU General ** Public license version 3 or any later version approved by the KDE Free ** Qt Foundation. The licenses are as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-2.0.html and ** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. #ifndef Patternist_XsdFacet_H #define Patternist_XsdFacet_H #include #include #include #include #include QT_BEGIN_NAMESPACE namespace QPatternist { /** * @short Represents a XSD facet object. * * This class represents one of the following XML schema objects: * * * * @see XML Schema API reference * @ingroup Patternist_schema * @author Tobias Koenig */ class XsdFacet : public NamedSchemaComponent, public XsdAnnotated { public: typedef QExplicitlySharedDataPointer Ptr; /** * Describes the type of the facet. */ enum Type { None = 0, ///< An invalid facet. Length = 1 << 0, ///< Match the exact length (Length Definition) MinimumLength = 1 << 1, ///< Match the minimum length (Minimum Length Definition) MaximumLength = 1 << 2, ///< Match the maximum length (Maximum Length Definition) Pattern = 1 << 3, ///< Match a regular expression (Pattern Definition) WhiteSpace = 1 << 4, ///< Match a whitespace rule (White Space Definition) MaximumInclusive = 1 << 5, ///< Match a maximum inclusive (Maximum Inclusive Definition) MaximumExclusive = 1 << 6, ///< Match a maximum exclusive (Maximum Exclusive Definition) MinimumInclusive = 1 << 7, ///< Match a minimum inclusive (Minimum Inclusive Definition) MinimumExclusive = 1 << 8, ///< Match a minimum exclusive (Minimum Exclusive Definition) TotalDigits = 1 << 9, ///< Match some integer digits (Total Digits Definition) FractionDigits = 1 << 10, ///< Match some double digits (Fraction Digits Definition) Enumeration = 1 << 11, ///< Match an enumeration (Enumeration Definition) Assertion = 1 << 12, ///< Match an assertion (Assertion Definition) }; typedef QHash Hash; /** * Creates a new facet object of type None. */ XsdFacet(); /** * Sets the @p type of the facet. * * @see Type */ void setType(Type type); /** * Returns the type of the facet. */ Type type() const; /** * Sets the @p value of the facet. * * Depending on the type of the facet the * value can be a string, interger, double etc. * * @note This method should be used for all types of facets * except Pattern, Enumeration and Assertion. */ void setValue(const AtomicValue::Ptr &value); /** * Returns the value of the facet or an empty pointer if facet * type is Pattern, Enumeration or Assertion. */ AtomicValue::Ptr value() const; /** * Sets the @p value of the facet. * * @note This method should be used for if the type of the * facet is Pattern or Enumeration. */ void setMultiValue(const AtomicValue::List &value); /** * Returns the value of the facet or an empty pointer if facet * type is not of type Pattern or Enumeration. */ AtomicValue::List multiValue() const; /** * Sets the @p assertions of the facet. * * @note This method should be used if the type of the * facet is Assertion. */ void setAssertions(const XsdAssertion::List &assertions); /** * Returns the assertions of the facet or an empty pointer if facet * type is not of type Assertion. */ XsdAssertion::List assertions() const; /** * Sets whether the facet is @p fixed. * * All facets except pattern, enumeration and assertion can be fixed. */ void setFixed(bool fixed); /** * Returns whether the facet is fixed. */ bool fixed() const; /** * Returns the textual description of the facet @p type. */ static QString typeName(Type type); private: Type m_type; AtomicValue::Ptr m_value; AtomicValue::List m_multiValue; XsdAssertion::List m_assertions; bool m_fixed; }; } QT_END_NAMESPACE #endif