source: NonGTP/Xerces/xercesc/util/ValueStackOf.hpp @ 188

Revision 188, 8.4 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

Line 
1/*
2 * The Apache Software License, Version 1.1
3 *
4 * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
5 * reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in
16 *    the documentation and/or other materials provided with the
17 *    distribution.
18 *
19 * 3. The end-user documentation included with the redistribution,
20 *    if any, must include the following acknowledgment:
21 *       "This product includes software developed by the
22 *        Apache Software Foundation (http://www.apache.org/)."
23 *    Alternately, this acknowledgment may appear in the software itself,
24 *    if and wherever such third-party acknowledgments normally appear.
25 *
26 * 4. The names "Xerces" and "Apache Software Foundation" must
27 *    not be used to endorse or promote products derived from this
28 *    software without prior written permission. For written
29 *    permission, please contact apache\@apache.org.
30 *
31 * 5. Products derived from this software may not be called "Apache",
32 *    nor may "Apache" appear in their name, without prior written
33 *    permission of the Apache Software Foundation.
34 *
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 * SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation, and was
51 * originally based on software copyright (c) 1999, International
52 * Business Machines, Inc., http://www.ibm.com .  For more information
53 * on the Apache Software Foundation, please see
54 * <http://www.apache.org/>.
55 */
56
57/*
58 * $Log: ValueStackOf.hpp,v $
59 * Revision 1.7  2004/01/29 11:48:46  cargilld
60 * Code cleanup changes to get rid of various compiler diagnostic messages.
61 *
62 * Revision 1.6  2003/05/29 13:26:44  knoaman
63 * Fix memory leak when using deprecated dom.
64 *
65 * Revision 1.5  2003/05/16 06:01:52  knoaman
66 * Partial implementation of the configurable memory manager.
67 *
68 * Revision 1.4  2003/05/15 19:07:46  knoaman
69 * Partial implementation of the configurable memory manager.
70 *
71 * Revision 1.3  2002/11/04 15:22:05  tng
72 * C++ Namespace Support.
73 *
74 * Revision 1.2  2002/08/21 17:45:00  tng
75 * [Bug 7087] compiler warnings when using gcc.
76 *
77 * Revision 1.1.1.1  2002/02/01 22:22:13  peiyongz
78 * sane_include
79 *
80 * Revision 1.4  2000/03/02 19:54:47  roddey
81 * This checkin includes many changes done while waiting for the
82 * 1.1.0 code to be finished. I can't list them all here, but a list is
83 * available elsewhere.
84 *
85 * Revision 1.3  2000/02/24 20:05:26  abagchi
86 * Swat for removing Log from API docs
87 *
88 * Revision 1.2  2000/02/06 07:48:05  rahulj
89 * Year 2K copyright swat.
90 *
91 * Revision 1.1.1.1  1999/11/09 01:05:30  twl
92 * Initial checkin
93 *
94 * Revision 1.2  1999/11/08 20:45:18  rahul
95 * Swat for adding in Product name and CVS comment log variable.
96 *
97 */
98
99#if !defined(VALUESTACKOF_HPP)
100#define VALUESTACKOF_HPP
101
102#include <xercesc/util/EmptyStackException.hpp>
103#include <xercesc/util/ValueVectorOf.hpp>
104
105XERCES_CPP_NAMESPACE_BEGIN
106
107//
108//  Forward declare the enumerator so he can be our friend. Can you say
109//  friend? Sure...
110//
111template <class TElem> class ValueStackEnumerator;
112
113
114template <class TElem> class ValueStackOf : public XMemory
115{
116public :
117    // -----------------------------------------------------------------------
118    //  Constructors and Destructor
119    // -----------------------------------------------------------------------
120    ValueStackOf
121    (
122          const unsigned int fInitCapacity
123          , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
124          , const bool toCallDestructor = false
125    );
126    ~ValueStackOf();
127
128
129    // -----------------------------------------------------------------------
130    //  Element management methods
131    // -----------------------------------------------------------------------
132    void push(const TElem& toPush);
133    const TElem& peek() const;
134    TElem pop();
135    void removeAllElements();
136
137
138    // -----------------------------------------------------------------------
139    //  Getter methods
140    // -----------------------------------------------------------------------
141    bool empty();
142    unsigned int curCapacity();
143    unsigned int size();
144
145
146private :
147    // -----------------------------------------------------------------------
148    //  Unimplemented constructors and operators
149    // -----------------------------------------------------------------------   
150    ValueStackOf(const ValueStackOf<TElem>&);
151    ValueStackOf<TElem>& operator=(const ValueStackOf<TElem>&);
152
153    // -----------------------------------------------------------------------
154    //  Declare our friends
155    // -----------------------------------------------------------------------
156    friend class ValueStackEnumerator<TElem>;
157
158
159    // -----------------------------------------------------------------------
160    //  Data Members
161    //
162    //  fVector
163    //      The vector that is used as the backing data structure for the
164    //      stack.
165    // -----------------------------------------------------------------------
166    ValueVectorOf<TElem>    fVector;
167};
168
169
170
171//
172//  An enumerator for a value stack. It derives from the basic enumerator
173//  class, so that value stacks can be generically enumerated.
174//
175template <class TElem> class ValueStackEnumerator : public XMLEnumerator<TElem>, public XMemory
176{
177public :
178    // -----------------------------------------------------------------------
179    //  Constructors and Destructor
180    // -----------------------------------------------------------------------
181    ValueStackEnumerator
182    (
183                ValueStackOf<TElem>* const  toEnum
184        , const bool                        adopt = false
185    );
186    virtual ~ValueStackEnumerator();
187
188
189    // -----------------------------------------------------------------------
190    //  Enum interface
191    // -----------------------------------------------------------------------
192    bool hasMoreElements() const;
193    TElem& nextElement();
194    void Reset();
195
196
197private :
198    // -----------------------------------------------------------------------
199    //  Unimplemented constructors and operators
200    // -----------------------------------------------------------------------   
201    ValueStackEnumerator(const ValueStackEnumerator<TElem>&);
202    ValueStackEnumerator<TElem>& operator=(const ValueStackEnumerator<TElem>&);
203
204    // -----------------------------------------------------------------------
205    //  Data Members
206    //
207    //  fAdopted
208    //      Indicates whether we have adopted the passed stack. If so then
209    //      we delete the stack when we are destroyed.
210    //
211    //  fCurIndex
212    //      This is the current index into the vector inside the stack being
213    //      enumerated.
214    //
215    //  fToEnum
216    //      The stack that is being enumerated. This is just kept for
217    //      adoption purposes, since we really are enumerating the vector
218    //      inside of it.
219    // -----------------------------------------------------------------------
220    bool                    fAdopted;
221    unsigned int            fCurIndex;
222    ValueVectorOf<TElem>*   fVector;
223    ValueStackOf<TElem>*    fToEnum;
224};
225
226XERCES_CPP_NAMESPACE_END
227
228#if !defined(XERCES_TMPLSINC)
229#include <xercesc/util/ValueStackOf.c>
230#endif
231
232#endif
Note: See TracBrowser for help on using the repository browser.