secureswitools/swisistools/source/xmlparser/xerces/include/xercesc/util/RefArrayOf.hpp
changeset 0 ba25891c3a9e
child 1 c42dffbd5b4f
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 /*
       
    18  * Licensed to the Apache Software Foundation (ASF) under one or more
       
    19  * contributor license agreements.  See the NOTICE file distributed with
       
    20  * this work for additional information regarding copyright ownership.
       
    21  * The ASF licenses this file to You under the Apache License, Version 2.0
       
    22  * (the "License"); you may not use this file except in compliance with
       
    23  * the License.  You may obtain a copy of the License at
       
    24  * 
       
    25  *      http://www.apache.org/licenses/LICENSE-2.0
       
    26  * 
       
    27  * Unless required by applicable law or agreed to in writing, software
       
    28  * distributed under the License is distributed on an "AS IS" BASIS,
       
    29  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    30  * See the License for the specific language governing permissions and
       
    31  * limitations under the License.
       
    32  */
       
    33 
       
    34 /*
       
    35  * $Id: RefArrayOf.hpp 568078 2007-08-21 11:43:25Z amassari $
       
    36  */
       
    37 
       
    38 
       
    39 #if !defined(REFARRAY_HPP)
       
    40 #define REFARRAY_HPP
       
    41 
       
    42 #include <xercesc/util/PlatformUtils.hpp>
       
    43 #include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
       
    44 #include <xercesc/util/IllegalArgumentException.hpp>
       
    45 #include <xercesc/util/XMLEnumerator.hpp>
       
    46 #include <xercesc/framework/MemoryManager.hpp>
       
    47 
       
    48 XERCES_CPP_NAMESPACE_BEGIN
       
    49 
       
    50 template <class TElem> class RefArrayOf : public XMemory
       
    51 {
       
    52 public :
       
    53     // -----------------------------------------------------------------------
       
    54     //  Contructors and Destructor
       
    55     // -----------------------------------------------------------------------
       
    56     RefArrayOf
       
    57     (
       
    58           const unsigned int size
       
    59         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
       
    60 	RefArrayOf
       
    61     (
       
    62           TElem* values[]
       
    63         , const unsigned int size
       
    64         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
       
    65 	RefArrayOf(const RefArrayOf<TElem>& source);
       
    66 	~RefArrayOf();
       
    67 
       
    68 
       
    69     // -----------------------------------------------------------------------
       
    70     //  Public operators
       
    71     // -----------------------------------------------------------------------
       
    72 	TElem*& operator[](const unsigned int index);
       
    73 	const TElem* operator[](const unsigned int index) const;
       
    74 	RefArrayOf<TElem>& operator=(const RefArrayOf<TElem>& toAssign);
       
    75 	bool operator==(const RefArrayOf<TElem>& toCompare) const;
       
    76 	bool operator!=(const RefArrayOf<TElem>& toCompare) const;
       
    77 
       
    78 
       
    79     // -----------------------------------------------------------------------
       
    80     //  Copy operations
       
    81     // -----------------------------------------------------------------------
       
    82     unsigned int copyFrom(const RefArrayOf<TElem>& srcArray);
       
    83 
       
    84 
       
    85     // -----------------------------------------------------------------------
       
    86     //  Getter methods
       
    87     // -----------------------------------------------------------------------
       
    88 	unsigned int length() const;
       
    89 	TElem** rawData() const;
       
    90 
       
    91 
       
    92     // -----------------------------------------------------------------------
       
    93     //  Element management methods
       
    94     // -----------------------------------------------------------------------
       
    95     void deleteAt(const unsigned int index);
       
    96     void deleteAllElements();
       
    97     void resize(const unsigned int newSize);
       
    98 
       
    99 
       
   100 private :
       
   101     // -----------------------------------------------------------------------
       
   102     //  Data members
       
   103     // -----------------------------------------------------------------------
       
   104 	unsigned int    fSize;
       
   105 	TElem**         fArray;
       
   106     MemoryManager*  fMemoryManager;
       
   107 };
       
   108 
       
   109 
       
   110 //
       
   111 //  An enumerator for a reference array. It derives from the basic enumerator
       
   112 //  class, so that value vectors can be generically enumerated.
       
   113 //
       
   114 template <class TElem> class RefArrayEnumerator : public XMLEnumerator<TElem>, public XMemory
       
   115 {
       
   116 public :
       
   117     // -----------------------------------------------------------------------
       
   118     //  Constructors and Destructor
       
   119     // -----------------------------------------------------------------------
       
   120     RefArrayEnumerator
       
   121     (
       
   122                 RefArrayOf<TElem>* const    toEnum
       
   123         , const bool                        adopt = false
       
   124     );
       
   125     virtual ~RefArrayEnumerator();
       
   126 
       
   127 
       
   128     // -----------------------------------------------------------------------
       
   129     //  Enum interface
       
   130     // -----------------------------------------------------------------------
       
   131     bool hasMoreElements() const;
       
   132     TElem& nextElement();
       
   133     void Reset();
       
   134 
       
   135 
       
   136 private :
       
   137     // -----------------------------------------------------------------------
       
   138     //  Unimplemented constructors and operators
       
   139     // -----------------------------------------------------------------------
       
   140     RefArrayEnumerator(const RefArrayEnumerator<TElem>&);
       
   141     RefArrayEnumerator<TElem>& operator=(const RefArrayEnumerator<TElem>&);
       
   142 
       
   143     // -----------------------------------------------------------------------
       
   144     //  Data Members
       
   145     //
       
   146     //  fAdopted
       
   147     //      Indicates whether we have adopted the passed array. If so then
       
   148     //      we delete it when we are destroyed.
       
   149     //
       
   150     //  fCurIndex
       
   151     //      This is the current index into the array.
       
   152     //
       
   153     //  fToEnum
       
   154     //      The reference array being enumerated.
       
   155     // -----------------------------------------------------------------------
       
   156     bool                fAdopted;
       
   157     unsigned int        fCurIndex;
       
   158     RefArrayOf<TElem>*  fToEnum;
       
   159 };
       
   160 
       
   161 XERCES_CPP_NAMESPACE_END
       
   162 
       
   163 #if !defined(XERCES_TMPLSINC)
       
   164 #include <xercesc/util/RefArrayOf.c>
       
   165 #endif
       
   166 
       
   167 #endif