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: XSParticle.hpp 883665 2009-11-24 11:41:38Z borisk $ |
---|
20 | */ |
---|
21 | |
---|
22 | #if !defined(XERCESC_INCLUDE_GUARD_XSPARTICLE_HPP) |
---|
23 | #define XERCESC_INCLUDE_GUARD_XSPARTICLE_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 Particle |
---|
31 | * component. |
---|
32 | * This is *always* owned by the validator /parser object from which |
---|
33 | * it is obtained. |
---|
34 | */ |
---|
35 | |
---|
36 | // forward declarations |
---|
37 | class XSElementDeclaration; |
---|
38 | class XSModelGroup; |
---|
39 | class XSWildcard; |
---|
40 | |
---|
41 | class XMLPARSER_EXPORT XSParticle : public XSObject |
---|
42 | { |
---|
43 | public: |
---|
44 | |
---|
45 | // possible terms of this particle |
---|
46 | enum TERM_TYPE { |
---|
47 | /* |
---|
48 | * an empty particle |
---|
49 | */ |
---|
50 | TERM_EMPTY = 0, |
---|
51 | /* |
---|
52 | * the particle has element content |
---|
53 | */ |
---|
54 | TERM_ELEMENT = XSConstants::ELEMENT_DECLARATION, |
---|
55 | /* |
---|
56 | * the particle's content is a model group |
---|
57 | */ |
---|
58 | TERM_MODELGROUP = XSConstants::MODEL_GROUP_DEFINITION, |
---|
59 | /* |
---|
60 | * the particle's content is a wildcard |
---|
61 | */ |
---|
62 | TERM_WILDCARD = XSConstants::WILDCARD |
---|
63 | }; |
---|
64 | |
---|
65 | // Constructors and Destructor |
---|
66 | // ----------------------------------------------------------------------- |
---|
67 | /** @name Constructors */ |
---|
68 | //@{ |
---|
69 | |
---|
70 | /** |
---|
71 | * The default constructor |
---|
72 | * |
---|
73 | * @param termType |
---|
74 | * @param xsModel |
---|
75 | * @param particleTerm |
---|
76 | * @param minOccurs |
---|
77 | * @param maxOccurs |
---|
78 | * @param unbounded |
---|
79 | * @param manager The configurable memory manager |
---|
80 | */ |
---|
81 | XSParticle |
---|
82 | ( |
---|
83 | TERM_TYPE termType |
---|
84 | , XSModel* const xsModel |
---|
85 | , XSObject* const particleTerm |
---|
86 | , XMLSize_t minOccurs |
---|
87 | , XMLSize_t maxOccurs |
---|
88 | , bool unbounded |
---|
89 | , MemoryManager* const manager |
---|
90 | ); |
---|
91 | |
---|
92 | //@}; |
---|
93 | |
---|
94 | /** @name Destructor */ |
---|
95 | //@{ |
---|
96 | ~XSParticle(); |
---|
97 | //@} |
---|
98 | |
---|
99 | //--------------------- |
---|
100 | /** @name XSParticle methods */ |
---|
101 | //@{ |
---|
102 | |
---|
103 | /** |
---|
104 | * [min occurs]: determines the minimum number of terms that can occur. |
---|
105 | */ |
---|
106 | XMLSize_t getMinOccurs() const; |
---|
107 | |
---|
108 | /** |
---|
109 | * [max occurs] determines the maximum number of terms that can occur. To |
---|
110 | * query for value of unbounded use <code>maxOccursUnbounded</code>. |
---|
111 | */ |
---|
112 | XMLSize_t getMaxOccurs() const; |
---|
113 | |
---|
114 | /** |
---|
115 | * [max occurs] whether the maxOccurs value is unbounded. |
---|
116 | */ |
---|
117 | bool getMaxOccursUnbounded() const; |
---|
118 | |
---|
119 | /** |
---|
120 | * Returns the type of the [term]: one of |
---|
121 | * TERM_EMPTY, TERM_ELEMENT, TERM_MODELGROUP, or TERM_WILDCARD. |
---|
122 | */ |
---|
123 | TERM_TYPE getTermType() const; |
---|
124 | |
---|
125 | /** |
---|
126 | * If this particle has an [element declaration] for its term, |
---|
127 | * this method returns that declaration; otherwise, it returns 0. |
---|
128 | * @returns The element declaration that is the [term] of this Particle |
---|
129 | * if and only if getTermType() == TERM_ELEMENT. |
---|
130 | */ |
---|
131 | XSElementDeclaration *getElementTerm(); |
---|
132 | |
---|
133 | /** |
---|
134 | * If this particle has a [model group] for its term, |
---|
135 | * this method returns that definition; otherwise, it returns 0. |
---|
136 | * @returns The model group that is the [term] of this Particle |
---|
137 | * if and only if getTermType() == TERM_MODELGROUP. |
---|
138 | */ |
---|
139 | XSModelGroup *getModelGroupTerm(); |
---|
140 | |
---|
141 | /** |
---|
142 | * If this particle has an [wildcard] for its term, |
---|
143 | * this method returns that declaration; otherwise, it returns 0. |
---|
144 | * @returns The wildcard declaration that is the [term] of this Particle |
---|
145 | * if and only if getTermType() == TERM_WILDCARD. |
---|
146 | */ |
---|
147 | XSWildcard *getWildcardTerm(); |
---|
148 | |
---|
149 | //@} |
---|
150 | |
---|
151 | //---------------------------------- |
---|
152 | /** methods needed by implementation */ |
---|
153 | //@{ |
---|
154 | |
---|
155 | //@} |
---|
156 | private: |
---|
157 | |
---|
158 | // ----------------------------------------------------------------------- |
---|
159 | // Unimplemented constructors and operators |
---|
160 | // ----------------------------------------------------------------------- |
---|
161 | XSParticle(const XSParticle&); |
---|
162 | XSParticle & operator=(const XSParticle &); |
---|
163 | |
---|
164 | protected: |
---|
165 | |
---|
166 | // ----------------------------------------------------------------------- |
---|
167 | // data members |
---|
168 | // ----------------------------------------------------------------------- |
---|
169 | TERM_TYPE fTermType; |
---|
170 | XMLSize_t fMinOccurs; |
---|
171 | XMLSize_t fMaxOccurs; |
---|
172 | bool fUnbounded; |
---|
173 | XSObject* fTerm; |
---|
174 | }; |
---|
175 | |
---|
176 | inline XMLSize_t XSParticle::getMinOccurs() const |
---|
177 | { |
---|
178 | return fMinOccurs; |
---|
179 | } |
---|
180 | |
---|
181 | inline XMLSize_t XSParticle::getMaxOccurs() const |
---|
182 | { |
---|
183 | return fMaxOccurs; |
---|
184 | } |
---|
185 | |
---|
186 | inline bool XSParticle::getMaxOccursUnbounded() const |
---|
187 | { |
---|
188 | return fUnbounded; |
---|
189 | } |
---|
190 | |
---|
191 | inline XSParticle::TERM_TYPE XSParticle::getTermType() const |
---|
192 | { |
---|
193 | return fTermType; |
---|
194 | } |
---|
195 | |
---|
196 | XERCES_CPP_NAMESPACE_END |
---|
197 | |
---|
198 | #endif |
---|