Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:15:19

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  *
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  *
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_SCHEMAATTDEFLIST_HPP)
0023 #define XERCESC_INCLUDE_GUARD_SCHEMAATTDEFLIST_HPP
0024 
0025 #include <xercesc/util/RefHash2KeysTableOf.hpp>
0026 #include <xercesc/validators/schema/SchemaElementDecl.hpp>
0027 
0028 XERCES_CPP_NAMESPACE_BEGIN
0029 
0030 //
0031 //  This is a derivative of the framework abstract class which defines the
0032 //  interface to a list of attribute defs that belong to a particular
0033 //  element. The scanner needs to be able to get a list of the attributes
0034 //  that an element supports, for use during the validation process and for
0035 //  fixed/default attribute processing.
0036 //
0037 //  For us, we just wrap the RefHash2KeysTableOf collection that the SchemaElementDecl
0038 //  class uses to store the attributes that belong to it.
0039 //
0040 //  This class does not adopt the hash table, it just references it. The
0041 //  hash table is owned by the element decl it is a member of.
0042 //
0043 class VALIDATORS_EXPORT SchemaAttDefList : public XMLAttDefList
0044 {
0045 public :
0046     // -----------------------------------------------------------------------
0047     //  Constructors and Destructor
0048     // -----------------------------------------------------------------------
0049     SchemaAttDefList
0050     (
0051          RefHash2KeysTableOf<SchemaAttDef>* const    listToUse,
0052          MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0053     );
0054 
0055     ~SchemaAttDefList();
0056 
0057 
0058     // -----------------------------------------------------------------------
0059     //  Implementation of the virtual interface
0060     // -----------------------------------------------------------------------
0061 
0062     virtual bool isEmpty() const;
0063     virtual XMLAttDef* findAttDef
0064     (
0065         const   unsigned int       uriID
0066         , const XMLCh* const        attName
0067     );
0068     virtual const XMLAttDef* findAttDef
0069     (
0070         const   unsigned int       uriID
0071         , const XMLCh* const        attName
0072     )   const;
0073     virtual XMLAttDef* findAttDef
0074     (
0075         const   XMLCh* const        attURI
0076         , const XMLCh* const        attName
0077     );
0078     virtual const XMLAttDef* findAttDef
0079     (
0080         const   XMLCh* const        attURI
0081         , const XMLCh* const        attName
0082     )   const;
0083 
0084     XMLAttDef* findAttDefLocalPart
0085     (
0086         const   unsigned int        uriID
0087         , const XMLCh* const        attLocalPart
0088     );
0089 
0090     const XMLAttDef* findAttDefLocalPart
0091     (
0092         const   unsigned int        uriID
0093         , const XMLCh* const        attLocalPart
0094     )   const;
0095 
0096     /**
0097      * return total number of attributes in this list
0098      */
0099     virtual XMLSize_t getAttDefCount() const ;
0100 
0101     /**
0102      * return attribute at the index-th position in the list.
0103      */
0104     virtual XMLAttDef &getAttDef(XMLSize_t index) ;
0105 
0106     /**
0107      * return attribute at the index-th position in the list.
0108      */
0109     virtual const XMLAttDef &getAttDef(XMLSize_t index) const ;
0110 
0111     /***
0112      * Support for Serialization/De-serialization
0113      ***/
0114     DECL_XSERIALIZABLE(SchemaAttDefList)
0115 
0116     SchemaAttDefList(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0117 
0118 private :
0119     // -----------------------------------------------------------------------
0120     //  Unimplemented constructors and operators
0121     // -----------------------------------------------------------------------
0122     SchemaAttDefList(const SchemaAttDefList&);
0123     SchemaAttDefList& operator=(const SchemaAttDefList&);
0124 
0125     void addAttDef(SchemaAttDef *toAdd);
0126 
0127     // -----------------------------------------------------------------------
0128     //  Private data members
0129     //
0130     //  fEnum
0131     //      This is an enumerator for the list that we use to do the enumerator
0132     //      type methods of this class.
0133     //
0134     //  fList
0135     //      The list of SchemaAttDef objects that represent the attributes that
0136     //      a particular element supports.
0137     //  fArray
0138     //      vector of pointers to the DTDAttDef objects contained in this list
0139     //  fSize
0140     //      size of fArray
0141     //  fCount
0142     //      number of DTDAttDef objects currently stored in this list
0143     // -----------------------------------------------------------------------
0144     RefHash2KeysTableOfEnumerator<SchemaAttDef>*    fEnum;
0145     RefHash2KeysTableOf<SchemaAttDef>*              fList;
0146     SchemaAttDef**                                  fArray;
0147     XMLSize_t                                       fSize;
0148     XMLSize_t                                       fCount;
0149 
0150     friend class ComplexTypeInfo;
0151 };
0152 
0153 inline void SchemaAttDefList::addAttDef(SchemaAttDef *toAdd)
0154 {
0155     if(fCount == fSize)
0156     {
0157         // need to grow fArray
0158         fSize <<= 1;
0159         SchemaAttDef** newArray = (SchemaAttDef **)((getMemoryManager())->allocate( sizeof(SchemaAttDef*) * fSize ));
0160         memcpy(newArray, fArray, fCount * sizeof(SchemaAttDef *));
0161         (getMemoryManager())->deallocate(fArray);
0162         fArray = newArray;
0163     }
0164     fArray[fCount++] = toAdd;
0165 }
0166 
0167 inline XMLAttDef* SchemaAttDefList::findAttDefLocalPart(const   unsigned int       uriID
0168                                                       , const XMLCh* const        attLocalPart)
0169 {
0170     return fList->get((void*)attLocalPart, uriID);
0171 }
0172 
0173 inline const XMLAttDef* SchemaAttDefList::findAttDefLocalPart(const   unsigned int       uriID
0174                                                             , const XMLCh* const        attLocalPart)   const
0175 {
0176     return fList->get((void*)attLocalPart, uriID);
0177 }
0178 
0179 XERCES_CPP_NAMESPACE_END
0180 
0181 #endif