source: icXML/icXML-devel/src/xercesc/util/ValueArrayOf.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: ValueArrayOf.hpp 932887 2010-04-11 13:04:59Z borisk $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_VALUEARRAY_HPP)
23#define XERCESC_INCLUDE_GUARD_VALUEARRAY_HPP
24
25#include <xercesc/util/XMLEnumerator.hpp>
26#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
27#include <xercesc/util/IllegalArgumentException.hpp>
28#include <icxercesc/util/PlatformUtils.hpp>
29#include <xercesc/framework/MemoryManager.hpp>
30
31XERCES_CPP_NAMESPACE_BEGIN
32
33template <class TElem> class ValueArrayOf : public XMemory
34{
35public :
36    // -----------------------------------------------------------------------
37    //  Constructors and Destructor
38    // -----------------------------------------------------------------------
39    ValueArrayOf
40    (
41           const XMLSize_t      size
42         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
43    );
44        ValueArrayOf
45    (
46          const TElem*         values
47        , const XMLSize_t      size
48        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
49    );
50        ValueArrayOf(const ValueArrayOf<TElem>& source);
51        ~ValueArrayOf();
52
53
54    // -----------------------------------------------------------------------
55    //  Public operators
56    // -----------------------------------------------------------------------
57        TElem& operator[](const XMLSize_t index);
58        const TElem& operator[](const XMLSize_t index) const;
59        ValueArrayOf<TElem>& operator=(const ValueArrayOf<TElem>& toAssign);
60        bool operator==(const ValueArrayOf<TElem>& toCompare) const;
61        bool operator!=(const ValueArrayOf<TElem>& toCompare) const;
62
63
64    // -----------------------------------------------------------------------
65    //  Copy operations
66    // -----------------------------------------------------------------------
67    XMLSize_t copyFrom(const ValueArrayOf<TElem>& srcArray);
68
69
70    // -----------------------------------------------------------------------
71    //  Getter methods
72    // -----------------------------------------------------------------------
73        XMLSize_t length() const;
74        TElem* rawData() const;
75
76
77    // -----------------------------------------------------------------------
78    //  Miscellaneous methods
79    // -----------------------------------------------------------------------
80    void resize(const XMLSize_t newSize);
81
82
83private :
84    // -----------------------------------------------------------------------
85    //  Data members
86    // -----------------------------------------------------------------------
87        XMLSize_t       fSize;
88        TElem*          fArray;
89    MemoryManager*  fMemoryManager;
90};
91
92
93//
94//  An enumerator for a value array. It derives from the basic enumerator
95//  class, so that value vectors can be generically enumerated.
96//
97template <class TElem> class ValueArrayEnumerator : public XMLEnumerator<TElem>, public XMemory
98{
99public :
100    // -----------------------------------------------------------------------
101    //  Constructors and Destructor
102    // -----------------------------------------------------------------------
103    ValueArrayEnumerator
104    (
105                ValueArrayOf<TElem>* const toEnum
106        , const bool                       adopt = false
107    );
108    virtual ~ValueArrayEnumerator();
109
110
111    // -----------------------------------------------------------------------
112    //  Enum interface
113    // -----------------------------------------------------------------------
114    bool hasMoreElements() const;
115    TElem& nextElement();
116    void Reset();
117
118
119private :
120    // -----------------------------------------------------------------------
121    //  Unimplemented constructors and operators
122    // -----------------------------------------------------------------------   
123    ValueArrayEnumerator(const ValueArrayEnumerator<TElem>&);
124    ValueArrayEnumerator<TElem>& operator=(const ValueArrayEnumerator<TElem>&);
125
126    // -----------------------------------------------------------------------
127    //  Data Members
128    //
129    //  fAdopted
130    //      Indicates whether we have adopted the passed vector. If so then
131    //      we delete the vector when we are destroyed.
132    //
133    //  fCurIndex
134    //      This is the current index into the vector.
135    //
136    //  fToEnum
137    //      The value array being enumerated.
138    // -----------------------------------------------------------------------
139    bool                    fAdopted;
140    XMLSize_t               fCurIndex;
141    ValueArrayOf<TElem>*    fToEnum;
142};
143
144XERCES_CPP_NAMESPACE_END
145
146#if !defined(XERCES_TMPLSINC)
147#include <xercesc/util/ValueArrayOf.c>
148#endif
149
150#endif
Note: See TracBrowser for help on using the repository browser.