source: NonGTP/Xerces/xerces/include/xercesc/util/ValueStackOf.hpp @ 358

Revision 358, 6.5 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 1999-2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * $Log: ValueStackOf.hpp,v $
19 * Revision 1.8  2004/09/08 13:56:23  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.7  2004/01/29 11:48:46  cargilld
23 * Code cleanup changes to get rid of various compiler diagnostic messages.
24 *
25 * Revision 1.6  2003/05/29 13:26:44  knoaman
26 * Fix memory leak when using deprecated dom.
27 *
28 * Revision 1.5  2003/05/16 06:01:52  knoaman
29 * Partial implementation of the configurable memory manager.
30 *
31 * Revision 1.4  2003/05/15 19:07:46  knoaman
32 * Partial implementation of the configurable memory manager.
33 *
34 * Revision 1.3  2002/11/04 15:22:05  tng
35 * C++ Namespace Support.
36 *
37 * Revision 1.2  2002/08/21 17:45:00  tng
38 * [Bug 7087] compiler warnings when using gcc.
39 *
40 * Revision 1.1.1.1  2002/02/01 22:22:13  peiyongz
41 * sane_include
42 *
43 * Revision 1.4  2000/03/02 19:54:47  roddey
44 * This checkin includes many changes done while waiting for the
45 * 1.1.0 code to be finished. I can't list them all here, but a list is
46 * available elsewhere.
47 *
48 * Revision 1.3  2000/02/24 20:05:26  abagchi
49 * Swat for removing Log from API docs
50 *
51 * Revision 1.2  2000/02/06 07:48:05  rahulj
52 * Year 2K copyright swat.
53 *
54 * Revision 1.1.1.1  1999/11/09 01:05:30  twl
55 * Initial checkin
56 *
57 * Revision 1.2  1999/11/08 20:45:18  rahul
58 * Swat for adding in Product name and CVS comment log variable.
59 *
60 */
61
62#if !defined(VALUESTACKOF_HPP)
63#define VALUESTACKOF_HPP
64
65#include <xercesc/util/EmptyStackException.hpp>
66#include <xercesc/util/ValueVectorOf.hpp>
67
68XERCES_CPP_NAMESPACE_BEGIN
69
70//
71//  Forward declare the enumerator so he can be our friend. Can you say
72//  friend? Sure...
73//
74template <class TElem> class ValueStackEnumerator;
75
76
77template <class TElem> class ValueStackOf : public XMemory
78{
79public :
80    // -----------------------------------------------------------------------
81    //  Constructors and Destructor
82    // -----------------------------------------------------------------------
83    ValueStackOf
84    (
85          const unsigned int fInitCapacity
86          , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
87          , const bool toCallDestructor = false
88    );
89    ~ValueStackOf();
90
91
92    // -----------------------------------------------------------------------
93    //  Element management methods
94    // -----------------------------------------------------------------------
95    void push(const TElem& toPush);
96    const TElem& peek() const;
97    TElem pop();
98    void removeAllElements();
99
100
101    // -----------------------------------------------------------------------
102    //  Getter methods
103    // -----------------------------------------------------------------------
104    bool empty();
105    unsigned int curCapacity();
106    unsigned int size();
107
108
109private :
110    // -----------------------------------------------------------------------
111    //  Unimplemented constructors and operators
112    // -----------------------------------------------------------------------   
113    ValueStackOf(const ValueStackOf<TElem>&);
114    ValueStackOf<TElem>& operator=(const ValueStackOf<TElem>&);
115
116    // -----------------------------------------------------------------------
117    //  Declare our friends
118    // -----------------------------------------------------------------------
119    friend class ValueStackEnumerator<TElem>;
120
121
122    // -----------------------------------------------------------------------
123    //  Data Members
124    //
125    //  fVector
126    //      The vector that is used as the backing data structure for the
127    //      stack.
128    // -----------------------------------------------------------------------
129    ValueVectorOf<TElem>    fVector;
130};
131
132
133
134//
135//  An enumerator for a value stack. It derives from the basic enumerator
136//  class, so that value stacks can be generically enumerated.
137//
138template <class TElem> class ValueStackEnumerator : public XMLEnumerator<TElem>, public XMemory
139{
140public :
141    // -----------------------------------------------------------------------
142    //  Constructors and Destructor
143    // -----------------------------------------------------------------------
144    ValueStackEnumerator
145    (
146                ValueStackOf<TElem>* const  toEnum
147        , const bool                        adopt = false
148    );
149    virtual ~ValueStackEnumerator();
150
151
152    // -----------------------------------------------------------------------
153    //  Enum interface
154    // -----------------------------------------------------------------------
155    bool hasMoreElements() const;
156    TElem& nextElement();
157    void Reset();
158
159
160private :
161    // -----------------------------------------------------------------------
162    //  Unimplemented constructors and operators
163    // -----------------------------------------------------------------------   
164    ValueStackEnumerator(const ValueStackEnumerator<TElem>&);
165    ValueStackEnumerator<TElem>& operator=(const ValueStackEnumerator<TElem>&);
166
167    // -----------------------------------------------------------------------
168    //  Data Members
169    //
170    //  fAdopted
171    //      Indicates whether we have adopted the passed stack. If so then
172    //      we delete the stack when we are destroyed.
173    //
174    //  fCurIndex
175    //      This is the current index into the vector inside the stack being
176    //      enumerated.
177    //
178    //  fToEnum
179    //      The stack that is being enumerated. This is just kept for
180    //      adoption purposes, since we really are enumerating the vector
181    //      inside of it.
182    // -----------------------------------------------------------------------
183    bool                    fAdopted;
184    unsigned int            fCurIndex;
185    ValueVectorOf<TElem>*   fVector;
186    ValueStackOf<TElem>*    fToEnum;
187};
188
189XERCES_CPP_NAMESPACE_END
190
191#if !defined(XERCES_TMPLSINC)
192#include <xercesc/util/ValueStackOf.c>
193#endif
194
195#endif
Note: See TracBrowser for help on using the repository browser.