1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 2003 The Apache Software Foundation. All rights
|
---|
5 | * reserved.
|
---|
6 | *
|
---|
7 | * Redistribution and use in source and binary forms, with or without
|
---|
8 | * modification, are permitted provided that the following conditions
|
---|
9 | * are met:
|
---|
10 | *
|
---|
11 | * 1. Redistributions of source code must retain the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer.
|
---|
13 | *
|
---|
14 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
15 | * notice, this list of conditions and the following disclaimer in
|
---|
16 | * the documentation and/or other materials provided with the
|
---|
17 | * distribution.
|
---|
18 | *
|
---|
19 | * 3. The end-user documentation included with the redistribution,
|
---|
20 | * if any, must include the following acknowledgment:
|
---|
21 | * "This product includes software developed by the
|
---|
22 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
23 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
24 | * if and wherever such third-party acknowledgments normally appear.
|
---|
25 | *
|
---|
26 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
27 | * not be used to endorse or promote products derived from this
|
---|
28 | * software without prior written permission. For written
|
---|
29 | * permission, please contact apache\@apache.org.
|
---|
30 | *
|
---|
31 | * 5. Products derived from this software may not be called "Apache",
|
---|
32 | * nor may "Apache" appear in their name, without prior written
|
---|
33 | * permission of the Apache Software Foundation.
|
---|
34 | *
|
---|
35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
46 | * SUCH DAMAGE.
|
---|
47 | * ====================================================================
|
---|
48 | *
|
---|
49 | * This software consists of voluntary contributions made by many
|
---|
50 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
51 | * originally based on software copyright (c) 1999, International
|
---|
52 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
53 | * on the Apache Software Foundation, please see
|
---|
54 | * <http://www.apache.org/>.
|
---|
55 | */
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * $Log: XSParticle.hpp,v $
|
---|
59 | * Revision 1.5 2003/12/01 23:23:26 neilg
|
---|
60 | * fix for bug 25118; thanks to Jeroen Witmond
|
---|
61 | *
|
---|
62 | * Revision 1.4 2003/11/21 17:34:04 knoaman
|
---|
63 | * PSVI update
|
---|
64 | *
|
---|
65 | * Revision 1.3 2003/11/14 22:47:53 neilg
|
---|
66 | * fix bogus log message from previous commit...
|
---|
67 | *
|
---|
68 | * Revision 1.2 2003/11/14 22:33:30 neilg
|
---|
69 | * Second phase of schema component model implementation.
|
---|
70 | * Implement XSModel, XSNamespaceItem, and the plumbing necessary
|
---|
71 | * to connect them to the other components.
|
---|
72 | * Thanks to David Cargill.
|
---|
73 | *
|
---|
74 | * Revision 1.1 2003/09/16 14:33:36 neilg
|
---|
75 | * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
|
---|
76 | *
|
---|
77 | */
|
---|
78 |
|
---|
79 | #if !defined(XSPARTICLE_HPP)
|
---|
80 | #define XSPARTICLE_HPP
|
---|
81 |
|
---|
82 | #include <xercesc/framework/psvi/XSObject.hpp>
|
---|
83 |
|
---|
84 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * This class describes all properties of a Schema Particle
|
---|
88 | * component.
|
---|
89 | * This is *always* owned by the validator /parser object from which
|
---|
90 | * it is obtained.
|
---|
91 | */
|
---|
92 |
|
---|
93 | // forward declarations
|
---|
94 | class XSElementDeclaration;
|
---|
95 | class XSModelGroup;
|
---|
96 | class XSWildcard;
|
---|
97 |
|
---|
98 | class XMLPARSER_EXPORT XSParticle : public XSObject
|
---|
99 | {
|
---|
100 | public:
|
---|
101 |
|
---|
102 | // possible terms of this particle
|
---|
103 | enum TERM_TYPE {
|
---|
104 | /*
|
---|
105 | * an empty particle
|
---|
106 | */
|
---|
107 | TERM_EMPTY = 0,
|
---|
108 | /*
|
---|
109 | * the particle has element content
|
---|
110 | */
|
---|
111 | TERM_ELEMENT = XSConstants::ELEMENT_DECLARATION,
|
---|
112 | /*
|
---|
113 | * the particle's content is a model group
|
---|
114 | */
|
---|
115 | TERM_MODELGROUP = XSConstants::MODEL_GROUP_DEFINITION,
|
---|
116 | /*
|
---|
117 | * the particle's content is a wildcard
|
---|
118 | */
|
---|
119 | TERM_WILDCARD = XSConstants::WILDCARD
|
---|
120 | };
|
---|
121 |
|
---|
122 | // Constructors and Destructor
|
---|
123 | // -----------------------------------------------------------------------
|
---|
124 | /** @name Constructors */
|
---|
125 | //@{
|
---|
126 |
|
---|
127 | /**
|
---|
128 | * The default constructor
|
---|
129 | *
|
---|
130 | * @param termType
|
---|
131 | * @param xsModel
|
---|
132 | * @param particleTerm
|
---|
133 | * @param minOccurs
|
---|
134 | * @param maxOccurs
|
---|
135 | * @param manager The configurable memory manager
|
---|
136 | */
|
---|
137 | XSParticle
|
---|
138 | (
|
---|
139 | TERM_TYPE termType
|
---|
140 | , XSModel* const xsModel
|
---|
141 | , XSObject* const particleTerm
|
---|
142 | , int minOccurs
|
---|
143 | , int maxOccurs
|
---|
144 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
145 | );
|
---|
146 |
|
---|
147 | //@};
|
---|
148 |
|
---|
149 | /** @name Destructor */
|
---|
150 | //@{
|
---|
151 | ~XSParticle();
|
---|
152 | //@}
|
---|
153 |
|
---|
154 | //---------------------
|
---|
155 | /** @name XSParticle methods */
|
---|
156 | //@{
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * [min occurs]: determines the minimum number of terms that can occur.
|
---|
160 | */
|
---|
161 | int getMinOccurs() const;
|
---|
162 |
|
---|
163 | /**
|
---|
164 | * [max occurs] determines the maximum number of terms that can occur. To
|
---|
165 | * query for value of unbounded use <code>maxOccursUnbounded</code>.
|
---|
166 | */
|
---|
167 | int getMaxOccurs() const;
|
---|
168 |
|
---|
169 | /**
|
---|
170 | * [max occurs] whether the maxOccurs value is unbounded.
|
---|
171 | */
|
---|
172 | bool getMaxOccursUnbounded() const;
|
---|
173 |
|
---|
174 | /**
|
---|
175 | * Returns the type of the [term]: one of
|
---|
176 | * TERM_EMPTY, TERM_ELEMENT, TERM_MODELGROUP, or TERM_WILDCARD.
|
---|
177 | */
|
---|
178 | TERM_TYPE getTermType() const;
|
---|
179 |
|
---|
180 | /**
|
---|
181 | * If this particle has an [element declaration] for its term,
|
---|
182 | * this method returns that declaration; otherwise, it returns 0.
|
---|
183 | * @returns The element declaration that is the [term] of this Particle
|
---|
184 | * if and only if getTermType() == TERM_ELEMENT.
|
---|
185 | */
|
---|
186 | XSElementDeclaration *getElementTerm();
|
---|
187 |
|
---|
188 | /**
|
---|
189 | * If this particle has a [model group] for its term,
|
---|
190 | * this method returns that definition; otherwise, it returns 0.
|
---|
191 | * @returns The model group that is the [term] of this Particle
|
---|
192 | * if and only if getTermType() == TERM_MODELGROUP.
|
---|
193 | */
|
---|
194 | XSModelGroup *getModelGroupTerm();
|
---|
195 |
|
---|
196 | /**
|
---|
197 | * If this particle has an [wildcard] for its term,
|
---|
198 | * this method returns that declaration; otherwise, it returns 0.
|
---|
199 | * @returns The wildcard declaration that is the [term] of this Particle
|
---|
200 | * if and only if getTermType() == TERM_WILDCARD.
|
---|
201 | */
|
---|
202 | XSWildcard *getWildcardTerm();
|
---|
203 |
|
---|
204 | //@}
|
---|
205 |
|
---|
206 | //----------------------------------
|
---|
207 | /** methods needed by implementation */
|
---|
208 | //@{
|
---|
209 |
|
---|
210 | //@}
|
---|
211 | private:
|
---|
212 |
|
---|
213 | // -----------------------------------------------------------------------
|
---|
214 | // Unimplemented constructors and operators
|
---|
215 | // -----------------------------------------------------------------------
|
---|
216 | XSParticle(const XSParticle&);
|
---|
217 | XSParticle & operator=(const XSParticle &);
|
---|
218 |
|
---|
219 | protected:
|
---|
220 |
|
---|
221 | // -----------------------------------------------------------------------
|
---|
222 | // data members
|
---|
223 | // -----------------------------------------------------------------------
|
---|
224 | TERM_TYPE fTermType;
|
---|
225 | int fMinOccurs;
|
---|
226 | int fMaxOccurs;
|
---|
227 | XSObject* fTerm;
|
---|
228 | };
|
---|
229 |
|
---|
230 | inline int XSParticle::getMinOccurs() const
|
---|
231 | {
|
---|
232 | return fMinOccurs;
|
---|
233 | }
|
---|
234 |
|
---|
235 | inline int XSParticle::getMaxOccurs() const
|
---|
236 | {
|
---|
237 | return fMaxOccurs;
|
---|
238 | }
|
---|
239 |
|
---|
240 | inline bool XSParticle::getMaxOccursUnbounded() const
|
---|
241 | {
|
---|
242 | return (fMaxOccurs == -1);
|
---|
243 | }
|
---|
244 |
|
---|
245 | inline XSParticle::TERM_TYPE XSParticle::getTermType() const
|
---|
246 | {
|
---|
247 | return fTermType;
|
---|
248 | }
|
---|
249 |
|
---|
250 | XERCES_CPP_NAMESPACE_END
|
---|
251 |
|
---|
252 | #endif
|
---|