source: icXML/icXML-devel/src/xercesc/util/RefStackOf.hpp @ 2722

Last change on this file since 2722 was 2722, checked in by cameron, 6 years ago

Original Xerces files with import mods for icxercesc

File size: 5.2 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id: RefStackOf.hpp 676911 2008-07-15 13:27:32Z amassari $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_REFSTACKOF_HPP)
23#define XERCESC_INCLUDE_GUARD_REFSTACKOF_HPP
24
25#include <xercesc/util/RefVectorOf.hpp>
26#include <xercesc/util/EmptyStackException.hpp>
27
28XERCES_CPP_NAMESPACE_BEGIN
29
30//
31//  Forward declare the enumerator so he can be our friend. Can you say
32//  friend? Sure...
33//
34template <class TElem> class RefStackEnumerator;
35
36
37template <class TElem> class RefStackOf : public XMemory
38{
39public :
40    // -----------------------------------------------------------------------
41    //  Constructors and Destructor
42    // -----------------------------------------------------------------------
43    RefStackOf(const XMLSize_t initElems,
44               const bool adoptElems = true,
45               MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
46    ~RefStackOf();
47
48
49    // -----------------------------------------------------------------------
50    //  Element management methods
51    // -----------------------------------------------------------------------
52    const TElem* elementAt(const XMLSize_t index) const;
53    TElem* popAt(const XMLSize_t index);
54    void push(TElem* const toPush);
55    const TElem* peek() const;
56    TElem* pop();
57    void removeAllElements();
58
59
60    // -----------------------------------------------------------------------
61    //  Getter methods
62    // -----------------------------------------------------------------------
63    bool empty();
64    XMLSize_t curCapacity();
65    XMLSize_t size();
66
67
68private :
69    // -----------------------------------------------------------------------
70    //  Declare our friends
71    // -----------------------------------------------------------------------
72    friend class RefStackEnumerator<TElem>;
73
74    // -----------------------------------------------------------------------
75    //  Unimplemented constructors and operators
76    // -----------------------------------------------------------------------
77    RefStackOf(const RefStackOf<TElem>&);
78    RefStackOf<TElem>& operator=(const RefStackOf<TElem>&);
79
80    // -----------------------------------------------------------------------
81    //  Data Members
82    //
83    //  fVector
84    //      The vector that is used as the backing data structure for the
85    //      stack.
86    // -----------------------------------------------------------------------
87    RefVectorOf<TElem>  fVector;
88};
89
90
91
92//
93//  An enumerator for a value stack. It derives from the basic enumerator
94//  class, so that value stacks can be generically enumerated.
95//
96template <class TElem> class RefStackEnumerator : public XMLEnumerator<TElem>, public XMemory
97{
98public :
99    // -----------------------------------------------------------------------
100    //  Constructors and Destructor
101    // -----------------------------------------------------------------------
102    RefStackEnumerator
103    (
104                RefStackOf<TElem>* const    toEnum
105        , const bool                        adopt = false
106    );
107    virtual ~RefStackEnumerator();
108
109
110    // -----------------------------------------------------------------------
111    //  Enum interface
112    // -----------------------------------------------------------------------
113    bool hasMoreElements() const;
114    TElem& nextElement();
115    void Reset();
116
117
118private :
119    // -----------------------------------------------------------------------
120    //  Unimplemented constructors and operators
121    // -----------------------------------------------------------------------
122    RefStackEnumerator(const RefStackEnumerator<TElem>&);
123    RefStackEnumerator<TElem>& operator=(const RefStackEnumerator<TElem>&);
124    // -----------------------------------------------------------------------
125    //  Data Members
126    //
127    //  fAdopted
128    //      Indicates whether we have adopted the passed stack. If so then
129    //      we delete the stack when we are destroyed.
130    //
131    //  fCurIndex
132    //      This is the current index into the vector inside the stack being
133    //      enumerated.
134    //
135    //  fToEnum
136    //      The stack that is being enumerated. This is just kept for
137    //      adoption purposes, since we really are enumerating the vector
138    //      inside of it.
139    // -----------------------------------------------------------------------
140    bool                fAdopted;
141    XMLSize_t           fCurIndex;
142    RefVectorOf<TElem>* fVector;
143    RefStackOf<TElem>*  fToEnum;
144};
145
146XERCES_CPP_NAMESPACE_END
147
148#if !defined(XERCES_TMPLSINC)
149#include <xercesc/util/RefStackOf.c>
150#endif
151
152#endif
Note: See TracBrowser for help on using the repository browser.