OW_ArrayImpl.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2003-2004 Vintela, Inc. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions are met:
00006 *
00007 *  - Redistributions of source code must retain the above copyright notice,
00008 *    this list of conditions and the following disclaimer.
00009 *
00010 *  - Redistributions in binary form must reproduce the above copyright notice,
00011 *    this list of conditions and the following disclaimer in the documentation
00012 *    and/or other materials provided with the distribution.
00013 *
00014 *  - Neither the name of Vintela, Inc. nor the names of its
00015 *    contributors may be used to endorse or promote products derived from this
00016 *    software without specific prior written permission.
00017 *
00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00022 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00028 * POSSIBILITY OF SUCH DAMAGE.
00029 *******************************************************************************/
00030 
00036 #ifndef OW_ARRAY_IMPL_HPP_INCLUDE_GUARD_
00037 #define OW_ARRAY_IMPL_HPP_INCLUDE_GUARD_
00038 #include "OW_config.h"
00039 #include "OW_Array.hpp"
00040 
00041 namespace OW_NAMESPACE
00042 {
00043 
00045 template <typename T>
00046 inline Array<T>::Array() 
00047 : m_impl(new V) 
00048 {
00049 }
00051 template <typename T>
00052 inline Array<T>::~Array() 
00053 {
00054 }
00056 template <typename T>
00057 inline Array<T>::Array(V* toWrap) 
00058 : m_impl(toWrap) 
00059 {
00060 }
00062 template <typename T>
00063 inline Array<T>::Array(size_type n, const T& value) 
00064 : m_impl(new V(n, value)) 
00065 {
00066 }
00068 template <typename T>
00069 inline Array<T>::Array(int n, const T& value) 
00070 : m_impl(new V(n, value)) 
00071 {
00072 }
00074 template <typename T>
00075 inline Array<T>::Array(long n, const T& value) 
00076 : m_impl(new V(n, value)) 
00077 {
00078 }
00080 template <typename T>
00081 inline Array<T>::Array(size_type n) 
00082 : m_impl(new V(n)) 
00083 {
00084 }
00086 template <typename T>
00087 template<class InputIterator>
00088 inline Array<T>::Array(InputIterator first, InputIterator last) 
00089 : m_impl(new V(first, last)) 
00090 {
00091 }
00093 template <typename T>
00094 inline typename Array<T>::iterator
00095 Array<T>::begin()
00096 { 
00097    return m_impl->begin(); 
00098 }
00100 template <typename T>
00101 inline typename Array<T>::const_iterator
00102 Array<T>::begin() const 
00103 { 
00104    return m_impl->begin(); 
00105 }
00107 template <typename T>
00108 inline typename Array<T>::iterator
00109 Array<T>::end()
00110 { 
00111    return m_impl->end(); 
00112 }
00114 template <typename T>
00115 inline typename Array<T>::const_iterator
00116 Array<T>::end() const 
00117 { 
00118    return m_impl->end(); 
00119 }
00121 template <typename T>
00122 inline typename Array<T>::reverse_iterator
00123 Array<T>::rbegin()
00124 { 
00125    return m_impl->rbegin(); 
00126 }
00128 template <typename T>
00129 inline typename Array<T>::const_reverse_iterator
00130 Array<T>::rbegin() const 
00131 { 
00132    return m_impl->rbegin(); 
00133 }
00135 template <typename T>
00136 inline typename Array<T>::reverse_iterator
00137 Array<T>::rend()
00138 { 
00139    return m_impl->rend(); 
00140 }
00142 template <typename T>
00143 inline typename Array<T>::const_reverse_iterator
00144 Array<T>::rend() const 
00145 { 
00146    return m_impl->rend(); 
00147 }
00149 template <typename T>
00150 inline typename Array<T>::size_type
00151 Array<T>::size() const 
00152 { 
00153    return m_impl->size(); 
00154 }
00156 template <typename T>
00157 inline typename Array<T>::size_type
00158 Array<T>::max_size() const 
00159 { 
00160    return m_impl->max_size(); 
00161 }
00163 template <typename T>
00164 inline typename Array<T>::size_type
00165 Array<T>::capacity() const 
00166 { 
00167    return m_impl->capacity(); 
00168 }
00170 template <typename T>
00171 inline bool
00172 Array<T>::empty() const 
00173 { 
00174    return m_impl->empty(); 
00175 }
00177 template <typename T>
00178 inline typename Array<T>::reference
00179 Array<T>::operator[](size_type n)
00180 {
00181 #ifdef OW_CHECK_ARRAY_INDEXING
00182    checkValidIndex(n);
00183 #endif
00184    return m_impl->operator[](n);
00185 }
00187 template <typename T>
00188 inline typename Array<T>::const_reference
00189 Array<T>::operator[](size_type n) const
00190 {
00191 #ifdef OW_CHECK_ARRAY_INDEXING
00192    checkValidIndex(n);
00193 #endif
00194    return m_impl->operator[](n);
00195 }
00197 template <typename T>
00198 inline Array<T>&
00199 Array<T>::operator+= (const T& x)
00200 {
00201    m_impl->push_back(x);
00202    return *this;
00203 }
00205 template <typename T>
00206 inline void
00207 Array<T>::reserve(size_type n) 
00208 { 
00209    m_impl->reserve(n); 
00210 }
00212 template <typename T>
00213 inline typename Array<T>::reference
00214 Array<T>::front() 
00215 { 
00216    return m_impl->front(); 
00217 }
00219 template <typename T>
00220 inline typename Array<T>::const_reference
00221 Array<T>::front() const 
00222 { 
00223    return m_impl->front(); 
00224 }
00226 template <typename T>
00227 inline typename Array<T>::reference
00228 Array<T>::back() 
00229 { 
00230    return m_impl->back(); 
00231 }
00233 template <typename T>
00234 inline typename Array<T>::const_reference
00235 Array<T>::back() const 
00236 { 
00237    return m_impl->back(); 
00238 }
00240 template <typename T>
00241 inline void
00242 Array<T>::push_back(const T& x) 
00243 { 
00244    m_impl->push_back(x); 
00245 }
00247 template <typename T>
00248 inline void
00249 Array<T>::append(const T& x) 
00250 { 
00251    push_back(x); 
00252 }
00254 template <typename T>
00255 inline void
00256 Array<T>::swap(Array<T>& x) 
00257 { 
00258    m_impl.swap(x.m_impl); 
00259 }
00261 template <typename T>
00262 inline typename Array<T>::iterator
00263 Array<T>::insert(iterator position, const T& x)
00264 { 
00265    return m_impl->insert(position, x); 
00266 }
00268 template <typename T>
00269 inline void
00270 Array<T>::insert(size_type position, const T& x)
00271 { 
00272    m_impl->insert(m_impl->begin() + position, x); 
00273 }
00275 template <typename T>
00276 inline void
00277 Array<T>::remove(size_type index)
00278 {
00279 #ifdef OW_CHECK_ARRAY_INDEXING
00280    checkValidIndex(index);
00281 #endif
00282    m_impl->erase(m_impl->begin() + index);
00283 }
00285 template <typename T>
00286 inline void
00287 Array<T>::remove(size_type begin, size_type end)
00288 {
00289 #ifdef OW_CHECK_ARRAY_INDEXING
00290    checkValidIndex(begin);
00291    checkValidIndex(end - 1);
00292 #endif
00293    m_impl->erase(m_impl->begin() + begin, m_impl->begin() + end);
00294 }
00296 template <typename T>
00297 template<class InputIterator>
00298 inline void
00299 Array<T>::insert(iterator position, InputIterator first, InputIterator last)
00300 {
00301    m_impl->insert(position, first, last);
00302 }
00304 template <typename T>
00305 inline void
00306 Array<T>::appendArray(const Array<T>& x)
00307 {
00308    insert(end(), x.begin(), x.end());
00309 }
00311 template <typename T>
00312 inline void
00313 Array<T>::pop_back() 
00314 { 
00315    m_impl->pop_back(); 
00316 }
00318 template <typename T>
00319 inline typename Array<T>::iterator
00320 Array<T>::erase(iterator position) 
00321 { 
00322    return m_impl->erase(position); 
00323 }
00325 template <typename T>
00326 inline typename Array<T>::iterator
00327 Array<T>::erase(iterator first, iterator last) 
00328 { 
00329    return m_impl->erase(first, last); 
00330 }
00332 template <typename T>
00333 inline void
00334 Array<T>::resize(size_type new_size, const T& x) 
00335 { 
00336    m_impl->resize(new_size, x); 
00337 }
00339 template <typename T>
00340 inline void
00341 Array<T>::resize(size_type new_size) 
00342 { 
00343    m_impl->resize(new_size); 
00344 }
00346 template <typename T>
00347 inline void
00348 Array<T>::clear() 
00349 { 
00350    m_impl->clear(); 
00351 }
00352 
00353 #ifdef OW_CHECK_ARRAY_INDEXING
00354 
00355 OW_COMMON_API void throwArrayOutOfBoundsException(size_t size, size_t idx);
00356 
00358 template <typename T>
00359 inline void
00360 Array<T>::checkValidIndex(size_type index) const
00361 {
00362    if (index >= size())
00363    {
00364       throwArrayOutOfBoundsException(size(), index);
00365    }
00366 }
00367 #endif
00368 template<class T>
00369 inline bool operator==(const Array<T>& x, const Array<T>& y)
00370 {
00371    return *x.m_impl == *y.m_impl;
00372 }
00373 template<class T>
00374 inline bool operator<(const Array<T>& x, const Array<T>& y)
00375 {
00376    return *x.m_impl < *y.m_impl;
00377 }
00378 template<class T>
00379 inline void swap(Array<T>& x, Array<T>& y)
00380 {
00381    x.swap(y);
00382 }
00383 
00384 } // end namespace OW_NAMESPACE
00385 
00386 #endif
00387    

Generated on Thu Feb 9 08:47:51 2006 for openwbem by  doxygen 1.4.6