source: trunk/VUT/GtpVisibilityPreprocessor/support/xerces/include/xercesc/framework/psvi/PSVIAttributeList.hpp @ 358

Revision 358, 7.6 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 2003,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * $Log: PSVIAttributeList.hpp,v $
19 * Revision 1.8  2004/09/08 13:56:07  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.7  2004/02/15 19:37:16  amassari
23 * Removed cause for warnings in VC 7.1
24 *
25 * Revision 1.6  2003/12/20 06:19:38  neilg
26 * store name/namespace of corresponding attribute in PSVIAttributeList; not all PSVIAttributes have XSAttributeDeclarations
27 *
28 * Revision 1.5  2003/12/15 17:23:48  cargilld
29 * psvi updates; cleanup revisits and bug fixes
30 *
31 * Revision 1.4  2003/12/02 16:21:41  neilg
32 * fix for ArrayIndexOutOfBoundsException in PSVIAttributeList; thanks to Pete Lloyd
33 *
34 * Revision 1.3  2003/11/26 16:20:37  neilg
35 * more complete implementation of PSVIAttributeList; remove some problematic const-ness
36 *
37 * Revision 1.2  2003/11/06 15:30:04  neilg
38 * 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.
39 *
40 * Revision 1.1  2003/09/16 14:33:36  neilg
41 * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
42 *
43 */
44
45#if !defined(PSVIATTRIBUTEDERIVATION_LIST_HPP)
46#define PSVIATTRIBUTEDERIVATION_LIST_HPP
47
48#include <xercesc/util/PlatformUtils.hpp>
49#include <xercesc/framework/psvi/PSVIAttribute.hpp>
50#include <xercesc/util/ValueVectorOf.hpp>
51
52XERCES_CPP_NAMESPACE_BEGIN
53
54/**
55 * A container for the PSVI contributions to attributes that occur
56 * on a particular element.
57 * This is always owned by the parser/validator from
58 * which it is obtained.  The parser/validator will specify
59 * under what conditions it may be relied upon to have meaningful contents.
60 */
61
62
63class XMLPARSER_EXPORT PSVIAttributeList : public XMemory
64{
65public:
66
67    //  Constructors and Destructor
68    // -----------------------------------------------------------------------
69    /** @name Constructors */
70    //@{
71
72    /**
73      * The default constructor
74      *
75      * @param  manager     The configurable memory manager
76      */
77    PSVIAttributeList( MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
78
79    //@};
80
81    /** @name Destructor */
82    //@{
83    ~PSVIAttributeList();
84    //@}
85
86    //---------------------
87    /** @name PSVIAttributeList methods */
88
89    //@{
90
91    /*
92     * Get the number of attributes whose PSVI contributions
93     * are contained in this list.
94     */
95    unsigned int getLength() const;
96
97    /*
98     * Get the PSVI contribution of attribute at position i
99     * in this list.  Indeces start from 0.
100     * @param index index from which the attribute PSVI contribution
101     * is to come. 
102     * @return PSVIAttribute containing the attributes PSVI contributions;
103     * null is returned if the index is out of range.
104     */
105    PSVIAttribute *getAttributePSVIAtIndex(const unsigned int index);
106
107    /*
108     * Get local part of attribute name at position index in the list.
109     * Indeces start from 0.
110     * @param index index from which the attribute name
111     * is to come. 
112     * @return local part of the attribute's name; null is returned if the index
113     * is out of range.
114     */
115    const XMLCh *getAttributeNameAtIndex(const unsigned int index);
116
117    /*
118     * Get namespace of attribute at position index in the list.
119     * Indeces start from 0.
120     * @param index index from which the attribute namespace
121     * is to come. 
122     * @return namespace of the attribute;
123     * null is returned if the index is out of range.
124     */
125    const XMLCh *getAttributeNamespaceAtIndex(const unsigned int index);
126
127    /*
128     * Get the PSVI contribution of attribute with given
129     * local name and namespace.
130     * @param attrName  local part of the attribute's name
131     * @param attrNamespace  namespace of the attribute
132     * @return null if the attribute PSVI does not exist
133     */
134    PSVIAttribute *getAttributePSVIByName(const XMLCh *attrName
135                    , const XMLCh * attrNamespace);
136
137    //@}
138
139    //----------------------------------
140    /** methods needed by implementation */
141
142    //@{
143
144    /**
145      * returns a PSVI attribute of undetermined state and given name/namespace and
146      * makes that object part of the internal list.  Intended to be called
147      * during validation of an element.
148      * @param attrName     name of this attribute
149      * @param attrNS       URI of the attribute
150      * @return             new, uninitialized, PSVIAttribute object
151      */
152    PSVIAttribute *getPSVIAttributeToFill(
153            const XMLCh * attrName
154            , const XMLCh * attrNS);
155
156    /**
157      * reset the list
158      */
159    void reset();
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    // fAttrNameList
180    //  list of the names of the initialized PSVIAttribute objects contained
181    //  in this listing
182    // fAttrNSList
183    //  list of the namespaces of the initialized PSVIAttribute objects contained
184    //  in this listing
185    // fAttrPos
186    //  current number of initialized PSVIAttributes in fAttrList
187    MemoryManager*                  fMemoryManager;   
188    RefVectorOf<PSVIAttribute>*     fAttrList;
189    RefArrayVectorOf<XMLCh>*        fAttrNameList;
190    RefArrayVectorOf<XMLCh>*        fAttrNSList;
191    unsigned int                    fAttrPos;
192};
193inline PSVIAttributeList::~PSVIAttributeList()
194{
195    delete fAttrList;
196    delete fAttrNameList;
197    delete fAttrNSList;
198}
199
200inline PSVIAttribute *PSVIAttributeList::getPSVIAttributeToFill(
201            const XMLCh *attrName
202            , const XMLCh * attrNS)
203{
204    PSVIAttribute *retAttr = 0;
205    if(fAttrPos == fAttrList->size())
206    {
207        retAttr = new (fMemoryManager)PSVIAttribute(fMemoryManager);
208        fAttrList->addElement(retAttr);
209        fAttrNameList->addElement((XMLCh *)attrName);
210        fAttrNSList->addElement((XMLCh *)attrNS);
211    }
212    else
213    {
214        retAttr = fAttrList->elementAt(fAttrPos);
215        fAttrNameList->setElementAt((XMLCh *)attrName, fAttrPos);
216        fAttrNSList->setElementAt((XMLCh *)attrNS, fAttrPos);
217    }
218    fAttrPos++;
219    return retAttr;
220}
221
222inline void PSVIAttributeList::reset()
223{
224    fAttrPos = 0;
225}
226
227XERCES_CPP_NAMESPACE_END
228
229#endif
Note: See TracBrowser for help on using the repository browser.