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_XsdIdentityConstraint_H
51#define Patternist_XsdIdentityConstraint_H
52
53#include <private/qnamedschemacomponent_p.h>
54#include <private/qxsdannotated_p.h>
55#include <private/qxsdxpathexpression_p.h>
56
57#include <QtCore/QStringList>
58
59QT_BEGIN_NAMESPACE
60
61namespace QPatternist
62{
63 /**
64 * @short Represents a XSD identity constraint object.
65 *
66 * This class represents the <em>identity constraint</em> object of a XML schema as described
67 * <a href="http://www.w3.org/TR/xmlschema11-1/#cIdentity-constraint_Definitions">here</a>.
68 *
69 * It contains information from either a <em>key</em> object, a <em>keyref</em> object or an
70 * <em>unique</em> object.
71 *
72 * @see <a href="http://www.w3.org/Submission/2004/SUBM-xmlschema-api-20040309/xml-schema-api.html#Interface-XSIdentityConstraint">XML Schema API reference</a>
73 * @ingroup Patternist_schema
74 * @author Tobias Koenig <tobias.koenig@nokia.com>
75 */
76 class XsdIdentityConstraint : public NamedSchemaComponent, public XsdAnnotated
77 {
78 public:
79 typedef QExplicitlySharedDataPointer<XsdIdentityConstraint> Ptr;
80 typedef QList<XsdIdentityConstraint::Ptr> List;
81
82 /**
83 * Describes the <a href="http://www.w3.org/TR/xmlschema11-1/#icd-identity-constraint_category">category</a> of the identity constraint.
84 */
85 enum Category
86 {
87 Key = 1, ///< The constraint is a key constraint
88 KeyReference, ///< The constraint is a keyref constraint
89 Unique ///< The constraint is an unique constraint
90 };
91
92 /**
93 * Sets the @p category of the identity constraint.
94 *
95 * @see Category
96 */
97 void setCategory(Category category);
98
99 /**
100 * Returns the category of the identity constraint.
101 */
102 Category category() const;
103
104 /**
105 * Sets the @p selector of the identity constraint.
106 *
107 * The selector is a restricted XPath 1.0 expression,
108 * that selects a set of nodes.
109 *
110 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#icd-selector"></a>
111 */
112 void setSelector(const XsdXPathExpression::Ptr &selector);
113
114 /**
115 * Returns the selector of the identity constraint.
116 */
117 XsdXPathExpression::Ptr selector() const;
118
119 /**
120 * Sets the @p fields of the identity constraint.
121 *
122 * Each field is a restricted XPath 1.0 expression,
123 * that selects a set of nodes.
124 *
125 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#icd-fields"></a>
126 */
127 void setFields(const XsdXPathExpression::List &fields);
128
129 /**
130 * Adds a new @p field to the identity constraint.
131 */
132 void addField(const XsdXPathExpression::Ptr &field);
133
134 /**
135 * Returns all fields of the identity constraint.
136 */
137 XsdXPathExpression::List fields() const;
138
139 /**
140 * Sets the referenced @p key of the identity constraint.
141 *
142 * The key points to a identity constraint of type Key or Unique.
143 *
144 * The identity constraint has only a referenced key if its
145 * type is KeyReference.
146 *
147 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#icd-referenced_key"></a>
148 */
149 void setReferencedKey(const XsdIdentityConstraint::Ptr &key);
150
151 /**
152 * Returns the referenced key of the identity constraint or an empty
153 * pointer if its type is not KeyReference.
154 */
155 XsdIdentityConstraint::Ptr referencedKey() const;
156
157 private:
158 Category m_category;
159 XsdXPathExpression::Ptr m_selector;
160 XsdXPathExpression::List m_fields;
161 XsdIdentityConstraint::Ptr m_referencedKey;
162 };
163}
164
165QT_END_NAMESPACE
166
167#endif
168

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