1 | /*
|
---|
2 | * Copyright 1999-2000,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: ValueArrayOf.hpp,v $
|
---|
19 | * Revision 1.7 2004/09/08 13:56:23 peiyongz
|
---|
20 | * Apache License Version 2.0
|
---|
21 | *
|
---|
22 | * Revision 1.6 2004/01/29 11:48:46 cargilld
|
---|
23 | * Code cleanup changes to get rid of various compiler diagnostic messages.
|
---|
24 | *
|
---|
25 | * Revision 1.5 2003/05/16 06:01:52 knoaman
|
---|
26 | * Partial implementation of the configurable memory manager.
|
---|
27 | *
|
---|
28 | * Revision 1.4 2003/05/15 19:07:46 knoaman
|
---|
29 | * Partial implementation of the configurable memory manager.
|
---|
30 | *
|
---|
31 | * Revision 1.3 2002/11/04 15:22:05 tng
|
---|
32 | * C++ Namespace Support.
|
---|
33 | *
|
---|
34 | * Revision 1.2 2002/08/21 17:45:00 tng
|
---|
35 | * [Bug 7087] compiler warnings when using gcc.
|
---|
36 | *
|
---|
37 | * Revision 1.1.1.1 2002/02/01 22:22:13 peiyongz
|
---|
38 | * sane_include
|
---|
39 | *
|
---|
40 | * Revision 1.4 2000/03/02 19:54:47 roddey
|
---|
41 | * This checkin includes many changes done while waiting for the
|
---|
42 | * 1.1.0 code to be finished. I can't list them all here, but a list is
|
---|
43 | * available elsewhere.
|
---|
44 | *
|
---|
45 | * Revision 1.3 2000/02/24 20:05:26 abagchi
|
---|
46 | * Swat for removing Log from API docs
|
---|
47 | *
|
---|
48 | * Revision 1.2 2000/02/06 07:48:05 rahulj
|
---|
49 | * Year 2K copyright swat.
|
---|
50 | *
|
---|
51 | * Revision 1.1.1.1 1999/11/09 01:05:27 twl
|
---|
52 | * Initial checkin
|
---|
53 | *
|
---|
54 | * Revision 1.2 1999/11/08 20:45:18 rahul
|
---|
55 | * Swat for adding in Product name and CVS comment log variable.
|
---|
56 | *
|
---|
57 | */
|
---|
58 |
|
---|
59 |
|
---|
60 | #if !defined(VALUEARRAY_HPP)
|
---|
61 | #define VALUEARRAY_HPP
|
---|
62 |
|
---|
63 | #include <xercesc/util/XMLEnumerator.hpp>
|
---|
64 | #include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
|
---|
65 | #include <xercesc/util/IllegalArgumentException.hpp>
|
---|
66 | #include <xercesc/util/PlatformUtils.hpp>
|
---|
67 | #include <xercesc/framework/MemoryManager.hpp>
|
---|
68 |
|
---|
69 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
70 |
|
---|
71 | template <class TElem> class ValueArrayOf : public XMemory
|
---|
72 | {
|
---|
73 | public :
|
---|
74 | // -----------------------------------------------------------------------
|
---|
75 | // Contructors and Destructor
|
---|
76 | // -----------------------------------------------------------------------
|
---|
77 | ValueArrayOf
|
---|
78 | (
|
---|
79 | const unsigned int size
|
---|
80 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
81 | );
|
---|
82 | ValueArrayOf
|
---|
83 | (
|
---|
84 | const TElem* values
|
---|
85 | , const unsigned int size
|
---|
86 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
87 | );
|
---|
88 | ValueArrayOf(const ValueArrayOf<TElem>& source);
|
---|
89 | ~ValueArrayOf();
|
---|
90 |
|
---|
91 |
|
---|
92 | // -----------------------------------------------------------------------
|
---|
93 | // Public operators
|
---|
94 | // -----------------------------------------------------------------------
|
---|
95 | TElem& operator[](const unsigned int index);
|
---|
96 | const TElem& operator[](const unsigned int index) const;
|
---|
97 | ValueArrayOf<TElem>& operator=(const ValueArrayOf<TElem>& toAssign);
|
---|
98 | bool operator==(const ValueArrayOf<TElem>& toCompare) const;
|
---|
99 | bool operator!=(const ValueArrayOf<TElem>& toCompare) const;
|
---|
100 |
|
---|
101 |
|
---|
102 | // -----------------------------------------------------------------------
|
---|
103 | // Copy operations
|
---|
104 | // -----------------------------------------------------------------------
|
---|
105 | unsigned int copyFrom(const ValueArrayOf<TElem>& srcArray);
|
---|
106 |
|
---|
107 |
|
---|
108 | // -----------------------------------------------------------------------
|
---|
109 | // Getter methods
|
---|
110 | // -----------------------------------------------------------------------
|
---|
111 | unsigned int length() const;
|
---|
112 | TElem* rawData() const;
|
---|
113 |
|
---|
114 |
|
---|
115 | // -----------------------------------------------------------------------
|
---|
116 | // Miscellaneous methods
|
---|
117 | // -----------------------------------------------------------------------
|
---|
118 | void resize(const unsigned int newSize);
|
---|
119 |
|
---|
120 |
|
---|
121 | private :
|
---|
122 | // -----------------------------------------------------------------------
|
---|
123 | // Data members
|
---|
124 | // -----------------------------------------------------------------------
|
---|
125 | unsigned int fSize;
|
---|
126 | TElem* fArray;
|
---|
127 | MemoryManager* fMemoryManager;
|
---|
128 | };
|
---|
129 |
|
---|
130 |
|
---|
131 | //
|
---|
132 | // An enumerator for a value array. It derives from the basic enumerator
|
---|
133 | // class, so that value vectors can be generically enumerated.
|
---|
134 | //
|
---|
135 | template <class TElem> class ValueArrayEnumerator : public XMLEnumerator<TElem>, public XMemory
|
---|
136 | {
|
---|
137 | public :
|
---|
138 | // -----------------------------------------------------------------------
|
---|
139 | // Constructors and Destructor
|
---|
140 | // -----------------------------------------------------------------------
|
---|
141 | ValueArrayEnumerator
|
---|
142 | (
|
---|
143 | ValueArrayOf<TElem>* const toEnum
|
---|
144 | , const bool adopt = false
|
---|
145 | );
|
---|
146 | virtual ~ValueArrayEnumerator();
|
---|
147 |
|
---|
148 |
|
---|
149 | // -----------------------------------------------------------------------
|
---|
150 | // Enum interface
|
---|
151 | // -----------------------------------------------------------------------
|
---|
152 | bool hasMoreElements() const;
|
---|
153 | TElem& nextElement();
|
---|
154 | void Reset();
|
---|
155 |
|
---|
156 |
|
---|
157 | private :
|
---|
158 | // -----------------------------------------------------------------------
|
---|
159 | // Unimplemented constructors and operators
|
---|
160 | // -----------------------------------------------------------------------
|
---|
161 | ValueArrayEnumerator(const ValueArrayEnumerator<TElem>&);
|
---|
162 | ValueArrayEnumerator<TElem>& operator=(const ValueArrayEnumerator<TElem>&);
|
---|
163 |
|
---|
164 | // -----------------------------------------------------------------------
|
---|
165 | // Data Members
|
---|
166 | //
|
---|
167 | // fAdopted
|
---|
168 | // Indicates whether we have adopted the passed vector. If so then
|
---|
169 | // we delete the vector when we are destroyed.
|
---|
170 | //
|
---|
171 | // fCurIndex
|
---|
172 | // This is the current index into the vector.
|
---|
173 | //
|
---|
174 | // fToEnum
|
---|
175 | // The value array being enumerated.
|
---|
176 | // -----------------------------------------------------------------------
|
---|
177 | bool fAdopted;
|
---|
178 | unsigned int fCurIndex;
|
---|
179 | ValueArrayOf<TElem>* fToEnum;
|
---|
180 | };
|
---|
181 |
|
---|
182 | XERCES_CPP_NAMESPACE_END
|
---|
183 |
|
---|
184 | #if !defined(XERCES_TMPLSINC)
|
---|
185 | #include <xercesc/util/ValueArrayOf.c>
|
---|
186 | #endif
|
---|
187 |
|
---|
188 | #endif
|
---|