1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /*
19  * $Id$
20  */
21 
22 #if !defined(XERCESC_INCLUDE_GUARD_XSIDCDEFINITION_HPP)
23 #define XERCESC_INCLUDE_GUARD_XSIDCDEFINITION_HPP
24 
25 #include <xercesc/framework/psvi/XSObject.hpp>
26 
27 XERCES_CPP_NAMESPACE_BEGIN
28 
29 /**
30  * This class describes all properties of a Schema Identity Constraint
31  * Definition component.
32  * This is *always* owned by the validator /parser object from which
33  * it is obtained.
34  */
35 
36 // forward declarations
37 class XSAnnotation;
38 class IdentityConstraint;
39 
40 class XMLPARSER_EXPORT XSIDCDefinition : public XSObject
41 {
42 public:
43 
44     // Identity Constraints
45     enum IC_CATEGORY {
46 	    /**
47 	     *
48 	     */
49 	    IC_KEY                    = 1,
50 	    /**
51 	     *
52 	     */
53 	    IC_KEYREF                 = 2,
54 	    /**
55 	     *
56 	     */
57 	    IC_UNIQUE                 = 3
58     };
59 
60     //  Constructors and Destructor
61     // -----------------------------------------------------------------------
62     /** @name Constructors */
63     //@{
64 
65     /**
66       * The default constructor
67       *
68       * @param  identityConstraint
69       * @param  keyIC
70       * @param  headAnnot
71       * @param  stringList
72       * @param  xsModel
73       * @param  manager     The configurable memory manager
74       */
75     XSIDCDefinition
76     (
77         IdentityConstraint* const identityConstraint
78         , XSIDCDefinition*  const keyIC
79         , XSAnnotation* const     headAnnot
80         , StringList* const       stringList
81         , XSModel* const          xsModel
82         , MemoryManager* const    manager = XMLPlatformUtils::fgMemoryManager
83     );
84 
85     //@};
86 
87     /** @name Destructor */
88     //@{
89     ~XSIDCDefinition();
90     //@}
91 
92     //---------------------
93     /** @name overridden XSXSObject methods */
94 
95     //@{
96 
97     /**
98      * The name of type <code>NCName</code> of this declaration as defined in
99      * XML Namespaces.
100      */
101     const XMLCh* getName() const;
102 
103     /**
104      *  The [target namespace] of this object, or <code>null</code> if it is
105      * unspecified.
106      */
107     const XMLCh* getNamespace() const;
108 
109     /**
110      * A namespace schema information item corresponding to the target
111      * namespace of the component, if it's globally declared; or null
112      * otherwise.
113      */
114     XSNamespaceItem *getNamespaceItem();
115 
116     //@}
117 
118     //---------------------
119     /** @name XSIDCDefinition methods */
120 
121     //@{
122 
123     /**
124      * [identity-constraint category]: one of IC_KEY, IC_KEYREF or IC_UNIQUE.
125      */
126     IC_CATEGORY getCategory() const;
127 
128     /**
129      * [selector]: a restricted XPath expression.
130      */
131     const XMLCh *getSelectorStr();
132 
133     /**
134      * [fields]: a non-empty list of restricted XPath ([XPath]) expressions.
135      */
136     StringList *getFieldStrs();
137 
138     /**
139      * [referenced key]: required if [identity-constraint category] is IC_KEYREF,
140      * forbidden otherwise (when an identity-constraint definition with [
141      * identity-constraint category] equal to IC_KEY or IC_UNIQUE).
142      */
143     XSIDCDefinition *getRefKey() const;
144 
145     /**
146      * A set of [annotations].
147      */
148     XSAnnotationList *getAnnotations();
149 
150     //@}
151 
152     //----------------------------------
153     /** methods needed by implementation */
154 
155     //@{
156 
157     //@}
158 private:
159 
160     // -----------------------------------------------------------------------
161     //  Unimplemented constructors and operators
162     // -----------------------------------------------------------------------
163     XSIDCDefinition(const XSIDCDefinition&);
164     XSIDCDefinition & operator=(const XSIDCDefinition &);
165 
166 protected:
167 
168     // -----------------------------------------------------------------------
169     //  data members
170     // -----------------------------------------------------------------------
171     IdentityConstraint* fIdentityConstraint;
172     XSIDCDefinition*    fKey;
173     StringList*         fStringList;
174     XSAnnotationList*   fXSAnnotationList;
175 };
176 
177 
getFieldStrs()178 inline StringList* XSIDCDefinition::getFieldStrs()
179 {
180     return fStringList;
181 }
182 
getRefKey() const183 inline XSIDCDefinition* XSIDCDefinition::getRefKey() const
184 {
185     return fKey;
186 }
187 
188 XERCES_CPP_NAMESPACE_END
189 
190 #endif
191