source: icXML/icXML-devel/src/xercesc/util/BaseRefVectorOf.hpp @ 2732

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

Original Xerces files with import mods for icxercesc

File size: 5.7 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: BaseRefVectorOf.hpp 676911 2008-07-15 13:27:32Z amassari $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_ABSTRACTVECTOROF_HPP)
23#define XERCESC_INCLUDE_GUARD_ABSTRACTVECTOROF_HPP
24
25#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
26#include <xercesc/util/XMLEnumerator.hpp>
27#include <icxercesc/util/PlatformUtils.hpp>
28#include <xercesc/framework/MemoryManager.hpp>
29
30XERCES_CPP_NAMESPACE_BEGIN
31
32/**
33 * Abstract base class for the xerces internal representation of Vector.
34 *
35 * The destructor is abstract, forcing each of RefVectorOf and
36 * RefArrayVectorOf to implement their own appropriate one.
37 *
38 */
39template <class TElem> class BaseRefVectorOf : public XMemory
40{
41public :
42    // -----------------------------------------------------------------------
43    //  Constructors and Destructor
44    // -----------------------------------------------------------------------
45    BaseRefVectorOf
46    (
47          const XMLSize_t maxElems
48        , const bool adoptElems = true
49        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
50    );
51    virtual ~BaseRefVectorOf();
52
53
54    // -----------------------------------------------------------------------
55    //  Element management
56    // -----------------------------------------------------------------------
57    void addElement(TElem* const toAdd);
58    virtual void setElementAt(TElem* const toSet, const XMLSize_t setAt);
59    void insertElementAt(TElem* const toInsert, const XMLSize_t insertAt);
60    TElem* orphanElementAt(const XMLSize_t orphanAt);
61    virtual void removeAllElements();
62    virtual void removeElementAt(const XMLSize_t removeAt);
63    virtual void removeLastElement();
64    bool containsElement(const TElem* const toCheck);
65    virtual void cleanup();
66    void reinitialize();
67
68
69    // -----------------------------------------------------------------------
70    //  Getter methods
71    // -----------------------------------------------------------------------
72    XMLSize_t curCapacity() const;
73    const TElem* elementAt(const XMLSize_t getAt) const;
74    TElem* elementAt(const XMLSize_t getAt);
75    XMLSize_t size() const;
76    MemoryManager* getMemoryManager() const;
77
78
79    // -----------------------------------------------------------------------
80    //  Miscellaneous
81    // -----------------------------------------------------------------------
82    void ensureExtraCapacity(const XMLSize_t length);
83
84private:
85    // -----------------------------------------------------------------------
86    //  Unimplemented constructors and operators
87    // -----------------------------------------------------------------------
88    BaseRefVectorOf(const BaseRefVectorOf<TElem>& copy);
89    BaseRefVectorOf& operator=(const BaseRefVectorOf<TElem>& copy);       
90
91protected:
92    // -----------------------------------------------------------------------
93    //  Data members
94    // -----------------------------------------------------------------------
95    bool            fAdoptedElems;
96    XMLSize_t       fCurCount;
97    XMLSize_t       fMaxCount;
98    TElem**         fElemList;
99    MemoryManager*  fMemoryManager;
100};
101
102
103//
104//  An enumerator for a vector. It derives from the basic enumerator
105//  class, so that value vectors can be generically enumerated.
106//
107template <class TElem> class BaseRefVectorEnumerator : public XMLEnumerator<TElem>, public XMemory
108{
109public :
110    // -----------------------------------------------------------------------
111    //  Constructors and Destructor
112    // -----------------------------------------------------------------------
113    BaseRefVectorEnumerator
114    (
115        BaseRefVectorOf<TElem>* const   toEnum
116        , const bool adopt = false
117    );
118    virtual ~BaseRefVectorEnumerator();
119
120    BaseRefVectorEnumerator(const BaseRefVectorEnumerator<TElem>& copy);
121    // -----------------------------------------------------------------------
122    //  Enum interface
123    // -----------------------------------------------------------------------
124    bool hasMoreElements() const;
125    TElem& nextElement();
126    void Reset();
127
128
129private :
130    // -----------------------------------------------------------------------
131    //  Unimplemented constructors and operators
132    // -----------------------------------------------------------------------       
133    BaseRefVectorEnumerator& operator=(const BaseRefVectorEnumerator<TElem>& copy);   
134    // -----------------------------------------------------------------------
135    //  Data Members
136    //
137    //  fAdopted
138    //      Indicates whether we have adopted the passed vector. If so then
139    //      we delete the vector when we are destroyed.
140    //
141    //  fCurIndex
142    //      This is the current index into the vector.
143    //
144    //  fToEnum
145    //      The reference vector being enumerated.
146    // -----------------------------------------------------------------------
147    bool                fAdopted;
148    XMLSize_t           fCurIndex;
149    BaseRefVectorOf<TElem>*    fToEnum;
150};
151
152XERCES_CPP_NAMESPACE_END
153
154#if !defined(XERCES_TMPLSINC)
155#include <xercesc/util/BaseRefVectorOf.c>
156#endif
157
158#endif
Note: See TracBrowser for help on using the repository browser.