|
||||
File indexing completed on 2025-01-18 10:14:51
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_PSVIATTRIBUTE_LIST_HPP) 0023 #define XERCESC_INCLUDE_GUARD_PSVIATTRIBUTE_LIST_HPP 0024 0025 #include <xercesc/util/PlatformUtils.hpp> 0026 #include <xercesc/framework/psvi/PSVIAttribute.hpp> 0027 #include <xercesc/util/RefVectorOf.hpp> 0028 0029 XERCES_CPP_NAMESPACE_BEGIN 0030 0031 /** 0032 * A container for the PSVI contributions to attributes that occur 0033 * on a particular element. 0034 * This is always owned by the parser/validator from 0035 * which it is obtained. The parser/validator will specify 0036 * under what conditions it may be relied upon to have meaningful contents. 0037 */ 0038 0039 class XMLPARSER_EXPORT PSVIAttributeStorage : public XMemory 0040 { 0041 public: 0042 PSVIAttributeStorage() : 0043 fPSVIAttribute(0) 0044 , fAttributeName(0) 0045 , fAttributeNamespace(0) 0046 { 0047 } 0048 0049 ~PSVIAttributeStorage() 0050 { 0051 delete fPSVIAttribute; 0052 } 0053 0054 PSVIAttribute* fPSVIAttribute; 0055 const XMLCh* fAttributeName; 0056 const XMLCh* fAttributeNamespace; 0057 }; 0058 0059 class XMLPARSER_EXPORT PSVIAttributeList : public XMemory 0060 { 0061 public: 0062 0063 // Constructors and Destructor 0064 // ----------------------------------------------------------------------- 0065 /** @name Constructors */ 0066 //@{ 0067 0068 /** 0069 * The default constructor 0070 * 0071 * @param manager The configurable memory manager 0072 */ 0073 PSVIAttributeList( MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0074 0075 //@}; 0076 0077 /** @name Destructor */ 0078 //@{ 0079 ~PSVIAttributeList(); 0080 //@} 0081 0082 //--------------------- 0083 /** @name PSVIAttributeList methods */ 0084 0085 //@{ 0086 0087 /* 0088 * Get the number of attributes whose PSVI contributions 0089 * are contained in this list. 0090 */ 0091 XMLSize_t getLength() const; 0092 0093 /* 0094 * Get the PSVI contribution of attribute at position i 0095 * in this list. Indices start from 0. 0096 * @param index index from which the attribute PSVI contribution 0097 * is to come. 0098 * @return PSVIAttribute containing the attributes PSVI contributions; 0099 * null is returned if the index is out of range. 0100 */ 0101 PSVIAttribute *getAttributePSVIAtIndex(const XMLSize_t index); 0102 0103 /* 0104 * Get local part of attribute name at position index in the list. 0105 * Indices start from 0. 0106 * @param index index from which the attribute name 0107 * is to come. 0108 * @return local part of the attribute's name; null is returned if the index 0109 * is out of range. 0110 */ 0111 const XMLCh *getAttributeNameAtIndex(const XMLSize_t index); 0112 0113 /* 0114 * Get namespace of attribute at position index in the list. 0115 * Indices start from 0. 0116 * @param index index from which the attribute namespace 0117 * is to come. 0118 * @return namespace of the attribute; 0119 * null is returned if the index is out of range. 0120 */ 0121 const XMLCh *getAttributeNamespaceAtIndex(const XMLSize_t index); 0122 0123 /* 0124 * Get the PSVI contribution of attribute with given 0125 * local name and namespace. 0126 * @param attrName local part of the attribute's name 0127 * @param attrNamespace namespace of the attribute 0128 * @return null if the attribute PSVI does not exist 0129 */ 0130 PSVIAttribute *getAttributePSVIByName(const XMLCh *attrName 0131 , const XMLCh * attrNamespace); 0132 0133 //@} 0134 0135 //---------------------------------- 0136 /** methods needed by implementation */ 0137 0138 //@{ 0139 0140 /** 0141 * returns a PSVI attribute of undetermined state and given name/namespace and 0142 * makes that object part of the internal list. Intended to be called 0143 * during validation of an element. 0144 * @param attrName name of this attribute 0145 * @param attrNS URI of the attribute 0146 * @return new, uninitialized, PSVIAttribute object 0147 */ 0148 PSVIAttribute *getPSVIAttributeToFill( 0149 const XMLCh * attrName 0150 , const XMLCh * attrNS); 0151 0152 /** 0153 * reset the list 0154 */ 0155 void reset(); 0156 0157 //@} 0158 0159 private: 0160 0161 // ----------------------------------------------------------------------- 0162 // Unimplemented constructors and operators 0163 // ----------------------------------------------------------------------- 0164 PSVIAttributeList(const PSVIAttributeList&); 0165 PSVIAttributeList & operator=(const PSVIAttributeList &); 0166 0167 0168 // ----------------------------------------------------------------------- 0169 // data members 0170 // ----------------------------------------------------------------------- 0171 // fMemoryManager 0172 // handler to provide dynamically-need memory 0173 // fAttrList 0174 // list of PSVIAttributes contained by this object 0175 // fAttrPos 0176 // current number of initialized PSVIAttributes in fAttrList 0177 MemoryManager* fMemoryManager; 0178 RefVectorOf<PSVIAttributeStorage>* fAttrList; 0179 XMLSize_t fAttrPos; 0180 }; 0181 0182 inline PSVIAttributeList::~PSVIAttributeList() 0183 { 0184 delete fAttrList; 0185 } 0186 0187 inline PSVIAttribute *PSVIAttributeList::getPSVIAttributeToFill( 0188 const XMLCh *attrName 0189 , const XMLCh * attrNS) 0190 { 0191 PSVIAttributeStorage* storage = 0; 0192 if(fAttrPos == fAttrList->size()) 0193 { 0194 storage = new (fMemoryManager) PSVIAttributeStorage(); 0195 storage->fPSVIAttribute = new (fMemoryManager) PSVIAttribute(fMemoryManager); 0196 fAttrList->addElement(storage); 0197 } 0198 else 0199 { 0200 storage = fAttrList->elementAt(fAttrPos); 0201 } 0202 storage->fAttributeName = attrName; 0203 storage->fAttributeNamespace = attrNS; 0204 fAttrPos++; 0205 return storage->fPSVIAttribute; 0206 } 0207 0208 inline void PSVIAttributeList::reset() 0209 { 0210 fAttrPos = 0; 0211 } 0212 0213 XERCES_CPP_NAMESPACE_END 0214 0215 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |