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