source: icXML/icXML-devel/src/xercesc/util/RefArrayOf.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.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: RefArrayOf.hpp 932887 2010-04-11 13:04:59Z borisk $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_REFARRAY_HPP)
23#define XERCESC_INCLUDE_GUARD_REFARRAY_HPP
24
25#include <icxercesc/util/PlatformUtils.hpp>
26#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
27#include <xercesc/util/IllegalArgumentException.hpp>
28#include <xercesc/util/XMLEnumerator.hpp>
29#include <xercesc/framework/MemoryManager.hpp>
30
31XERCES_CPP_NAMESPACE_BEGIN
32
33template <class TElem> class RefArrayOf : public XMemory
34{
35public :
36    // -----------------------------------------------------------------------
37    //  Constructors and Destructor
38    // -----------------------------------------------------------------------
39    RefArrayOf
40    (
41          const XMLSize_t size
42        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
43        RefArrayOf
44    (
45          TElem* values[]
46        , const XMLSize_t size
47        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
48        RefArrayOf(const RefArrayOf<TElem>& source);
49        ~RefArrayOf();
50
51
52    // -----------------------------------------------------------------------
53    //  Public operators
54    // -----------------------------------------------------------------------
55        TElem*& operator[](const XMLSize_t index);
56        const TElem* operator[](const XMLSize_t index) const;
57        RefArrayOf<TElem>& operator=(const RefArrayOf<TElem>& toAssign);
58        bool operator==(const RefArrayOf<TElem>& toCompare) const;
59        bool operator!=(const RefArrayOf<TElem>& toCompare) const;
60
61
62    // -----------------------------------------------------------------------
63    //  Copy operations
64    // -----------------------------------------------------------------------
65    XMLSize_t copyFrom(const RefArrayOf<TElem>& srcArray);
66
67
68    // -----------------------------------------------------------------------
69    //  Getter methods
70    // -----------------------------------------------------------------------
71        XMLSize_t length() const;
72        TElem** rawData() const;
73
74
75    // -----------------------------------------------------------------------
76    //  Element management methods
77    // -----------------------------------------------------------------------
78    void deleteAt(const XMLSize_t index);
79    void deleteAllElements();
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 reference array. It derives from the basic enumerator
95//  class, so that value vectors can be generically enumerated.
96//
97template <class TElem> class RefArrayEnumerator : public XMLEnumerator<TElem>, public XMemory
98{
99public :
100    // -----------------------------------------------------------------------
101    //  Constructors and Destructor
102    // -----------------------------------------------------------------------
103    RefArrayEnumerator
104    (
105                RefArrayOf<TElem>* const    toEnum
106        , const bool                        adopt = false
107    );
108    virtual ~RefArrayEnumerator();
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    RefArrayEnumerator(const RefArrayEnumerator<TElem>&);
124    RefArrayEnumerator<TElem>& operator=(const RefArrayEnumerator<TElem>&);
125
126    // -----------------------------------------------------------------------
127    //  Data Members
128    //
129    //  fAdopted
130    //      Indicates whether we have adopted the passed array. If so then
131    //      we delete it when we are destroyed.
132    //
133    //  fCurIndex
134    //      This is the current index into the array.
135    //
136    //  fToEnum
137    //      The reference array being enumerated.
138    // -----------------------------------------------------------------------
139    bool                fAdopted;
140    XMLSize_t           fCurIndex;
141    RefArrayOf<TElem>*  fToEnum;
142};
143
144XERCES_CPP_NAMESPACE_END
145
146#if !defined(XERCES_TMPLSINC)
147#include <xercesc/util/RefArrayOf.c>
148#endif
149
150#endif
Note: See TracBrowser for help on using the repository browser.