[358] | 1 | /*
|
---|
| 2 | * Copyright 1999-2000,2004 The Apache Software Foundation.
|
---|
| 3 | *
|
---|
| 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 5 | * you may not use this file except in compliance with the License.
|
---|
| 6 | * You may obtain a copy of the License at
|
---|
| 7 | *
|
---|
| 8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 9 | *
|
---|
| 10 | * Unless required by applicable law or agreed to in writing, software
|
---|
| 11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 13 | * See the License for the specific language governing permissions and
|
---|
| 14 | * limitations under the License.
|
---|
| 15 | */
|
---|
| 16 |
|
---|
| 17 | /*
|
---|
| 18 | * $Log: DTDAttDefList.hpp,v $
|
---|
| 19 | * Revision 1.8 2004/09/08 13:56:50 peiyongz
|
---|
| 20 | * Apache License Version 2.0
|
---|
| 21 | *
|
---|
| 22 | * Revision 1.7 2004/01/29 11:52:30 cargilld
|
---|
| 23 | * Code cleanup changes to get rid of various compiler diagnostic messages.
|
---|
| 24 | *
|
---|
| 25 | * Revision 1.6 2003/11/10 21:54:51 neilg
|
---|
| 26 | * implementation for new stateless means of traversing attribute definition lists
|
---|
| 27 | *
|
---|
| 28 | * Revision 1.5 2003/10/20 11:46:28 gareth
|
---|
| 29 | * Pass in memory manager to constructors and use for creation of enumerators.
|
---|
| 30 | *
|
---|
| 31 | * Revision 1.4 2003/10/10 16:24:51 peiyongz
|
---|
| 32 | * Implementation of Serialization/Deserialization
|
---|
| 33 | *
|
---|
| 34 | * Revision 1.3 2002/12/06 13:27:22 tng
|
---|
| 35 | * [Bug 9083] Make some classes be exportable.
|
---|
| 36 | *
|
---|
| 37 | * Revision 1.2 2002/11/04 14:50:40 tng
|
---|
| 38 | * C++ Namespace Support.
|
---|
| 39 | *
|
---|
| 40 | * Revision 1.1.1.1 2002/02/01 22:22:43 peiyongz
|
---|
| 41 | * sane_include
|
---|
| 42 | *
|
---|
| 43 | * Revision 1.3 2000/02/24 20:16:48 abagchi
|
---|
| 44 | * Swat for removing Log from API docs
|
---|
| 45 | *
|
---|
| 46 | * Revision 1.2 2000/02/09 21:42:37 abagchi
|
---|
| 47 | * Copyright swat
|
---|
| 48 | *
|
---|
| 49 | * Revision 1.1.1.1 1999/11/09 01:03:28 twl
|
---|
| 50 | * Initial checkin
|
---|
| 51 | *
|
---|
| 52 | * Revision 1.2 1999/11/08 20:45:39 rahul
|
---|
| 53 | * Swat for adding in Product name and CVS comment log variable.
|
---|
| 54 | *
|
---|
| 55 | */
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 | #if !defined(DTDATTDEFLIST_HPP)
|
---|
| 59 | #define DTDATTDEFLIST_HPP
|
---|
| 60 |
|
---|
| 61 | #include <xercesc/util/RefHashTableOf.hpp>
|
---|
| 62 | #include <xercesc/validators/DTD/DTDElementDecl.hpp>
|
---|
| 63 |
|
---|
| 64 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
| 65 |
|
---|
| 66 | //
|
---|
| 67 | // This is a derivative of the framework abstract class which defines the
|
---|
| 68 | // interface to a list of attribute defs that belong to a particular
|
---|
| 69 | // element. The scanner needs to be able to get a list of the attributes
|
---|
| 70 | // that an element supports, for use during the validation process and for
|
---|
| 71 | // fixed/default attribute processing.
|
---|
| 72 | //
|
---|
| 73 | // Since each validator can store attributes differently, this abstract
|
---|
| 74 | // interface allows each validator to provide an implementation of this
|
---|
| 75 | // data strucure that works best for it.
|
---|
| 76 | //
|
---|
| 77 | // For us, we just wrap the RefHashTableOf collection that the DTDElementDecl
|
---|
| 78 | // class uses to store the attributes that belong to it.
|
---|
| 79 | //
|
---|
| 80 | // This clss does not adopt the hash table, it just references it. The
|
---|
| 81 | // hash table is owned by the element decl it is a member of.
|
---|
| 82 | //
|
---|
| 83 | class VALIDATORS_EXPORT DTDAttDefList : public XMLAttDefList
|
---|
| 84 | {
|
---|
| 85 | public :
|
---|
| 86 | // -----------------------------------------------------------------------
|
---|
| 87 | // Constructors and Destructor
|
---|
| 88 | // -----------------------------------------------------------------------
|
---|
| 89 | DTDAttDefList
|
---|
| 90 | (
|
---|
| 91 | RefHashTableOf<DTDAttDef>* const listToUse,
|
---|
| 92 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 93 | );
|
---|
| 94 |
|
---|
| 95 | ~DTDAttDefList();
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 | // -----------------------------------------------------------------------
|
---|
| 99 | // Implementation of the virtual interface
|
---|
| 100 | // -----------------------------------------------------------------------
|
---|
| 101 |
|
---|
| 102 | /**
|
---|
| 103 | * @deprecated This method is not thread-safe.
|
---|
| 104 | */
|
---|
| 105 | virtual bool hasMoreElements() const;
|
---|
| 106 | virtual bool isEmpty() const;
|
---|
| 107 | virtual XMLAttDef* findAttDef
|
---|
| 108 | (
|
---|
| 109 | const unsigned long uriID
|
---|
| 110 | , const XMLCh* const attName
|
---|
| 111 | );
|
---|
| 112 | virtual const XMLAttDef* findAttDef
|
---|
| 113 | (
|
---|
| 114 | const unsigned long uriID
|
---|
| 115 | , const XMLCh* const attName
|
---|
| 116 | ) const;
|
---|
| 117 | virtual XMLAttDef* findAttDef
|
---|
| 118 | (
|
---|
| 119 | const XMLCh* const attURI
|
---|
| 120 | , const XMLCh* const attName
|
---|
| 121 | );
|
---|
| 122 | virtual const XMLAttDef* findAttDef
|
---|
| 123 | (
|
---|
| 124 | const XMLCh* const attURI
|
---|
| 125 | , const XMLCh* const attName
|
---|
| 126 | ) const;
|
---|
| 127 |
|
---|
| 128 | /**
|
---|
| 129 | * @deprecated This method is not thread-safe.
|
---|
| 130 | */
|
---|
| 131 | virtual XMLAttDef& nextElement();
|
---|
| 132 |
|
---|
| 133 | /**
|
---|
| 134 | * @deprecated This method is not thread-safe.
|
---|
| 135 | */
|
---|
| 136 | virtual void Reset();
|
---|
| 137 |
|
---|
| 138 | /**
|
---|
| 139 | * return total number of attributes in this list
|
---|
| 140 | */
|
---|
| 141 | virtual unsigned int getAttDefCount() const ;
|
---|
| 142 |
|
---|
| 143 | /**
|
---|
| 144 | * return attribute at the index-th position in the list.
|
---|
| 145 | */
|
---|
| 146 | virtual XMLAttDef &getAttDef(unsigned int index) ;
|
---|
| 147 |
|
---|
| 148 | /**
|
---|
| 149 | * return attribute at the index-th position in the list.
|
---|
| 150 | */
|
---|
| 151 | virtual const XMLAttDef &getAttDef(unsigned int index) const ;
|
---|
| 152 |
|
---|
| 153 | /***
|
---|
| 154 | * Support for Serialization/De-serialization
|
---|
| 155 | ***/
|
---|
| 156 | DECL_XSERIALIZABLE(DTDAttDefList)
|
---|
| 157 |
|
---|
| 158 | DTDAttDefList(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 159 |
|
---|
| 160 | private :
|
---|
| 161 |
|
---|
| 162 | void addAttDef(DTDAttDef *toAdd);
|
---|
| 163 | // -----------------------------------------------------------------------
|
---|
| 164 | // Unimplemented constructors and operators
|
---|
| 165 | // -----------------------------------------------------------------------
|
---|
| 166 | DTDAttDefList(const DTDAttDefList &);
|
---|
| 167 | DTDAttDefList& operator = (const DTDAttDefList&);
|
---|
| 168 |
|
---|
| 169 | // -----------------------------------------------------------------------
|
---|
| 170 | // Private data members
|
---|
| 171 | //
|
---|
| 172 | // fEnum
|
---|
| 173 | // This is an enerator for the list that we use to do the enumerator
|
---|
| 174 | // type methods of this class.
|
---|
| 175 | //
|
---|
| 176 | // fList
|
---|
| 177 | // The list of DTDAttDef objects that represent the attributes that
|
---|
| 178 | // a particular element supports.
|
---|
| 179 | // fArray
|
---|
| 180 | // vector of pointers to the DTDAttDef objects contained in this list
|
---|
| 181 | // fSize
|
---|
| 182 | // size of fArray
|
---|
| 183 | // fCount
|
---|
| 184 | // number of DTDAttDef objects currently stored in this list
|
---|
| 185 | // -----------------------------------------------------------------------
|
---|
| 186 | RefHashTableOfEnumerator<DTDAttDef>* fEnum;
|
---|
| 187 | RefHashTableOf<DTDAttDef>* fList;
|
---|
| 188 | DTDAttDef** fArray;
|
---|
| 189 | unsigned int fSize;
|
---|
| 190 | unsigned int fCount;
|
---|
| 191 |
|
---|
| 192 | friend class DTDElementDecl;
|
---|
| 193 | };
|
---|
| 194 |
|
---|
| 195 | inline void DTDAttDefList::addAttDef(DTDAttDef *toAdd)
|
---|
| 196 | {
|
---|
| 197 | if(fCount == fSize)
|
---|
| 198 | {
|
---|
| 199 | // need to grow fArray
|
---|
| 200 | fSize <<= 1;
|
---|
| 201 | DTDAttDef** newArray = (DTDAttDef **)((getMemoryManager())->allocate( sizeof(DTDAttDef*) * fSize ));
|
---|
| 202 | memcpy(newArray, fArray, fCount * sizeof(DTDAttDef *));
|
---|
| 203 | (getMemoryManager())->deallocate(fArray);
|
---|
| 204 | fArray = newArray;
|
---|
| 205 | }
|
---|
| 206 | fArray[fCount++] = toAdd;
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 | XERCES_CPP_NAMESPACE_END
|
---|
| 210 |
|
---|
| 211 | #endif
|
---|