Back to home page

EIC code displayed by LXR

 
 

    


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

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_XERCESATTGROUPINFO_HPP)
0023 #define XERCESC_INCLUDE_GUARD_XERCESATTGROUPINFO_HPP
0024 
0025 
0026 /**
0027   * The class act as a place holder to store attributeGroup information.
0028   *
0029   * The class is intended for internal use.
0030   */
0031 
0032 // ---------------------------------------------------------------------------
0033 //  Includes
0034 // ---------------------------------------------------------------------------
0035 #include <xercesc/util/RefVectorOf.hpp>
0036 #include <xercesc/validators/schema/SchemaAttDef.hpp>
0037 
0038 #include <xercesc/internal/XSerializable.hpp>
0039 
0040 XERCES_CPP_NAMESPACE_BEGIN
0041 
0042 class VALIDATORS_EXPORT XercesAttGroupInfo : public XSerializable, public XMemory
0043 {
0044 public:
0045     // -----------------------------------------------------------------------
0046     //  Public Constructors/Destructor
0047     // -----------------------------------------------------------------------
0048     XercesAttGroupInfo
0049     (
0050         unsigned int           attGroupNameId
0051         , unsigned int         attGroupNamespaceId
0052         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0053     );
0054     ~XercesAttGroupInfo();
0055 
0056     // -----------------------------------------------------------------------
0057     //  Getter methods
0058     // -----------------------------------------------------------------------
0059     bool                containsTypeWithId() const;
0060     XMLSize_t           attributeCount() const;
0061     XMLSize_t           anyAttributeCount() const;
0062     unsigned int        getNameId() const;
0063     unsigned int        getNamespaceId() const;
0064     SchemaAttDef*       attributeAt(const XMLSize_t index);
0065     const SchemaAttDef* attributeAt(const XMLSize_t index) const;
0066     SchemaAttDef*       anyAttributeAt(const XMLSize_t index);
0067     const SchemaAttDef* anyAttributeAt(const XMLSize_t index) const;
0068     SchemaAttDef*       getCompleteWildCard() const;
0069     const SchemaAttDef* getAttDef(const XMLCh* const baseName,
0070                                   const int uriId) const;
0071 
0072     // -----------------------------------------------------------------------
0073     //  Setter methods
0074     // -----------------------------------------------------------------------
0075     void setTypeWithId(const bool other);
0076     void addAttDef(SchemaAttDef* const toAdd, const bool toClone = false);
0077     void addAnyAttDef(SchemaAttDef* const toAdd, const bool toClone = false);
0078     void setCompleteWildCard(SchemaAttDef* const toSet);
0079 
0080     // -----------------------------------------------------------------------
0081     //  Query methods
0082     // -----------------------------------------------------------------------
0083     bool containsAttribute(const XMLCh* const name, const unsigned int uri);
0084 
0085     /***
0086      * Support for Serialization/De-serialization
0087      ***/
0088     DECL_XSERIALIZABLE(XercesAttGroupInfo)
0089     XercesAttGroupInfo(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0090 
0091 private:
0092     // -----------------------------------------------------------------------
0093     //  Unimplemented constructors and operators
0094     // -----------------------------------------------------------------------
0095     XercesAttGroupInfo(const XercesAttGroupInfo& elemInfo);
0096     XercesAttGroupInfo& operator= (const XercesAttGroupInfo& other);
0097 
0098     // -----------------------------------------------------------------------
0099     //  Private data members
0100     // -----------------------------------------------------------------------
0101     bool                       fTypeWithId;
0102     unsigned int               fNameId;
0103     unsigned int               fNamespaceId;
0104     RefVectorOf<SchemaAttDef>* fAttributes;
0105     RefVectorOf<SchemaAttDef>* fAnyAttributes;
0106     SchemaAttDef*              fCompleteWildCard;
0107     MemoryManager*             fMemoryManager;
0108 };
0109 
0110 // ---------------------------------------------------------------------------
0111 //  XercesAttGroupInfo: Getter methods
0112 // ---------------------------------------------------------------------------
0113 inline bool XercesAttGroupInfo::containsTypeWithId() const {
0114 
0115     return fTypeWithId;
0116 }
0117 
0118 inline XMLSize_t XercesAttGroupInfo::attributeCount() const {
0119 
0120     if (fAttributes) {
0121         return fAttributes->size();
0122     }
0123 
0124     return 0;
0125 }
0126 
0127 inline XMLSize_t XercesAttGroupInfo::anyAttributeCount() const {
0128 
0129     if (fAnyAttributes) {
0130         return fAnyAttributes->size();
0131     }
0132 
0133     return 0;
0134 }
0135 
0136 inline unsigned int XercesAttGroupInfo::getNameId() const
0137 {
0138     return fNameId;
0139 }
0140 
0141 inline unsigned int XercesAttGroupInfo::getNamespaceId() const
0142 {
0143     return fNamespaceId;
0144 }
0145 
0146 inline SchemaAttDef*
0147 XercesAttGroupInfo::attributeAt(const XMLSize_t index) {
0148 
0149     if (fAttributes) {
0150         return fAttributes->elementAt(index);
0151     }
0152 
0153     return 0;
0154 }
0155 
0156 inline const SchemaAttDef*
0157 XercesAttGroupInfo::attributeAt(const XMLSize_t index) const {
0158 
0159     if (fAttributes) {
0160         return fAttributes->elementAt(index);
0161     }
0162 
0163     return 0;
0164 }
0165 
0166 inline SchemaAttDef*
0167 XercesAttGroupInfo::anyAttributeAt(const XMLSize_t index) {
0168 
0169     if (fAnyAttributes) {
0170         return fAnyAttributes->elementAt(index);
0171     }
0172 
0173     return 0;
0174 }
0175 
0176 inline const SchemaAttDef*
0177 XercesAttGroupInfo::anyAttributeAt(const XMLSize_t index) const {
0178 
0179     if (fAnyAttributes) {
0180         return fAnyAttributes->elementAt(index);
0181     }
0182 
0183     return 0;
0184 }
0185 
0186 inline SchemaAttDef*
0187 XercesAttGroupInfo::getCompleteWildCard() const {
0188 
0189     return fCompleteWildCard;
0190 }
0191 
0192 // ---------------------------------------------------------------------------
0193 //  XercesAttGroupInfo: Setter methods
0194 // ---------------------------------------------------------------------------
0195 inline void XercesAttGroupInfo::setTypeWithId(const bool other) {
0196 
0197     fTypeWithId = other;
0198 }
0199 
0200 inline void XercesAttGroupInfo::addAttDef(SchemaAttDef* const toAdd,
0201                                              const bool toClone) {
0202 
0203     if (!fAttributes) {
0204         fAttributes = new (fMemoryManager) RefVectorOf<SchemaAttDef>(4, true, fMemoryManager);
0205     }
0206 
0207     if (toClone) {
0208         SchemaAttDef* clonedAttDef = new (fMemoryManager) SchemaAttDef(toAdd);
0209 
0210         if (!clonedAttDef->getBaseAttDecl())
0211             clonedAttDef->setBaseAttDecl(toAdd);
0212 
0213         fAttributes->addElement(clonedAttDef);
0214     }
0215     else {
0216         fAttributes->addElement(toAdd);
0217     }
0218 }
0219 
0220 inline void XercesAttGroupInfo::addAnyAttDef(SchemaAttDef* const toAdd,
0221                                              const bool toClone) {
0222 
0223     if (!fAnyAttributes) {
0224         fAnyAttributes = new (fMemoryManager) RefVectorOf<SchemaAttDef>(2, true, fMemoryManager);
0225     }
0226 
0227     if (toClone) {
0228         SchemaAttDef* clonedAttDef = new (fMemoryManager) SchemaAttDef(toAdd);
0229 
0230         if (!clonedAttDef->getBaseAttDecl())
0231             clonedAttDef->setBaseAttDecl(toAdd);
0232 
0233         fAnyAttributes->addElement(clonedAttDef);
0234     }
0235     else {
0236         fAnyAttributes->addElement(toAdd);
0237     }
0238 }
0239 
0240 inline void
0241 XercesAttGroupInfo::setCompleteWildCard(SchemaAttDef* const toSet) {
0242 
0243     if (fCompleteWildCard) {
0244         delete fCompleteWildCard;
0245     }
0246 
0247     fCompleteWildCard = toSet;
0248 }
0249 
0250 XERCES_CPP_NAMESPACE_END
0251 
0252 #endif
0253 
0254 /**
0255   * End of file XercesAttGroupInfo.hpp
0256   */
0257