http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Release Info

Installation
Download
Build

FAQs
Samples
API Docs

DOM C++ Binding
Programming
Migration Guide

Feedback
Bug-Reporting
PDF Document

CVS Repository
Mail Archive

API Docs for SAX and DOM
 

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PSVIAttributeList.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 2003,2004 The Apache Software Foundation.
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 /*
00018  * $Log: PSVIAttributeList.hpp,v $
00019  * Revision 1.8  2004/09/08 13:56:07  peiyongz
00020  * Apache License Version 2.0
00021  *
00022  * Revision 1.7  2004/02/15 19:37:16  amassari
00023  * Removed cause for warnings in VC 7.1
00024  *
00025  * Revision 1.6  2003/12/20 06:19:38  neilg
00026  * store name/namespace of corresponding attribute in PSVIAttributeList; not all PSVIAttributes have XSAttributeDeclarations
00027  *
00028  * Revision 1.5  2003/12/15 17:23:48  cargilld
00029  * psvi updates; cleanup revisits and bug fixes
00030  *
00031  * Revision 1.4  2003/12/02 16:21:41  neilg
00032  * fix for ArrayIndexOutOfBoundsException in PSVIAttributeList; thanks to Pete Lloyd
00033  *
00034  * Revision 1.3  2003/11/26 16:20:37  neilg
00035  * more complete implementation of PSVIAttributeList; remove some problematic const-ness
00036  *
00037  * Revision 1.2  2003/11/06 15:30:04  neilg
00038  * 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.
00039  *
00040  * Revision 1.1  2003/09/16 14:33:36  neilg
00041  * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
00042  *
00043  */
00044 
00045 #if !defined(PSVIATTRIBUTEDERIVATION_LIST_HPP)
00046 #define PSVIATTRIBUTEDERIVATION_LIST_HPP
00047 
00048 #include <xercesc/util/PlatformUtils.hpp>
00049 #include <xercesc/framework/psvi/PSVIAttribute.hpp>
00050 #include <xercesc/util/ValueVectorOf.hpp>
00051 
00052 XERCES_CPP_NAMESPACE_BEGIN
00053 
00063 class  PSVIAttributeList : public XMemory
00064 {
00065 public:
00066 
00067     //  Constructors and Destructor
00068     // -----------------------------------------------------------------------
00071 
00077     PSVIAttributeList( MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00078 
00080 
00083     ~PSVIAttributeList();
00085 
00086     //---------------------
00090 
00091     /*
00092      * Get the number of attributes whose PSVI contributions
00093      * are contained in this list.
00094      */
00095     unsigned int getLength() const;
00096 
00097     /*
00098      * Get the PSVI contribution of attribute at position i
00099      * in this list.  Indeces start from 0.
00100      * @param index index from which the attribute PSVI contribution
00101      * is to come.  
00102      * @return PSVIAttribute containing the attributes PSVI contributions;
00103      * null is returned if the index is out of range.
00104      */
00105     PSVIAttribute *getAttributePSVIAtIndex(const unsigned int index);
00106 
00107     /*
00108      * Get local part of attribute name at position index in the list.
00109      * Indeces start from 0.
00110      * @param index index from which the attribute name 
00111      * is to come.  
00112      * @return local part of the attribute's name; null is returned if the index
00113      * is out of range.
00114      */
00115     const XMLCh *getAttributeNameAtIndex(const unsigned int index);
00116 
00117     /*
00118      * Get namespace of attribute at position index in the list.
00119      * Indeces start from 0.
00120      * @param index index from which the attribute namespace 
00121      * is to come.  
00122      * @return namespace of the attribute; 
00123      * null is returned if the index is out of range.
00124      */
00125     const XMLCh *getAttributeNamespaceAtIndex(const unsigned int index);
00126 
00127     /*
00128      * Get the PSVI contribution of attribute with given 
00129      * local name and namespace.
00130      * @param attrName  local part of the attribute's name
00131      * @param attrNamespace  namespace of the attribute
00132      * @return null if the attribute PSVI does not exist
00133      */
00134     PSVIAttribute *getAttributePSVIByName(const XMLCh *attrName
00135                     , const XMLCh * attrNamespace);
00136 
00138 
00139     //----------------------------------
00143 
00152     PSVIAttribute *getPSVIAttributeToFill(
00153             const XMLCh * attrName
00154             , const XMLCh * attrNS);
00155 
00159     void reset();
00160 
00162 
00163 private:
00164 
00165     // -----------------------------------------------------------------------
00166     //  Unimplemented constructors and operators
00167     // -----------------------------------------------------------------------
00168     PSVIAttributeList(const PSVIAttributeList&);
00169     PSVIAttributeList & operator=(const PSVIAttributeList &);
00170 
00171 
00172     // -----------------------------------------------------------------------
00173     //  data members
00174     // -----------------------------------------------------------------------
00175     // fMemoryManager
00176     //  handler to provide dynamically-need memory
00177     // fAttrList
00178     //  list of PSVIAttributes contained by this object
00179     // fAttrNameList
00180     //  list of the names of the initialized PSVIAttribute objects contained
00181     //  in this listing
00182     // fAttrNSList
00183     //  list of the namespaces of the initialized PSVIAttribute objects contained
00184     //  in this listing
00185     // fAttrPos
00186     //  current number of initialized PSVIAttributes in fAttrList
00187     MemoryManager*                  fMemoryManager;    
00188     RefVectorOf<PSVIAttribute>*     fAttrList;
00189     RefArrayVectorOf<XMLCh>*        fAttrNameList;
00190     RefArrayVectorOf<XMLCh>*        fAttrNSList;
00191     unsigned int                    fAttrPos;
00192 };
00193 inline PSVIAttributeList::~PSVIAttributeList() 
00194 {
00195     delete fAttrList;
00196     delete fAttrNameList;
00197     delete fAttrNSList;
00198 }
00199 
00200 inline PSVIAttribute *PSVIAttributeList::getPSVIAttributeToFill(
00201             const XMLCh *attrName
00202             , const XMLCh * attrNS)
00203 {
00204     PSVIAttribute *retAttr = 0;
00205     if(fAttrPos == fAttrList->size())
00206     {
00207         retAttr = new (fMemoryManager)PSVIAttribute(fMemoryManager);
00208         fAttrList->addElement(retAttr);
00209         fAttrNameList->addElement((XMLCh *)attrName);
00210         fAttrNSList->addElement((XMLCh *)attrNS);
00211     }
00212     else
00213     {
00214         retAttr = fAttrList->elementAt(fAttrPos);
00215         fAttrNameList->setElementAt((XMLCh *)attrName, fAttrPos);
00216         fAttrNSList->setElementAt((XMLCh *)attrNS, fAttrPos);
00217     }
00218     fAttrPos++;
00219     return retAttr;
00220 }
00221 
00222 inline void PSVIAttributeList::reset()
00223 {
00224     fAttrPos = 0;
00225 }
00226 
00227 XERCES_CPP_NAMESPACE_END
00228 
00229 #endif


Copyright © 1994-2004 The Apache Software Foundation. All Rights Reserved.