File indexing completed on 2025-01-18 10:15:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #if defined(XERCES_TMPLSINC)
0027 #include <xercesc/util/ValueStackOf.hpp>
0028 #endif
0029
0030 XERCES_CPP_NAMESPACE_BEGIN
0031
0032
0033
0034
0035
0036 template <class TElem>
0037 ValueStackOf<TElem>::ValueStackOf(const XMLSize_t fInitCapacity,
0038 MemoryManager* const manager,
0039 const bool toCallDestructor) :
0040
0041 fVector(fInitCapacity, manager, toCallDestructor)
0042 {
0043 }
0044
0045 template <class TElem> ValueStackOf<TElem>::~ValueStackOf()
0046 {
0047 }
0048
0049
0050
0051
0052
0053 template <class TElem> void ValueStackOf<TElem>::push(const TElem& toPush)
0054 {
0055 fVector.addElement(toPush);
0056 }
0057
0058 template <class TElem> const TElem& ValueStackOf<TElem>::peek() const
0059 {
0060 const XMLSize_t curSize = fVector.size();
0061 if (curSize == 0)
0062 ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::Stack_EmptyStack, fVector.getMemoryManager());
0063
0064 return fVector.elementAt(curSize-1);
0065 }
0066
0067 template <class TElem> TElem ValueStackOf<TElem>::pop()
0068 {
0069 const XMLSize_t curSize = fVector.size();
0070 if (curSize == 0)
0071 ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::Stack_EmptyStack, fVector.getMemoryManager());
0072
0073 TElem retVal = fVector.elementAt(curSize-1);
0074 fVector.removeElementAt(curSize-1);
0075 return retVal;
0076 }
0077
0078 template <class TElem> void ValueStackOf<TElem>::removeAllElements()
0079 {
0080 fVector.removeAllElements();
0081 }
0082
0083
0084
0085
0086
0087 template <class TElem> bool ValueStackOf<TElem>::empty()
0088 {
0089 return (fVector.size() == 0);
0090 }
0091
0092 template <class TElem> XMLSize_t ValueStackOf<TElem>::curCapacity()
0093 {
0094 return fVector.curCapacity();
0095 }
0096
0097 template <class TElem> XMLSize_t ValueStackOf<TElem>::size()
0098 {
0099 return fVector.size();
0100 }
0101
0102
0103
0104
0105
0106
0107
0108 template <class TElem> ValueStackEnumerator<TElem>::
0109 ValueStackEnumerator( ValueStackOf<TElem>* const toEnum
0110 , const bool adopt) :
0111
0112 fAdopted(adopt)
0113 , fCurIndex(0)
0114 , fToEnum(toEnum)
0115 , fVector(&toEnum->fVector)
0116 {
0117 }
0118
0119 template <class TElem> ValueStackEnumerator<TElem>::~ValueStackEnumerator()
0120 {
0121 if (fAdopted)
0122 delete fToEnum;
0123 }
0124
0125
0126
0127
0128
0129 template <class TElem> bool ValueStackEnumerator<TElem>::hasMoreElements() const
0130 {
0131 if (fCurIndex >= fVector->size())
0132 return false;
0133 return true;
0134 }
0135
0136 template <class TElem> TElem& ValueStackEnumerator<TElem>::nextElement()
0137 {
0138 return fVector->elementAt(fCurIndex++);
0139 }
0140
0141 template <class TElem> void ValueStackEnumerator<TElem>::Reset()
0142 {
0143 fCurIndex = 0;
0144 }
0145
0146 XERCES_CPP_NAMESPACE_END