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

Last change on this file since 2722 was 2722, checked in by cameron, 7 years ago

Original Xerces files with import mods for icxercesc

File size: 6.3 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
131                    , const XMLCh * attrNamespace);
132
133    //@}
134
135    //----------------------------------
136    /** methods needed by implementation */
137
138    //@{
139
140    /**
141      * returns a PSVI attribute of undetermined state and given name/namespace and
142      * makes that object part of the internal list.  Intended to be called
143      * during validation of an element.
144      * @param attrName     name of this attribute
145      * @param attrNS       URI of the attribute
146      * @return             new, uninitialized, PSVIAttribute object
147      */
148    PSVIAttribute *getPSVIAttributeToFill(
149            const XMLCh * attrName
150            , const XMLCh * attrNS);
151
152    /**
153      * reset the list
154      */
155    void reset();
156
157    //@}
158
159private:
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
182inline PSVIAttributeList::~PSVIAttributeList()
183{
184    delete fAttrList;
185}
186
187inline 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
208inline void PSVIAttributeList::reset()
209{
210    fAttrPos = 0;
211}
212
213XERCES_CPP_NAMESPACE_END
214
215#endif
Note: See TracBrowser for help on using the repository browser.