|
||||
File indexing completed on 2025-01-30 10:27:30
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_DTDATTDEFLIST_HPP) 0023 #define XERCESC_INCLUDE_GUARD_DTDATTDEFLIST_HPP 0024 0025 #include <xercesc/util/RefHashTableOf.hpp> 0026 #include <xercesc/validators/DTD/DTDElementDecl.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 // Since each validator can store attributes differently, this abstract 0038 // interface allows each validator to provide an implementation of this 0039 // data structure that works best for it. 0040 // 0041 // For us, we just wrap the RefHashTableOf collection that the DTDElementDecl 0042 // class uses to store the attributes that belong to it. 0043 // 0044 // This clss does not adopt the hash table, it just references it. The 0045 // hash table is owned by the element decl it is a member of. 0046 // 0047 class VALIDATORS_EXPORT DTDAttDefList : public XMLAttDefList 0048 { 0049 public : 0050 // ----------------------------------------------------------------------- 0051 // Constructors and Destructor 0052 // ----------------------------------------------------------------------- 0053 DTDAttDefList 0054 ( 0055 RefHashTableOf<DTDAttDef>* const listToUse, 0056 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0057 ); 0058 0059 ~DTDAttDefList(); 0060 0061 0062 // ----------------------------------------------------------------------- 0063 // Implementation of the virtual interface 0064 // ----------------------------------------------------------------------- 0065 0066 virtual bool isEmpty() const; 0067 virtual XMLAttDef* findAttDef 0068 ( 0069 const unsigned int uriID 0070 , const XMLCh* const attName 0071 ); 0072 virtual const XMLAttDef* findAttDef 0073 ( 0074 const unsigned int uriID 0075 , const XMLCh* const attName 0076 ) const; 0077 virtual XMLAttDef* findAttDef 0078 ( 0079 const XMLCh* const attURI 0080 , const XMLCh* const attName 0081 ); 0082 virtual const XMLAttDef* findAttDef 0083 ( 0084 const XMLCh* const attURI 0085 , const XMLCh* const attName 0086 ) const; 0087 0088 /** 0089 * return total number of attributes in this list 0090 */ 0091 virtual XMLSize_t getAttDefCount() const ; 0092 0093 /** 0094 * return attribute at the index-th position in the list. 0095 */ 0096 virtual XMLAttDef &getAttDef(XMLSize_t index) ; 0097 0098 /** 0099 * return attribute at the index-th position in the list. 0100 */ 0101 virtual const XMLAttDef &getAttDef(XMLSize_t index) const ; 0102 0103 /*** 0104 * Support for Serialization/De-serialization 0105 ***/ 0106 DECL_XSERIALIZABLE(DTDAttDefList) 0107 0108 DTDAttDefList(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0109 0110 private : 0111 0112 void addAttDef(DTDAttDef *toAdd); 0113 // ----------------------------------------------------------------------- 0114 // Unimplemented constructors and operators 0115 // ----------------------------------------------------------------------- 0116 DTDAttDefList(const DTDAttDefList &); 0117 DTDAttDefList& operator = (const DTDAttDefList&); 0118 0119 // ----------------------------------------------------------------------- 0120 // Private data members 0121 // 0122 // fEnum 0123 // This is an enerator for the list that we use to do the enumerator 0124 // type methods of this class. 0125 // 0126 // fList 0127 // The list of DTDAttDef objects that represent the attributes that 0128 // a particular element supports. 0129 // fArray 0130 // vector of pointers to the DTDAttDef objects contained in this list 0131 // fSize 0132 // size of fArray 0133 // fCount 0134 // number of DTDAttDef objects currently stored in this list 0135 // ----------------------------------------------------------------------- 0136 RefHashTableOfEnumerator<DTDAttDef>* fEnum; 0137 RefHashTableOf<DTDAttDef>* fList; 0138 DTDAttDef** fArray; 0139 XMLSize_t fSize; 0140 XMLSize_t fCount; 0141 0142 friend class DTDElementDecl; 0143 }; 0144 0145 inline void DTDAttDefList::addAttDef(DTDAttDef *toAdd) 0146 { 0147 if(fCount == fSize) 0148 { 0149 // need to grow fArray 0150 fSize <<= 1; 0151 DTDAttDef** newArray = (DTDAttDef **)((getMemoryManager())->allocate( sizeof(DTDAttDef*) * fSize )); 0152 memcpy(newArray, fArray, fCount * sizeof(DTDAttDef *)); 0153 (getMemoryManager())->deallocate(fArray); 0154 fArray = newArray; 0155 } 0156 fArray[fCount++] = toAdd; 0157 } 0158 0159 XERCES_CPP_NAMESPACE_END 0160 0161 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |