00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055
00056
00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076
00077
00078 #if !defined(REFVECTOROF_HPP)
00079 #define REFVECTOROF_HPP
00080
00081 #include <util/XercesDefs.hpp>
00082 #include <util/ArrayIndexOutOfBoundsException.hpp>
00083 #include <util/XMLEnumerator.hpp>
00084
00085
00086 template <class TElem> class RefVectorOf
00087 {
00088 public :
00089
00090
00091
00092 RefVectorOf(const unsigned int maxElems, const bool adoptElems = true);
00093 ~RefVectorOf();
00094
00095
00096
00097
00098
00099 void addElement(TElem* const toAdd);
00100 void setElementAt(TElem* const toSet, const unsigned int setAt);
00101 void insertElementAt(TElem* const toInsert, const unsigned int insertAt);
00102 TElem* orphanElementAt(const unsigned int orphanAt);
00103 void removeAllElements();
00104 void removeElementAt(const unsigned int removeAt);
00105 void removeLastElement();
00106
00107
00108
00109
00110
00111 unsigned int curCapacity() const;
00112 const TElem* elementAt(const unsigned int getAt) const;
00113 TElem* elementAt(const unsigned int getAt);
00114 unsigned int size() const;
00115
00116
00117
00118
00119
00120 void ensureExtraCapacity(const unsigned int length);
00121
00122
00123 private:
00124
00125
00126
00127 bool fAdoptedElems;
00128 unsigned int fCurCount;
00129 unsigned int fMaxCount;
00130 TElem** fElemList;
00131 };
00132
00133
00134
00135
00136
00137
00138 template <class TElem> class RefVectorEnumerator : public XMLEnumerator<TElem>
00139 {
00140 public :
00141
00142
00143
00144 RefVectorEnumerator
00145 (
00146 RefVectorOf<TElem>* const toEnum
00147 , const bool adopt = false
00148 );
00149 ~RefVectorEnumerator();
00150
00151
00152
00153
00154
00155 bool hasMoreElements() const;
00156 TElem& nextElement();
00157 void Reset();
00158
00159
00160 private :
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 bool fAdopted;
00175 unsigned int fCurIndex;
00176 RefVectorOf<TElem>* fToEnum;
00177 };
00178
00179 #if !defined(XERCES_TMPLSINC)
00180 #include <util/RefVectorOf.c>
00181 #endif
00182
00183 #endif