Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:15:14

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 
0023 // ---------------------------------------------------------------------------
0024 //  Includes
0025 // ---------------------------------------------------------------------------
0026 #if defined(XERCES_TMPLSINC)
0027 #include <xercesc/util/ValueStackOf.hpp>
0028 #endif
0029 
0030 XERCES_CPP_NAMESPACE_BEGIN
0031 
0032 
0033 // ---------------------------------------------------------------------------
0034 //  ValueStackOf: Constructors and Destructor
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 //  ValueStackOf: Element management methods
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 //  ValueStackOf: Getter methods
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 //  ValueStackEnumerator: Constructors and Destructor
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 //  ValueStackEnumerator: Enum interface
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