|
||||
File indexing completed on 2025-01-30 10:27:25
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_REFARRAY_HPP) 0023 #define XERCESC_INCLUDE_GUARD_REFARRAY_HPP 0024 0025 #include <xercesc/util/PlatformUtils.hpp> 0026 #include <xercesc/util/ArrayIndexOutOfBoundsException.hpp> 0027 #include <xercesc/util/IllegalArgumentException.hpp> 0028 #include <xercesc/util/XMLEnumerator.hpp> 0029 #include <xercesc/framework/MemoryManager.hpp> 0030 0031 XERCES_CPP_NAMESPACE_BEGIN 0032 0033 template <class TElem> class RefArrayOf : public XMemory 0034 { 0035 public : 0036 // ----------------------------------------------------------------------- 0037 // Constructors and Destructor 0038 // ----------------------------------------------------------------------- 0039 RefArrayOf 0040 ( 0041 const XMLSize_t size 0042 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0043 RefArrayOf 0044 ( 0045 TElem* values[] 0046 , const XMLSize_t size 0047 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0048 RefArrayOf(const RefArrayOf<TElem>& source); 0049 ~RefArrayOf(); 0050 0051 0052 // ----------------------------------------------------------------------- 0053 // Public operators 0054 // ----------------------------------------------------------------------- 0055 TElem*& operator[](const XMLSize_t index); 0056 const TElem* operator[](const XMLSize_t index) const; 0057 RefArrayOf<TElem>& operator=(const RefArrayOf<TElem>& toAssign); 0058 bool operator==(const RefArrayOf<TElem>& toCompare) const; 0059 bool operator!=(const RefArrayOf<TElem>& toCompare) const; 0060 0061 0062 // ----------------------------------------------------------------------- 0063 // Copy operations 0064 // ----------------------------------------------------------------------- 0065 XMLSize_t copyFrom(const RefArrayOf<TElem>& srcArray); 0066 0067 0068 // ----------------------------------------------------------------------- 0069 // Getter methods 0070 // ----------------------------------------------------------------------- 0071 XMLSize_t length() const; 0072 TElem** rawData() const; 0073 0074 0075 // ----------------------------------------------------------------------- 0076 // Element management methods 0077 // ----------------------------------------------------------------------- 0078 void deleteAt(const XMLSize_t index); 0079 void deleteAllElements(); 0080 void resize(const XMLSize_t newSize); 0081 0082 0083 private : 0084 // ----------------------------------------------------------------------- 0085 // Data members 0086 // ----------------------------------------------------------------------- 0087 XMLSize_t fSize; 0088 TElem** fArray; 0089 MemoryManager* fMemoryManager; 0090 }; 0091 0092 0093 // 0094 // An enumerator for a reference array. It derives from the basic enumerator 0095 // class, so that value vectors can be generically enumerated. 0096 // 0097 template <class TElem> class RefArrayEnumerator : public XMLEnumerator<TElem>, public XMemory 0098 { 0099 public : 0100 // ----------------------------------------------------------------------- 0101 // Constructors and Destructor 0102 // ----------------------------------------------------------------------- 0103 RefArrayEnumerator 0104 ( 0105 RefArrayOf<TElem>* const toEnum 0106 , const bool adopt = false 0107 ); 0108 virtual ~RefArrayEnumerator(); 0109 0110 0111 // ----------------------------------------------------------------------- 0112 // Enum interface 0113 // ----------------------------------------------------------------------- 0114 bool hasMoreElements() const; 0115 TElem& nextElement(); 0116 void Reset(); 0117 0118 0119 private : 0120 // ----------------------------------------------------------------------- 0121 // Unimplemented constructors and operators 0122 // ----------------------------------------------------------------------- 0123 RefArrayEnumerator(const RefArrayEnumerator<TElem>&); 0124 RefArrayEnumerator<TElem>& operator=(const RefArrayEnumerator<TElem>&); 0125 0126 // ----------------------------------------------------------------------- 0127 // Data Members 0128 // 0129 // fAdopted 0130 // Indicates whether we have adopted the passed array. If so then 0131 // we delete it when we are destroyed. 0132 // 0133 // fCurIndex 0134 // This is the current index into the array. 0135 // 0136 // fToEnum 0137 // The reference array being enumerated. 0138 // ----------------------------------------------------------------------- 0139 bool fAdopted; 0140 XMLSize_t fCurIndex; 0141 RefArrayOf<TElem>* fToEnum; 0142 }; 0143 0144 XERCES_CPP_NAMESPACE_END 0145 0146 #if !defined(XERCES_TMPLSINC) 0147 #include <xercesc/util/RefArrayOf.c> 0148 #endif 0149 0150 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |