- Main Page
- Related Pages
- Classes
- Files

# PSVIAttributeList.hpp

Go to the documentation of this file.

    00001 /*
    00002  * Licensed to the Apache Software Foundation (ASF) under one or more
    00003  * contributor license agreements.  See the NOTICE file distributed with
    00004  * this work for additional information regarding copyright ownership.
    00005  * The ASF licenses this file to You under the Apache License, Version 2.0
    00006  * (the "License"); you may not use this file except in compliance with
    00007  * the License.  You may obtain a copy of the License at
    00008  *
    00009  *      http://www.apache.org/licenses/LICENSE-2.0
    00010  *
    00011  * Unless required by applicable law or agreed to in writing, software
    00012  * distributed under the License is distributed on an "AS IS" BASIS,
    00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00014  * See the License for the specific language governing permissions and
    00015  * limitations under the License.
    00016  */
    00017
    00018 /*
    00019  * $Id: PSVIAttributeList.hpp 932887 2010-04-11 13:04:59Z borisk $
    00020  */
    00021
    00022 #if !defined(XERCESC_INCLUDE_GUARD_PSVIATTRIBUTE_LIST_HPP)
    00023 #define XERCESC_INCLUDE_GUARD_PSVIATTRIBUTE_LIST_HPP
    00024
    00025 #include <xercesc/util/PlatformUtils.hpp>
    00026 #include <xercesc/framework/psvi/PSVIAttribute.hpp>
    00027 #include <xercesc/util/RefVectorOf.hpp>
    00028
    00029 XERCES_CPP_NAMESPACE_BEGIN
    00030
    00039 class XMLPARSER_EXPORT PSVIAttributeStorage : public XMemory
    00040 {
    00041 public:
    00042     PSVIAttributeStorage() :
    00043         fPSVIAttribute(0)
    00044       , fAttributeName(0)
    00045       , fAttributeNamespace(0)
    00046     {
    00047     }
    00048
    00049     ~PSVIAttributeStorage()
    00050     {
    00051         delete fPSVIAttribute;
    00052     }
    00053
    00054     PSVIAttribute* fPSVIAttribute;
    00055     const XMLCh*   fAttributeName;
    00056     const XMLCh*   fAttributeNamespace;
    00057 };
    00058
    00059 class XMLPARSER_EXPORT PSVIAttributeList : public XMemory
    00060 {
    00061 public:
    00062
    00063     //  Constructors and Destructor
    00064     // -----------------------------------------------------------------------
    00067
    00073     PSVIAttributeList( MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00074
    00076
    00079     ~PSVIAttributeList();
    00081
    00082     //---------------------
    00086
    00087     /*
    00088      * Get the number of attributes whose PSVI contributions
    00089      * are contained in this list.
    00090      */
    00091     XMLSize_t getLength() const;
    00092
    00093     /*
    00094      * Get the PSVI contribution of attribute at position i
    00095      * in this list.  Indices start from 0.
    00096      * @param index index from which the attribute PSVI contribution
    00097      * is to come.
    00098      * @return PSVIAttribute containing the attributes PSVI contributions;
    00099      * null is returned if the index is out of range.
    00100      */
    00101     PSVIAttribute *getAttributePSVIAtIndex(const XMLSize_t index);
    00102
    00103     /*
    00104      * Get local part of attribute name at position index in the list.
    00105      * Indices start from 0.
    00106      * @param index index from which the attribute name
    00107      * is to come.
    00108      * @return local part of the attribute's name; null is returned if the index
    00109      * is out of range.
    00110      */
    00111     const XMLCh *getAttributeNameAtIndex(const XMLSize_t index);
    00112
    00113     /*
    00114      * Get namespace of attribute at position index in the list.
    00115      * Indices start from 0.
    00116      * @param index index from which the attribute namespace
    00117      * is to come.
    00118      * @return namespace of the attribute;
    00119      * null is returned if the index is out of range.
    00120      */
    00121     const XMLCh *getAttributeNamespaceAtIndex(const XMLSize_t index);
    00122
    00123     /*
    00124      * Get the PSVI contribution of attribute with given
    00125      * local name and namespace.
    00126      * @param attrName  local part of the attribute's name
    00127      * @param attrNamespace  namespace of the attribute
    00128      * @return null if the attribute PSVI does not exist
    00129      */
    00130     PSVIAttribute *getAttributePSVIByName(const XMLCh *attrName
    00131                     , const XMLCh * attrNamespace);
    00132
    00134
    00135     //----------------------------------
    00139
    00148     PSVIAttribute *getPSVIAttributeToFill(
    00149             const XMLCh * attrName
    00150             , const XMLCh * attrNS);
    00151
    00155     void reset();
    00156
    00158
    00159 private:
    00160
    00161     // -----------------------------------------------------------------------
    00162     //  Unimplemented constructors and operators
    00163     // -----------------------------------------------------------------------
    00164     PSVIAttributeList(const PSVIAttributeList&);
    00165     PSVIAttributeList & operator=(const PSVIAttributeList &);
    00166
    00167
    00168     // -----------------------------------------------------------------------
    00169     //  data members
    00170     // -----------------------------------------------------------------------
    00171     // fMemoryManager
    00172     //  handler to provide dynamically-need memory
    00173     // fAttrList
    00174     //  list of PSVIAttributes contained by this object
    00175     // fAttrPos
    00176     //  current number of initialized PSVIAttributes in fAttrList
    00177     MemoryManager*                      fMemoryManager;
    00178     RefVectorOf<PSVIAttributeStorage>*  fAttrList;
    00179     XMLSize_t                           fAttrPos;
    00180 };
    00181
    00182 inline PSVIAttributeList::~PSVIAttributeList()
    00183 {
    00184     delete fAttrList;
    00185 }
    00186
    00187 inline PSVIAttribute *PSVIAttributeList::getPSVIAttributeToFill(
    00188             const XMLCh *attrName
    00189             , const XMLCh * attrNS)
    00190 {
    00191     PSVIAttributeStorage* storage = 0;
    00192     if(fAttrPos == fAttrList->size())
    00193     {
    00194         storage = new (fMemoryManager) PSVIAttributeStorage();
    00195         storage->fPSVIAttribute = new (fMemoryManager) PSVIAttribute(fMemoryManager);
    00196         fAttrList->addElement(storage);
    00197     }
    00198     else
    00199     {
    00200         storage = fAttrList->elementAt(fAttrPos);
    00201     }
    00202     storage->fAttributeName = attrName;
    00203     storage->fAttributeNamespace = attrNS;
    00204     fAttrPos++;
    00205     return storage->fPSVIAttribute;
    00206 }
    00207
    00208 inline void PSVIAttributeList::reset()
    00209 {
    00210     fAttrPos = 0;
    00211 }
    00212
    00213 XERCES_CPP_NAMESPACE_END
    00214
    00215 #endif