Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:27:26

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  * 
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  * 
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_VALUEARRAY_HPP)
0023 #define XERCESC_INCLUDE_GUARD_VALUEARRAY_HPP
0024 
0025 #include <xercesc/util/XMLEnumerator.hpp>
0026 #include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
0027 #include <xercesc/util/IllegalArgumentException.hpp>
0028 #include <xercesc/util/PlatformUtils.hpp>
0029 #include <xercesc/framework/MemoryManager.hpp>
0030 
0031 XERCES_CPP_NAMESPACE_BEGIN
0032 
0033 template <class TElem> class ValueArrayOf : public XMemory
0034 {
0035 public :
0036     // -----------------------------------------------------------------------
0037     //  Constructors and Destructor
0038     // -----------------------------------------------------------------------
0039     ValueArrayOf
0040     (
0041            const XMLSize_t      size
0042          , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0043     );
0044     ValueArrayOf
0045     (
0046           const TElem*         values
0047         , const XMLSize_t      size
0048         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0049     );
0050     ValueArrayOf(const ValueArrayOf<TElem>& source);
0051     ~ValueArrayOf();
0052 
0053 
0054     // -----------------------------------------------------------------------
0055     //  Public operators
0056     // -----------------------------------------------------------------------
0057     TElem& operator[](const XMLSize_t index);
0058     const TElem& operator[](const XMLSize_t index) const;
0059     ValueArrayOf<TElem>& operator=(const ValueArrayOf<TElem>& toAssign);
0060     bool operator==(const ValueArrayOf<TElem>& toCompare) const;
0061     bool operator!=(const ValueArrayOf<TElem>& toCompare) const;
0062 
0063 
0064     // -----------------------------------------------------------------------
0065     //  Copy operations
0066     // -----------------------------------------------------------------------
0067     XMLSize_t copyFrom(const ValueArrayOf<TElem>& srcArray);
0068 
0069 
0070     // -----------------------------------------------------------------------
0071     //  Getter methods
0072     // -----------------------------------------------------------------------
0073     XMLSize_t length() const;
0074     TElem* rawData() const;
0075 
0076 
0077     // -----------------------------------------------------------------------
0078     //  Miscellaneous methods
0079     // -----------------------------------------------------------------------
0080     void resize(const XMLSize_t newSize);
0081 
0082 
0083 private :
0084     // -----------------------------------------------------------------------
0085     //  Data members
0086     // -----------------------------------------------------------------------
0087     XMLSize_t       fSize;
0088     TElem*          fArray;
0089     MemoryManager*  fMemoryManager;
0090 };
0091 
0092 
0093 //
0094 //  An enumerator for a value array. It derives from the basic enumerator
0095 //  class, so that value vectors can be generically enumerated.
0096 //
0097 template <class TElem> class ValueArrayEnumerator : public XMLEnumerator<TElem>, public XMemory
0098 {
0099 public :
0100     // -----------------------------------------------------------------------
0101     //  Constructors and Destructor
0102     // -----------------------------------------------------------------------
0103     ValueArrayEnumerator
0104     (
0105                 ValueArrayOf<TElem>* const toEnum
0106         , const bool                       adopt = false
0107     );
0108     virtual ~ValueArrayEnumerator();
0109 
0110 
0111     // -----------------------------------------------------------------------
0112     //  Enum interface
0113     // -----------------------------------------------------------------------
0114     bool hasMoreElements() const;
0115     TElem& nextElement();
0116     void Reset();
0117 
0118 
0119 private :
0120     // -----------------------------------------------------------------------
0121     //  Unimplemented constructors and operators
0122     // -----------------------------------------------------------------------    
0123     ValueArrayEnumerator(const ValueArrayEnumerator<TElem>&);
0124     ValueArrayEnumerator<TElem>& operator=(const ValueArrayEnumerator<TElem>&);
0125 
0126     // -----------------------------------------------------------------------
0127     //  Data Members
0128     //
0129     //  fAdopted
0130     //      Indicates whether we have adopted the passed vector. If so then
0131     //      we delete the vector when we are destroyed.
0132     //
0133     //  fCurIndex
0134     //      This is the current index into the vector.
0135     //
0136     //  fToEnum
0137     //      The value array being enumerated.
0138     // -----------------------------------------------------------------------
0139     bool                    fAdopted;
0140     XMLSize_t               fCurIndex;
0141     ValueArrayOf<TElem>*    fToEnum;
0142 };
0143 
0144 XERCES_CPP_NAMESPACE_END
0145 
0146 #if !defined(XERCES_TMPLSINC)
0147 #include <xercesc/util/ValueArrayOf.c>
0148 #endif
0149 
0150 #endif