source: icXML/icXML-devel/src/xercesc/framework/psvi/PSVIAttributeList.hpp

Last change on this file was 3565, checked in by cameron, 6 years ago

Updates to xercesc sources

File size: 6.9 KB
Line 
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 <icxercesc/util/PlatformUtils.hpp>
26#include <xercesc/framework/psvi/PSVIAttribute.hpp>
27#include <xercesc/util/RefVectorOf.hpp>
28
29XERCES_CPP_NAMESPACE_BEGIN
30
31/**
32 * A container for the PSVI contributions to attributes that occur
33 * on a particular element.
34 * This is always owned by the parser/validator from
35 * which it is obtained.  The parser/validator will specify
36 * under what conditions it may be relied upon to have meaningful contents.
37 */
38
39class XMLPARSER_EXPORT PSVIAttributeStorage : public XMemory
40{
41public:
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
59class XMLPARSER_EXPORT PSVIAttributeList : public XMemory
60{
61public:
62
63    //  Constructors and Destructor
64    // -----------------------------------------------------------------------
65    /** @name Constructors */
66    //@{
67
68    /**
69      * The default constructor
70      *
71      * @param  manager     The configurable memory manager
72      */
73    PSVIAttributeList( MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
74
75    //@};
76
77    /** @name Destructor */
78    //@{
79    ~PSVIAttributeList();
80    //@}
81
82    //---------------------
83    /** @name PSVIAttributeList methods */
84
85    //@{
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, const XMLCh * attrNamespace);
131
132    //@}
133
134    //----------------------------------
135    /** methods needed by implementation */
136
137    //@{
138
139    /**
140      * returns a PSVI attribute of undetermined state and given name/namespace and
141      * makes that object part of the internal list.  Intended to be called
142      * during validation of an element.
143      * @param attrName     name of this attribute
144      * @param attrNS       URI of the attribute
145      * @return             new, uninitialized, PSVIAttribute object
146      */
147    PSVIAttribute *getPSVIAttributeToFill(const XMLCh * attrName, const XMLCh * attrNS);
148
149    PSVIAttribute *getPSVIAttributeToFill(const XMLSize_t index, const XMLCh * attrName, const XMLCh * attrNS);
150
151
152    void setPSVIMaxAttributeCount(const XMLSize_t maxAttributeCount);
153
154    /**
155      * reset the list
156      */
157    void reset();
158
159    void setAttributeCount(XMLSize_t attributeCount);
160
161    //@}
162
163private:
164
165    // -----------------------------------------------------------------------
166    //  Unimplemented constructors and operators
167    // -----------------------------------------------------------------------
168    PSVIAttributeList(const PSVIAttributeList&);
169    PSVIAttributeList & operator=(const PSVIAttributeList &);
170
171
172    // -----------------------------------------------------------------------
173    //  data members
174    // -----------------------------------------------------------------------
175    // fMemoryManager
176    //  handler to provide dynamically-need memory
177    // fAttrList
178    //  list of PSVIAttributes contained by this object
179    // fAttrPos
180    //  current number of initialized PSVIAttributes in fAttrList   
181    RefVectorOf<PSVIAttributeStorage>   fAttrList;
182    XMLSize_t                           fAttrCount;
183    MemoryManager*                      fMemoryManager;
184};
185
186inline PSVIAttributeList::~PSVIAttributeList()
187{
188
189}
190
191inline PSVIAttribute *PSVIAttributeList::getPSVIAttributeToFill(const XMLSize_t index, const XMLCh *attrName, const XMLCh * attrNS)
192{
193    PSVIAttributeStorage* storage = fAttrList.elementAt(index);
194    storage->fAttributeName = attrName;
195    storage->fAttributeNamespace = attrNS;
196    return storage->fPSVIAttribute;
197}
198
199inline void PSVIAttributeList::setAttributeCount(const XMLSize_t attributeCount)
200{
201    fAttrCount = attributeCount;
202}
203
204inline void PSVIAttributeList::setPSVIMaxAttributeCount(const XMLSize_t maxAttributeCount)
205{
206    if (unlikely(maxAttributeCount > fAttrList.size()))
207    {
208        XMLSize_t count = maxAttributeCount - fAttrList.size();
209        do
210        {
211            PSVIAttributeStorage * storage = new (fMemoryManager) PSVIAttributeStorage();
212            storage->fPSVIAttribute = new (fMemoryManager) PSVIAttribute(fMemoryManager);
213            fAttrList.addElement(storage);
214        }
215        while (--count);
216    }
217}
218
219inline void PSVIAttributeList::reset()
220{
221    fAttrCount = 0;
222}
223
224inline PSVIAttribute *PSVIAttributeList::getPSVIAttributeToFill(const XMLCh *, const XMLCh *)
225{
226    DEPRECATED_FEATURE_IN_ICXML;
227}
228
229XERCES_CPP_NAMESPACE_END
230
231#endif
Note: See TracBrowser for help on using the repository browser.