File indexing completed on 2025-01-30 10:27:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #if defined(XERCES_TMPLSINC)
0022 #include "RefArrayVectorOf.hpp"
0023 #endif
0024
0025 XERCES_CPP_NAMESPACE_BEGIN
0026
0027
0028
0029
0030 template <class TElem>
0031 RefArrayVectorOf<TElem>::RefArrayVectorOf( const XMLSize_t maxElems
0032 , const bool adoptElems
0033 , MemoryManager* const manager)
0034 : BaseRefVectorOf<TElem>(maxElems, adoptElems, manager)
0035 {
0036 }
0037
0038
0039 template <class TElem> RefArrayVectorOf<TElem>::~RefArrayVectorOf()
0040 {
0041 if (this->fAdoptedElems)
0042 {
0043 for (XMLSize_t index = 0; index < this->fCurCount; index++)
0044 this->fMemoryManager->deallocate(this->fElemList[index]);
0045 }
0046 this->fMemoryManager->deallocate(this->fElemList);
0047 }
0048
0049 template <class TElem> void
0050 RefArrayVectorOf<TElem>::setElementAt(TElem* const toSet, const XMLSize_t setAt)
0051 {
0052 if (setAt >= this->fCurCount)
0053 ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, this->fMemoryManager);
0054
0055 if (this->fAdoptedElems)
0056 this->fMemoryManager->deallocate(this->fElemList[setAt]);
0057
0058 this->fElemList[setAt] = toSet;
0059 }
0060
0061 template <class TElem> void RefArrayVectorOf<TElem>::removeAllElements()
0062 {
0063 for (XMLSize_t index = 0; index < this->fCurCount; index++)
0064 {
0065 if (this->fAdoptedElems)
0066 this->fMemoryManager->deallocate(this->fElemList[index]);
0067
0068
0069 this->fElemList[index] = 0;
0070 }
0071 this->fCurCount = 0;
0072 }
0073
0074 template <class TElem> void RefArrayVectorOf<TElem>::
0075 removeElementAt(const XMLSize_t removeAt)
0076 {
0077 if (removeAt >= this->fCurCount)
0078 ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, this->fMemoryManager);
0079
0080 if (this->fAdoptedElems)
0081 this->fMemoryManager->deallocate(this->fElemList[removeAt]);
0082
0083
0084 if (removeAt == this->fCurCount-1)
0085 {
0086 this->fElemList[removeAt] = 0;
0087 this->fCurCount--;
0088 return;
0089 }
0090
0091
0092 for (XMLSize_t index = removeAt; index < this->fCurCount-1; index++)
0093 this->fElemList[index] = this->fElemList[index+1];
0094
0095
0096 this->fElemList[this->fCurCount-1] = 0;
0097
0098
0099 this->fCurCount--;
0100 }
0101
0102 template <class TElem> void RefArrayVectorOf<TElem>::removeLastElement()
0103 {
0104 if (!this->fCurCount)
0105 return;
0106 this->fCurCount--;
0107
0108 if (this->fAdoptedElems)
0109 this->fMemoryManager->deallocate(this->fElemList[this->fCurCount]);
0110 }
0111
0112 template <class TElem> void RefArrayVectorOf<TElem>::cleanup()
0113 {
0114 if (this->fAdoptedElems)
0115 {
0116 for (XMLSize_t index = 0; index < this->fCurCount; index++)
0117 this->fMemoryManager->deallocate(this->fElemList[index]);
0118 }
0119 this->fMemoryManager->deallocate(this->fElemList);
0120 }
0121
0122 XERCES_CPP_NAMESPACE_END