Xerces-C++ 3.1.3

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

PSVIAttributeList.hpp
Go to the documentation of this file.
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: PSVIAttributeList.hpp 932887 2010-04-11 13:04:59Z borisk $
20 */
21
22 #if !defined(XERCESC_INCLUDE_GUARD_PSVIATTRIBUTE_LIST_HPP)
23 #define XERCESC_INCLUDE_GUARD_PSVIATTRIBUTE_LIST_HPP
24
25 #include <xercesc/util/PlatformUtils.hpp>
26 #include <xercesc/framework/psvi/PSVIAttribute.hpp>
27 #include <xercesc/util/RefVectorOf.hpp>
28
29 XERCES_CPP_NAMESPACE_BEGIN
30
39 class XMLPARSER_EXPORT PSVIAttributeStorage : public XMemory
40 {
41 public:
42 PSVIAttributeStorage() :
43 fPSVIAttribute(0)
44 , fAttributeName(0)
45 , fAttributeNamespace(0)
46 {
47 }
48
49 ~PSVIAttributeStorage()
50 {
51 delete fPSVIAttribute;
52 }
53
54 PSVIAttribute* fPSVIAttribute;
55 const XMLCh* fAttributeName;
56 const XMLCh* fAttributeNamespace;
57 };
58
59 class XMLPARSER_EXPORT PSVIAttributeList : public XMemory
60 {
61 public:
62
63 // Constructors and Destructor
64 // -----------------------------------------------------------------------
67
73 PSVIAttributeList( MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
74
76
79 ~PSVIAttributeList();
81
82 //---------------------
86
87 /*
88 * Get the number of attributes whose PSVI contributions
89 * are contained in this list.
90 */
91 XMLSize_t getLength() const;
92
93 /*
94 * Get the PSVI contribution of attribute at position i
95 * in this list. Indices start from 0.
96 * @param index index from which the attribute PSVI contribution
97 * is to come.
98 * @return PSVIAttribute containing the attributes PSVI contributions;
99 * null is returned if the index is out of range.
100 */
101 PSVIAttribute *getAttributePSVIAtIndex(const XMLSize_t index);
102
103 /*
104 * Get local part of attribute name at position index in the list.
105 * Indices start from 0.
106 * @param index index from which the attribute name
107 * is to come.
108 * @return local part of the attribute's name; null is returned if the index
109 * is out of range.
110 */
111 const XMLCh *getAttributeNameAtIndex(const XMLSize_t index);
112
113 /*
114 * Get namespace of attribute at position index in the list.
115 * Indices start from 0.
116 * @param index index from which the attribute namespace
117 * is to come.
118 * @return namespace of the attribute;
119 * null is returned if the index is out of range.
120 */
121 const XMLCh *getAttributeNamespaceAtIndex(const XMLSize_t index);
122
123 /*
124 * Get the PSVI contribution of attribute with given
125 * local name and namespace.
126 * @param attrName local part of the attribute's name
127 * @param attrNamespace namespace of the attribute
128 * @return null if the attribute PSVI does not exist
129 */
130 PSVIAttribute *getAttributePSVIByName(const XMLCh *attrName
131 , const XMLCh * attrNamespace);
132
134
135 //----------------------------------
139
148 PSVIAttribute *getPSVIAttributeToFill(
149 const XMLCh * attrName
150 , const XMLCh * attrNS);
151
155 void reset();
156
158
159 private:
160
161 // -----------------------------------------------------------------------
162 // Unimplemented constructors and operators
163 // -----------------------------------------------------------------------
164 PSVIAttributeList(const PSVIAttributeList&);
165 PSVIAttributeList & operator=(const PSVIAttributeList &);
166
167
168 // -----------------------------------------------------------------------
169 // data members
170 // -----------------------------------------------------------------------
171 // fMemoryManager
172 // handler to provide dynamically-need memory
173 // fAttrList
174 // list of PSVIAttributes contained by this object
175 // fAttrPos
176 // current number of initialized PSVIAttributes in fAttrList
177 MemoryManager* fMemoryManager;
178 RefVectorOf<PSVIAttributeStorage>* fAttrList;
179 XMLSize_t fAttrPos;
180 };
181
182 inline PSVIAttributeList::~PSVIAttributeList()
183 {
184 delete fAttrList;
185 }
186
187 inline PSVIAttribute *PSVIAttributeList::getPSVIAttributeToFill(
188 const XMLCh *attrName
189 , const XMLCh * attrNS)
190 {
191 PSVIAttributeStorage* storage = 0;
192 if(fAttrPos == fAttrList->size())
193 {
194 storage = new (fMemoryManager) PSVIAttributeStorage();
195 storage->fPSVIAttribute = new (fMemoryManager) PSVIAttribute(fMemoryManager);
196 fAttrList->addElement(storage);
197 }
198 else
199 {
200 storage = fAttrList->elementAt(fAttrPos);
201 }
202 storage->fAttributeName = attrName;
203 storage->fAttributeNamespace = attrNS;
204 fAttrPos++;
205 return storage->fPSVIAttribute;
206 }
207
208 inline void PSVIAttributeList::reset()
209 {
210 fAttrPos = 0;
211 }
212
213 XERCES_CPP_NAMESPACE_END
214
215 #endif