![]() |
|
|||
File indexing completed on 2025-03-13 09:30:36
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_VALUESTACKOF_HPP) 0023 #define XERCESC_INCLUDE_GUARD_VALUESTACKOF_HPP 0024 0025 #include <xercesc/util/EmptyStackException.hpp> 0026 #include <xercesc/util/ValueVectorOf.hpp> 0027 0028 XERCES_CPP_NAMESPACE_BEGIN 0029 0030 // 0031 // Forward declare the enumerator so he can be our friend. Can you say 0032 // friend? Sure... 0033 // 0034 template <class TElem> class ValueStackEnumerator; 0035 0036 0037 template <class TElem> class ValueStackOf : public XMemory 0038 { 0039 public : 0040 // ----------------------------------------------------------------------- 0041 // Constructors and Destructor 0042 // ----------------------------------------------------------------------- 0043 ValueStackOf 0044 ( 0045 const XMLSize_t fInitCapacity 0046 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0047 , const bool toCallDestructor = false 0048 ); 0049 ~ValueStackOf(); 0050 0051 0052 // ----------------------------------------------------------------------- 0053 // Element management methods 0054 // ----------------------------------------------------------------------- 0055 void push(const TElem& toPush); 0056 const TElem& peek() const; 0057 TElem pop(); 0058 void removeAllElements(); 0059 0060 0061 // ----------------------------------------------------------------------- 0062 // Getter methods 0063 // ----------------------------------------------------------------------- 0064 bool empty(); 0065 XMLSize_t curCapacity(); 0066 XMLSize_t size(); 0067 0068 0069 private : 0070 // ----------------------------------------------------------------------- 0071 // Unimplemented constructors and operators 0072 // ----------------------------------------------------------------------- 0073 ValueStackOf(const ValueStackOf<TElem>&); 0074 ValueStackOf<TElem>& operator=(const ValueStackOf<TElem>&); 0075 0076 // ----------------------------------------------------------------------- 0077 // Declare our friends 0078 // ----------------------------------------------------------------------- 0079 friend class ValueStackEnumerator<TElem>; 0080 0081 0082 // ----------------------------------------------------------------------- 0083 // Data Members 0084 // 0085 // fVector 0086 // The vector that is used as the backing data structure for the 0087 // stack. 0088 // ----------------------------------------------------------------------- 0089 ValueVectorOf<TElem> fVector; 0090 }; 0091 0092 0093 0094 // 0095 // An enumerator for a value stack. It derives from the basic enumerator 0096 // class, so that value stacks can be generically enumerated. 0097 // 0098 template <class TElem> class ValueStackEnumerator : public XMLEnumerator<TElem>, public XMemory 0099 { 0100 public : 0101 // ----------------------------------------------------------------------- 0102 // Constructors and Destructor 0103 // ----------------------------------------------------------------------- 0104 ValueStackEnumerator 0105 ( 0106 ValueStackOf<TElem>* const toEnum 0107 , const bool adopt = false 0108 ); 0109 virtual ~ValueStackEnumerator(); 0110 0111 0112 // ----------------------------------------------------------------------- 0113 // Enum interface 0114 // ----------------------------------------------------------------------- 0115 bool hasMoreElements() const; 0116 TElem& nextElement(); 0117 void Reset(); 0118 0119 0120 private : 0121 // ----------------------------------------------------------------------- 0122 // Unimplemented constructors and operators 0123 // ----------------------------------------------------------------------- 0124 ValueStackEnumerator(const ValueStackEnumerator<TElem>&); 0125 ValueStackEnumerator<TElem>& operator=(const ValueStackEnumerator<TElem>&); 0126 0127 // ----------------------------------------------------------------------- 0128 // Data Members 0129 // 0130 // fAdopted 0131 // Indicates whether we have adopted the passed stack. If so then 0132 // we delete the stack when we are destroyed. 0133 // 0134 // fCurIndex 0135 // This is the current index into the vector inside the stack being 0136 // enumerated. 0137 // 0138 // fToEnum 0139 // The stack that is being enumerated. This is just kept for 0140 // adoption purposes, since we really are enumerating the vector 0141 // inside of it. 0142 // ----------------------------------------------------------------------- 0143 bool fAdopted; 0144 XMLSize_t fCurIndex; 0145 ValueVectorOf<TElem>* fVector; 0146 ValueStackOf<TElem>* fToEnum; 0147 }; 0148 0149 XERCES_CPP_NAMESPACE_END 0150 0151 #if !defined(XERCES_TMPLSINC) 0152 #include <xercesc/util/ValueStackOf.c> 0153 #endif 0154 0155 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |