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: PSVIAttributeList.hpp,v $
|
---|
59 | * Revision 1.7 2004/02/15 19:37:16 amassari
|
---|
60 | * Removed cause for warnings in VC 7.1
|
---|
61 | *
|
---|
62 | * Revision 1.6 2003/12/20 06:19:38 neilg
|
---|
63 | * store name/namespace of corresponding attribute in PSVIAttributeList; not all PSVIAttributes have XSAttributeDeclarations
|
---|
64 | *
|
---|
65 | * Revision 1.5 2003/12/15 17:23:48 cargilld
|
---|
66 | * psvi updates; cleanup revisits and bug fixes
|
---|
67 | *
|
---|
68 | * Revision 1.4 2003/12/02 16:21:41 neilg
|
---|
69 | * fix for ArrayIndexOutOfBoundsException in PSVIAttributeList; thanks to Pete Lloyd
|
---|
70 | *
|
---|
71 | * Revision 1.3 2003/11/26 16:20:37 neilg
|
---|
72 | * more complete implementation of PSVIAttributeList; remove some problematic const-ness
|
---|
73 | *
|
---|
74 | * Revision 1.2 2003/11/06 15:30:04 neilg
|
---|
75 | * first part of PSVI/schema component model implementation, thanks to David Cargill. This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse.
|
---|
76 | *
|
---|
77 | * Revision 1.1 2003/09/16 14:33:36 neilg
|
---|
78 | * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
|
---|
79 | *
|
---|
80 | */
|
---|
81 |
|
---|
82 | #if !defined(PSVIATTRIBUTEDERIVATION_LIST_HPP)
|
---|
83 | #define PSVIATTRIBUTEDERIVATION_LIST_HPP
|
---|
84 |
|
---|
85 | #include <xercesc/util/PlatformUtils.hpp>
|
---|
86 | #include <xercesc/framework/psvi/PSVIAttribute.hpp>
|
---|
87 | #include <xercesc/util/ValueVectorOf.hpp>
|
---|
88 |
|
---|
89 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
90 |
|
---|
91 | /**
|
---|
92 | * A container for the PSVI contributions to attributes that occur
|
---|
93 | * on a particular element.
|
---|
94 | * This is always owned by the parser/validator from
|
---|
95 | * which it is obtained. The parser/validator will specify
|
---|
96 | * under what conditions it may be relied upon to have meaningful contents.
|
---|
97 | */
|
---|
98 |
|
---|
99 |
|
---|
100 | class XMLPARSER_EXPORT PSVIAttributeList : public XMemory
|
---|
101 | {
|
---|
102 | public:
|
---|
103 |
|
---|
104 | // Constructors and Destructor
|
---|
105 | // -----------------------------------------------------------------------
|
---|
106 | /** @name Constructors */
|
---|
107 | //@{
|
---|
108 |
|
---|
109 | /**
|
---|
110 | * The default constructor
|
---|
111 | *
|
---|
112 | * @param manager The configurable memory manager
|
---|
113 | */
|
---|
114 | PSVIAttributeList( MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
115 |
|
---|
116 | //@};
|
---|
117 |
|
---|
118 | /** @name Destructor */
|
---|
119 | //@{
|
---|
120 | ~PSVIAttributeList();
|
---|
121 | //@}
|
---|
122 |
|
---|
123 | //---------------------
|
---|
124 | /** @name PSVIAttributeList methods */
|
---|
125 |
|
---|
126 | //@{
|
---|
127 |
|
---|
128 | /*
|
---|
129 | * Get the number of attributes whose PSVI contributions
|
---|
130 | * are contained in this list.
|
---|
131 | */
|
---|
132 | unsigned int getLength() const;
|
---|
133 |
|
---|
134 | /*
|
---|
135 | * Get the PSVI contribution of attribute at position i
|
---|
136 | * in this list. Indeces start from 0.
|
---|
137 | * @param index index from which the attribute PSVI contribution
|
---|
138 | * is to come.
|
---|
139 | * @return PSVIAttribute containing the attributes PSVI contributions;
|
---|
140 | * null is returned if the index is out of range.
|
---|
141 | */
|
---|
142 | PSVIAttribute *getAttributePSVIAtIndex(const unsigned int index);
|
---|
143 |
|
---|
144 | /*
|
---|
145 | * Get local part of attribute name at position index in the list.
|
---|
146 | * Indeces start from 0.
|
---|
147 | * @param index index from which the attribute name
|
---|
148 | * is to come.
|
---|
149 | * @return local part of the attribute's name; null is returned if the index
|
---|
150 | * is out of range.
|
---|
151 | */
|
---|
152 | const XMLCh *getAttributeNameAtIndex(const unsigned int index);
|
---|
153 |
|
---|
154 | /*
|
---|
155 | * Get namespace of attribute at position index in the list.
|
---|
156 | * Indeces start from 0.
|
---|
157 | * @param index index from which the attribute namespace
|
---|
158 | * is to come.
|
---|
159 | * @return namespace of the attribute;
|
---|
160 | * null is returned if the index is out of range.
|
---|
161 | */
|
---|
162 | const XMLCh *getAttributeNamespaceAtIndex(const unsigned int index);
|
---|
163 |
|
---|
164 | /*
|
---|
165 | * Get the PSVI contribution of attribute with given
|
---|
166 | * local name and namespace.
|
---|
167 | * @param attrName local part of the attribute's name
|
---|
168 | * @param attrNamespace namespace of the attribute
|
---|
169 | * @return null if the attribute PSVI does not exist
|
---|
170 | */
|
---|
171 | PSVIAttribute *getAttributePSVIByName(const XMLCh *attrName
|
---|
172 | , const XMLCh * attrNamespace);
|
---|
173 |
|
---|
174 | //@}
|
---|
175 |
|
---|
176 | //----------------------------------
|
---|
177 | /** methods needed by implementation */
|
---|
178 |
|
---|
179 | //@{
|
---|
180 |
|
---|
181 | /**
|
---|
182 | * returns a PSVI attribute of undetermined state and given name/namespace and
|
---|
183 | * makes that object part of the internal list. Intended to be called
|
---|
184 | * during validation of an element.
|
---|
185 | * @param attrName name of this attribute
|
---|
186 | * @param attrNS URI of the attribute
|
---|
187 | * @return new, uninitialized, PSVIAttribute object
|
---|
188 | */
|
---|
189 | PSVIAttribute *getPSVIAttributeToFill(
|
---|
190 | const XMLCh * attrName
|
---|
191 | , const XMLCh * attrNS);
|
---|
192 |
|
---|
193 | /**
|
---|
194 | * reset the list
|
---|
195 | */
|
---|
196 | void reset();
|
---|
197 |
|
---|
198 | //@}
|
---|
199 |
|
---|
200 | private:
|
---|
201 |
|
---|
202 | // -----------------------------------------------------------------------
|
---|
203 | // Unimplemented constructors and operators
|
---|
204 | // -----------------------------------------------------------------------
|
---|
205 | PSVIAttributeList(const PSVIAttributeList&);
|
---|
206 | PSVIAttributeList & operator=(const PSVIAttributeList &);
|
---|
207 |
|
---|
208 |
|
---|
209 | // -----------------------------------------------------------------------
|
---|
210 | // data members
|
---|
211 | // -----------------------------------------------------------------------
|
---|
212 | // fMemoryManager
|
---|
213 | // handler to provide dynamically-need memory
|
---|
214 | // fAttrList
|
---|
215 | // list of PSVIAttributes contained by this object
|
---|
216 | // fAttrNameList
|
---|
217 | // list of the names of the initialized PSVIAttribute objects contained
|
---|
218 | // in this listing
|
---|
219 | // fAttrNSList
|
---|
220 | // list of the namespaces of the initialized PSVIAttribute objects contained
|
---|
221 | // in this listing
|
---|
222 | // fAttrPos
|
---|
223 | // current number of initialized PSVIAttributes in fAttrList
|
---|
224 | MemoryManager* fMemoryManager;
|
---|
225 | RefVectorOf<PSVIAttribute>* fAttrList;
|
---|
226 | RefArrayVectorOf<XMLCh>* fAttrNameList;
|
---|
227 | RefArrayVectorOf<XMLCh>* fAttrNSList;
|
---|
228 | unsigned int fAttrPos;
|
---|
229 | };
|
---|
230 | inline PSVIAttributeList::~PSVIAttributeList()
|
---|
231 | {
|
---|
232 | delete fAttrList;
|
---|
233 | delete fAttrNameList;
|
---|
234 | delete fAttrNSList;
|
---|
235 | }
|
---|
236 |
|
---|
237 | inline PSVIAttribute *PSVIAttributeList::getPSVIAttributeToFill(
|
---|
238 | const XMLCh *attrName
|
---|
239 | , const XMLCh * attrNS)
|
---|
240 | {
|
---|
241 | PSVIAttribute *retAttr = 0;
|
---|
242 | if(fAttrPos == fAttrList->size())
|
---|
243 | {
|
---|
244 | retAttr = new (fMemoryManager)PSVIAttribute(fMemoryManager);
|
---|
245 | fAttrList->addElement(retAttr);
|
---|
246 | fAttrNameList->addElement((XMLCh *)attrName);
|
---|
247 | fAttrNSList->addElement((XMLCh *)attrNS);
|
---|
248 | }
|
---|
249 | else
|
---|
250 | {
|
---|
251 | retAttr = fAttrList->elementAt(fAttrPos);
|
---|
252 | fAttrNameList->setElementAt((XMLCh *)attrName, fAttrPos);
|
---|
253 | fAttrNSList->setElementAt((XMLCh *)attrNS, fAttrPos);
|
---|
254 | }
|
---|
255 | fAttrPos++;
|
---|
256 | return retAttr;
|
---|
257 | }
|
---|
258 |
|
---|
259 | inline void PSVIAttributeList::reset()
|
---|
260 | {
|
---|
261 | fAttrPos = 0;
|
---|
262 | }
|
---|
263 |
|
---|
264 | XERCES_CPP_NAMESPACE_END
|
---|
265 |
|
---|
266 | #endif
|
---|