source: NonGTP/Xerces/xerces-c_2_8_0/include/xercesc/framework/psvi/PSVIAttributeList.hpp @ 2674

Revision 2674, 6.4 KB checked in by mattausch, 16 years ago (diff)
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 568078 2007-08-21 11:43:25Z amassari $
20 */
21
22#if !defined(PSVIATTRIBUTEDERIVATION_LIST_HPP)
23#define PSVIATTRIBUTEDERIVATION_LIST_HPP
24
25#include <xercesc/util/PlatformUtils.hpp>
26#include <xercesc/framework/psvi/PSVIAttribute.hpp>
27#include <xercesc/util/ValueVectorOf.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
39
40class XMLPARSER_EXPORT PSVIAttributeList : public XMemory
41{
42public:
43
44    //  Constructors and Destructor
45    // -----------------------------------------------------------------------
46    /** @name Constructors */
47    //@{
48
49    /**
50      * The default constructor
51      *
52      * @param  manager     The configurable memory manager
53      */
54    PSVIAttributeList( MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
55
56    //@};
57
58    /** @name Destructor */
59    //@{
60    ~PSVIAttributeList();
61    //@}
62
63    //---------------------
64    /** @name PSVIAttributeList methods */
65
66    //@{
67
68    /*
69     * Get the number of attributes whose PSVI contributions
70     * are contained in this list.
71     */
72    unsigned int getLength() const;
73
74    /*
75     * Get the PSVI contribution of attribute at position i
76     * in this list.  Indeces start from 0.
77     * @param index index from which the attribute PSVI contribution
78     * is to come. 
79     * @return PSVIAttribute containing the attributes PSVI contributions;
80     * null is returned if the index is out of range.
81     */
82    PSVIAttribute *getAttributePSVIAtIndex(const unsigned int index);
83
84    /*
85     * Get local part of attribute name at position index in the list.
86     * Indeces start from 0.
87     * @param index index from which the attribute name
88     * is to come. 
89     * @return local part of the attribute's name; null is returned if the index
90     * is out of range.
91     */
92    const XMLCh *getAttributeNameAtIndex(const unsigned int index);
93
94    /*
95     * Get namespace of attribute at position index in the list.
96     * Indeces start from 0.
97     * @param index index from which the attribute namespace
98     * is to come. 
99     * @return namespace of the attribute;
100     * null is returned if the index is out of range.
101     */
102    const XMLCh *getAttributeNamespaceAtIndex(const unsigned int index);
103
104    /*
105     * Get the PSVI contribution of attribute with given
106     * local name and namespace.
107     * @param attrName  local part of the attribute's name
108     * @param attrNamespace  namespace of the attribute
109     * @return null if the attribute PSVI does not exist
110     */
111    PSVIAttribute *getAttributePSVIByName(const XMLCh *attrName
112                    , const XMLCh * attrNamespace);
113
114    //@}
115
116    //----------------------------------
117    /** methods needed by implementation */
118
119    //@{
120
121    /**
122      * returns a PSVI attribute of undetermined state and given name/namespace and
123      * makes that object part of the internal list.  Intended to be called
124      * during validation of an element.
125      * @param attrName     name of this attribute
126      * @param attrNS       URI of the attribute
127      * @return             new, uninitialized, PSVIAttribute object
128      */
129    PSVIAttribute *getPSVIAttributeToFill(
130            const XMLCh * attrName
131            , const XMLCh * attrNS);
132
133    /**
134      * reset the list
135      */
136    void reset();
137
138    //@}
139
140private:
141
142    // -----------------------------------------------------------------------
143    //  Unimplemented constructors and operators
144    // -----------------------------------------------------------------------
145    PSVIAttributeList(const PSVIAttributeList&);
146    PSVIAttributeList & operator=(const PSVIAttributeList &);
147
148
149    // -----------------------------------------------------------------------
150    //  data members
151    // -----------------------------------------------------------------------
152    // fMemoryManager
153    //  handler to provide dynamically-need memory
154    // fAttrList
155    //  list of PSVIAttributes contained by this object
156    // fAttrNameList
157    //  list of the names of the initialized PSVIAttribute objects contained
158    //  in this listing
159    // fAttrNSList
160    //  list of the namespaces of the initialized PSVIAttribute objects contained
161    //  in this listing
162    // fAttrPos
163    //  current number of initialized PSVIAttributes in fAttrList
164    MemoryManager*                  fMemoryManager;   
165    RefVectorOf<PSVIAttribute>*     fAttrList;
166    RefArrayVectorOf<XMLCh>*        fAttrNameList;
167    RefArrayVectorOf<XMLCh>*        fAttrNSList;
168    unsigned int                    fAttrPos;
169};
170inline PSVIAttributeList::~PSVIAttributeList()
171{
172    delete fAttrList;
173    delete fAttrNameList;
174    delete fAttrNSList;
175}
176
177inline PSVIAttribute *PSVIAttributeList::getPSVIAttributeToFill(
178            const XMLCh *attrName
179            , const XMLCh * attrNS)
180{
181    PSVIAttribute *retAttr = 0;
182    if(fAttrPos == fAttrList->size())
183    {
184        retAttr = new (fMemoryManager)PSVIAttribute(fMemoryManager);
185        fAttrList->addElement(retAttr);
186        fAttrNameList->addElement((XMLCh *)attrName);
187        fAttrNSList->addElement((XMLCh *)attrNS);
188    }
189    else
190    {
191        retAttr = fAttrList->elementAt(fAttrPos);
192        fAttrNameList->setElementAt((XMLCh *)attrName, fAttrPos);
193        fAttrNSList->setElementAt((XMLCh *)attrNS, fAttrPos);
194    }
195    fAttrPos++;
196    return retAttr;
197}
198
199inline void PSVIAttributeList::reset()
200{
201    fAttrPos = 0;
202}
203
204XERCES_CPP_NAMESPACE_END
205
206#endif
Note: See TracBrowser for help on using the repository browser.