|
||||
File indexing completed on 2025-01-18 10:15:11
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_ABSTRACTVECTOROF_HPP) 0023 #define XERCESC_INCLUDE_GUARD_ABSTRACTVECTOROF_HPP 0024 0025 #include <xercesc/util/ArrayIndexOutOfBoundsException.hpp> 0026 #include <xercesc/util/XMLEnumerator.hpp> 0027 #include <xercesc/util/PlatformUtils.hpp> 0028 #include <xercesc/framework/MemoryManager.hpp> 0029 0030 XERCES_CPP_NAMESPACE_BEGIN 0031 0032 /** 0033 * Abstract base class for the xerces internal representation of Vector. 0034 * 0035 * The destructor is abstract, forcing each of RefVectorOf and 0036 * RefArrayVectorOf to implement their own appropriate one. 0037 * 0038 */ 0039 template <class TElem> class BaseRefVectorOf : public XMemory 0040 { 0041 public : 0042 // ----------------------------------------------------------------------- 0043 // Constructors and Destructor 0044 // ----------------------------------------------------------------------- 0045 BaseRefVectorOf 0046 ( 0047 const XMLSize_t maxElems 0048 , const bool adoptElems = true 0049 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0050 ); 0051 virtual ~BaseRefVectorOf(); 0052 0053 0054 // ----------------------------------------------------------------------- 0055 // Element management 0056 // ----------------------------------------------------------------------- 0057 void addElement(TElem* const toAdd); 0058 virtual void setElementAt(TElem* const toSet, const XMLSize_t setAt); 0059 void insertElementAt(TElem* const toInsert, const XMLSize_t insertAt); 0060 TElem* orphanElementAt(const XMLSize_t orphanAt); 0061 virtual void removeAllElements(); 0062 virtual void removeElementAt(const XMLSize_t removeAt); 0063 virtual void removeLastElement(); 0064 bool containsElement(const TElem* const toCheck); 0065 virtual void cleanup(); 0066 void reinitialize(); 0067 0068 0069 // ----------------------------------------------------------------------- 0070 // Getter methods 0071 // ----------------------------------------------------------------------- 0072 XMLSize_t curCapacity() const; 0073 const TElem* elementAt(const XMLSize_t getAt) const; 0074 TElem* elementAt(const XMLSize_t getAt); 0075 XMLSize_t size() const; 0076 MemoryManager* getMemoryManager() const; 0077 0078 0079 // ----------------------------------------------------------------------- 0080 // Miscellaneous 0081 // ----------------------------------------------------------------------- 0082 void ensureExtraCapacity(const XMLSize_t length); 0083 0084 private: 0085 // ----------------------------------------------------------------------- 0086 // Unimplemented constructors and operators 0087 // ----------------------------------------------------------------------- 0088 BaseRefVectorOf(const BaseRefVectorOf<TElem>& copy); 0089 BaseRefVectorOf& operator=(const BaseRefVectorOf<TElem>& copy); 0090 0091 protected: 0092 // ----------------------------------------------------------------------- 0093 // Data members 0094 // ----------------------------------------------------------------------- 0095 bool fAdoptedElems; 0096 XMLSize_t fCurCount; 0097 XMLSize_t fMaxCount; 0098 TElem** fElemList; 0099 MemoryManager* fMemoryManager; 0100 }; 0101 0102 0103 // 0104 // An enumerator for a vector. It derives from the basic enumerator 0105 // class, so that value vectors can be generically enumerated. 0106 // 0107 template <class TElem> class BaseRefVectorEnumerator : public XMLEnumerator<TElem>, public XMemory 0108 { 0109 public : 0110 // ----------------------------------------------------------------------- 0111 // Constructors and Destructor 0112 // ----------------------------------------------------------------------- 0113 BaseRefVectorEnumerator 0114 ( 0115 BaseRefVectorOf<TElem>* const toEnum 0116 , const bool adopt = false 0117 ); 0118 virtual ~BaseRefVectorEnumerator(); 0119 0120 BaseRefVectorEnumerator(const BaseRefVectorEnumerator<TElem>& copy); 0121 // ----------------------------------------------------------------------- 0122 // Enum interface 0123 // ----------------------------------------------------------------------- 0124 bool hasMoreElements() const; 0125 TElem& nextElement(); 0126 void Reset(); 0127 0128 0129 private : 0130 // ----------------------------------------------------------------------- 0131 // Unimplemented constructors and operators 0132 // ----------------------------------------------------------------------- 0133 BaseRefVectorEnumerator& operator=(const BaseRefVectorEnumerator<TElem>& copy); 0134 // ----------------------------------------------------------------------- 0135 // Data Members 0136 // 0137 // fAdopted 0138 // Indicates whether we have adopted the passed vector. If so then 0139 // we delete the vector when we are destroyed. 0140 // 0141 // fCurIndex 0142 // This is the current index into the vector. 0143 // 0144 // fToEnum 0145 // The reference vector being enumerated. 0146 // ----------------------------------------------------------------------- 0147 bool fAdopted; 0148 XMLSize_t fCurIndex; 0149 BaseRefVectorOf<TElem>* fToEnum; 0150 }; 0151 0152 XERCES_CPP_NAMESPACE_END 0153 0154 #if !defined(XERCES_TMPLSINC) 0155 #include <xercesc/util/BaseRefVectorOf.c> 0156 #endif 0157 0158 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |