source: icXML/icXML-devel/src/xercesc/util/ValueVectorOf.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: ValueVectorOf.hpp 676911 2008-07-15 13:27:32Z amassari $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_VALUEVECTOROF_HPP)
23#define XERCESC_INCLUDE_GUARD_VALUEVECTOROF_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
32template <class TElem> class ValueVectorOf : public XMemory
33{
34public :
35    // -----------------------------------------------------------------------
36    //  Constructors and Destructor
37    // -----------------------------------------------------------------------
38    ValueVectorOf
39    (
40        const XMLSize_t maxElems
41        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
42        , const bool toCallDestructor = false
43    );
44    ValueVectorOf(const ValueVectorOf<TElem>& toCopy);
45    ~ValueVectorOf();
46
47
48    // -----------------------------------------------------------------------
49    //  Operators
50    // -----------------------------------------------------------------------
51    ValueVectorOf<TElem>& operator=(const ValueVectorOf<TElem>& toAssign);
52
53
54    // -----------------------------------------------------------------------
55    //  Element management
56    // -----------------------------------------------------------------------
57    void addElement(const TElem& toAdd);
58    void setElementAt(const TElem& toSet, const XMLSize_t setAt);
59    void insertElementAt(const TElem& toInsert, const XMLSize_t insertAt);
60    void removeElementAt(const XMLSize_t removeAt);
61    void removeAllElements();
62    bool containsElement(const TElem& toCheck, const XMLSize_t startIndex = 0);
63
64
65    // -----------------------------------------------------------------------
66    //  Getter methods
67    // -----------------------------------------------------------------------
68    const TElem& elementAt(const XMLSize_t getAt) const;
69    TElem& elementAt(const XMLSize_t getAt);
70    XMLSize_t curCapacity() const;
71    XMLSize_t size() const;
72    MemoryManager* getMemoryManager() const;
73
74
75    // -----------------------------------------------------------------------
76    //  Miscellaneous
77    // -----------------------------------------------------------------------
78    void ensureExtraCapacity(const XMLSize_t length);
79    const TElem* rawData() const;
80
81
82private:
83    // -----------------------------------------------------------------------
84    //  Data members
85    //
86    //  fCurCount
87    //      The count of values current added to the vector, which may be
88    //      less than the internal capacity.
89    //
90    //  fMaxCount
91    //      The current capacity of the vector.
92    //
93    //  fElemList
94    //      The list of elements, which is dynamically allocated to the needed
95    //      size.
96    // -----------------------------------------------------------------------
97    bool            fCallDestructor;
98    XMLSize_t       fCurCount;
99    XMLSize_t       fMaxCount;
100    TElem*          fElemList;
101    MemoryManager*  fMemoryManager;
102};
103
104
105//
106//  An enumerator for a value vector. It derives from the basic enumerator
107//  class, so that value vectors can be generically enumerated.
108//
109template <class TElem> class ValueVectorEnumerator : public XMLEnumerator<TElem>, public XMemory
110{
111public :
112    // -----------------------------------------------------------------------
113    //  Constructors and Destructor
114    // -----------------------------------------------------------------------
115    ValueVectorEnumerator
116    (
117                ValueVectorOf<TElem>* const toEnum
118        , const bool                        adopt = false
119    );
120    virtual ~ValueVectorEnumerator();
121
122
123    // -----------------------------------------------------------------------
124    //  Enum interface
125    // -----------------------------------------------------------------------
126    bool hasMoreElements() const;
127    TElem& nextElement();
128    void Reset();
129
130
131private :
132    // -----------------------------------------------------------------------
133    //  Unimplemented constructors and operators
134    // -----------------------------------------------------------------------   
135    ValueVectorEnumerator(const ValueVectorEnumerator<TElem>&);
136    ValueVectorEnumerator<TElem>& operator=(const ValueVectorEnumerator<TElem>&);
137
138    // -----------------------------------------------------------------------
139    //  Data Members
140    //
141    //  fAdopted
142    //      Indicates whether we have adopted the passed vector. If so then
143    //      we delete the vector when we are destroyed.
144    //
145    //  fCurIndex
146    //      This is the current index into the vector.
147    //
148    //  fToEnum
149    //      The value vector being enumerated.
150    // -----------------------------------------------------------------------
151    bool                    fAdopted;
152    XMLSize_t               fCurIndex;
153    ValueVectorOf<TElem>*   fToEnum;
154};
155
156XERCES_CPP_NAMESPACE_END
157
158#if !defined(XERCES_TMPLSINC)
159#include <xercesc/util/ValueVectorOf.c>
160#endif
161
162#endif
Note: See TracBrowser for help on using the repository browser.