/home/ntakagi/work/STLport-5.1.5/stlport/stl/debug/_string.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1997-1999
00003  * Silicon Graphics Computer Systems, Inc.
00004  *
00005  * Copyright (c) 1999
00006  * Boris Fomitchev
00007  *
00008  * This material is provided "as is", with absolutely no warranty expressed
00009  * or implied. Any use is at your own risk.
00010  *
00011  * Permission to use or copy this software for any purpose is hereby granted
00012  * without fee, provided the above notices are retained on all copies.
00013  * Permission to modify the code and to distribute modified code is granted,
00014  * provided the above notices are retained, and a notice that the code was
00015  * modified is included with the above copyright notice.
00016  */
00017 
00018 #ifndef _STLP_DBG_STRING_H
00019 #define _STLP_DBG_STRING_H
00020 
00021 #ifndef _STLP_DBG_ITERATOR_H
00022 #  include <stl/debug/_iterator.h>
00023 #endif
00024 
00025 _STLP_BEGIN_NAMESPACE
00026 
00027 #define _STLP_NON_DBG_STRING_NAME _STLP_NON_DBG_NAME(str)
00028 #define _STLP_NON_DBG_STRING _STLP_PRIV _STLP_NON_DBG_STRING_NAME <_CharT, _Traits, _Alloc>
00029 
00030 #if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
00031 template <class _CharT,class _Traits, class _Alloc>
00032 inline _CharT*
00033 value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_STRING >&)
00034 { return (_CharT*)0; }
00035 template <class _CharT, class _Traits, class _Alloc>
00036 inline random_access_iterator_tag
00037 iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_STRING >&)
00038 { return random_access_iterator_tag(); }
00039 #endif
00040 
00041 template <class _CharT, class _Traits, class _Alloc>
00042 class basic_string :
00043 #if !defined (__DMC__)
00044                      private
00045 #else
00046                      public
00047 #endif
00048                              _STLP_PRIV __construct_checker<_STLP_NON_DBG_STRING >
00049 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (basic_string)
00050                    , public __stlport_class<basic_string<_CharT, _Traits, _Alloc> >
00051 #endif
00052 {
00053 protected:
00054   typedef _STLP_NON_DBG_STRING _Base;
00055   typedef basic_string<_CharT, _Traits, _Alloc> _Self;
00056   typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_STRING > _ConstructCheck;
00057   typedef typename _IsPOD<_CharT>::_Type _Char_Is_POD;
00058 
00059 public:
00060   __IMPORT_CONTAINER_TYPEDEFS(_Base)
00061   typedef typename _Base::traits_type traits_type;
00062   typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Nonconst_traits<value_type> > > iterator;
00063   typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Const_traits<value_type> > > const_iterator;
00064   _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
00065 
00066 public:                         // Constructor, destructor, assignment.
00067   typedef typename _Base::_Reserve_t _Reserve_t;
00068 
00069 private:
00070   _Base _M_non_dbg_impl;
00071   _STLP_PRIV __owned_list _M_iter_list;
00072 
00073   void _Invalidate_all()
00074   { _M_iter_list._Invalidate_all(); }
00075   void _Compare_Capacity (size_type __old_capacity) {
00076     if (this->capacity() > __old_capacity) {
00077       _Invalidate_all();
00078     }
00079   }
00080   void _Invalidate_iterator(const iterator& __it)
00081   { _STLP_PRIV __invalidate_iterator(&_M_iter_list, __it); }
00082   void _Invalidate_iterators(const iterator& __f, const iterator& __l)
00083   { _STLP_PRIV __invalidate_range(&_M_iter_list, __f, __l); }
00084 
00085 public:
00086 #include <stl/_string_npos.h>
00087 
00088   allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); }
00089 
00090   explicit basic_string(const allocator_type& __a = allocator_type())
00091     : _M_non_dbg_impl(__a), _M_iter_list(&_M_non_dbg_impl) {}
00092 
00093   basic_string(_Reserve_t __r, size_t __n,
00094                const allocator_type& __a = allocator_type())
00095     : _M_non_dbg_impl(__r, __n, __a), _M_iter_list(&_M_non_dbg_impl) {}
00096 
00097   basic_string(const _Self& __s)
00098     : _ConstructCheck(__s),
00099       _M_non_dbg_impl(__s._M_non_dbg_impl), _M_iter_list(&_M_non_dbg_impl) {}
00100 
00101   basic_string(const _Self& __s, size_type __pos, size_type __n = npos,
00102                const allocator_type& __a = allocator_type())
00103     : _M_non_dbg_impl(__s._M_non_dbg_impl, __pos, __n, __a),
00104       _M_iter_list(&_M_non_dbg_impl) {}
00105 
00106   basic_string(const _CharT* __s, size_type __n,
00107                const allocator_type& __a = allocator_type())
00108     : _ConstructCheck(__s), _M_non_dbg_impl(__s, __n, __a),
00109       _M_iter_list(&_M_non_dbg_impl) {}
00110 
00111   basic_string(const _CharT* __s,
00112                const allocator_type& __a = allocator_type())
00113     : _ConstructCheck(__s),
00114       _M_non_dbg_impl(__s, __a), _M_iter_list(&_M_non_dbg_impl) {}
00115 
00116   basic_string(size_type __n, _CharT __c,
00117                const allocator_type& __a = allocator_type())
00118     : _M_non_dbg_impl(__n, __c, __a), _M_iter_list(&_M_non_dbg_impl) {}
00119 
00120   basic_string(__move_source<_Self> src)
00121     : _M_non_dbg_impl(__move_source<_Base >(src.get()._M_non_dbg_impl)),
00122       _M_iter_list(&_M_non_dbg_impl) {
00123 #if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
00124     src.get()._M_iter_list._Invalidate_all();
00125 #else
00126     src.get()._M_iter_list._Set_owner(_M_iter_list);
00127 #endif
00128   }
00129 
00130 #if !defined (_STLP_MEMBER_TEMPLATES) || defined(__MRC__) || defined(__SC__)
00131   basic_string(const _CharT* __f, const _CharT* __l,
00132                const allocator_type& __a = allocator_type())
00133     : _ConstructCheck(__f, __l),
00134       _M_non_dbg_impl(__f, __l, __a), _M_iter_list(&_M_non_dbg_impl) {
00135   }
00136   basic_string(const_iterator __f, const_iterator __l,
00137                const allocator_type & __a = allocator_type())
00138     : _ConstructCheck(__f, __l),
00139       _M_non_dbg_impl(__f._M_iterator, __l._M_iterator, __a), _M_iter_list(&_M_non_dbg_impl) {
00140   }
00141 #else
00142   template <class _InputIterator>
00143   basic_string(_InputIterator __f, _InputIterator __l,
00144                const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL)
00145     : _ConstructCheck(__f, __l),
00146       _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l), __a),
00147       _M_iter_list(&_M_non_dbg_impl) {}
00148 #  if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
00149   template <class _InputIterator>
00150   basic_string(_InputIterator __f, _InputIterator __l)
00151     : _ConstructCheck(__f, __l),
00152       _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l)),
00153       _M_iter_list(&_M_non_dbg_impl) {}
00154 #  endif
00155 #endif
00156 
00157 private:
00158   // constructor from non-debug version for substr
00159   basic_string (const _Base& __x)
00160     : _M_non_dbg_impl(__x), _M_iter_list(&_M_non_dbg_impl) {}
00161 
00162 public:
00163   _Self& operator=(const _Self& __s) {
00164     if (this != &__s) {
00165       assign(__s);
00166     }
00167     return *this;
00168   }
00169 
00170   _Self& operator=(const _CharT* __s) {
00171     _STLP_FIX_LITERAL_BUG(__s)
00172     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00173     return assign(__s);
00174   }
00175 
00176   _Self& operator=(_CharT __c) {
00177     return assign(1, __c);
00178   }
00179 
00180   // Iterators.
00181   iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
00182   const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
00183   iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
00184   const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
00185 
00186   reverse_iterator rbegin()             { return reverse_iterator(end()); }
00187   const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
00188   reverse_iterator rend()               { return reverse_iterator(begin()); }
00189   const_reverse_iterator rend() const   { return const_reverse_iterator(begin()); }
00190 
00191   // Size, capacity, etc.
00192   size_type size() const { return _M_non_dbg_impl.size(); }
00193   size_type length() const { return _M_non_dbg_impl.length(); }
00194   size_t max_size() const { return _M_non_dbg_impl.max_size(); }
00195 
00196   void resize(size_type __n, _CharT __c) {
00197     if (__n > capacity())
00198       _Invalidate_all();
00199     else if (__n < size())
00200       _Invalidate_iterators(begin() + __n, end());
00201     _M_non_dbg_impl.resize(__n, __c);
00202   }
00203   void resize(size_type __n) { resize(__n, _STLP_DEFAULT_CONSTRUCTED(_CharT)); }
00204   size_type capacity() const { return _M_non_dbg_impl.capacity(); }
00205 
00206   void reserve(size_type __s = 0) {
00207     if (__s > capacity()) _Invalidate_all();
00208     _M_non_dbg_impl.reserve(__s);
00209   }
00210 
00211   void clear() {
00212     _Invalidate_all();
00213     _M_non_dbg_impl.clear();
00214   }
00215 
00216   bool empty() const { return _M_non_dbg_impl.empty(); }
00217 
00218   const_reference operator[](size_type __n) const {
00219     _STLP_VERBOSE_ASSERT(__n <= this->size(), _StlMsg_OUT_OF_BOUNDS);
00220     return _M_non_dbg_impl[__n];
00221   }
00222 
00223   reference operator[](size_type __n) {
00224     _STLP_VERBOSE_ASSERT(__n < this->size(), _StlMsg_OUT_OF_BOUNDS)
00225     return _M_non_dbg_impl[__n];
00226   }
00227 
00228   const_reference at(size_type __n) const { return _M_non_dbg_impl.at(__n); }
00229   reference at(size_type __n) { return _M_non_dbg_impl.at(__n); }
00230 
00231   // Append, operator+=, push_back.
00232   _Self& operator+=(const _Self& __s) { return append(__s); }
00233   _Self& operator+=(const _CharT* __s) {
00234     _STLP_FIX_LITERAL_BUG(__s)
00235     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00236     return append(__s);
00237   }
00238   _Self& operator+=(_CharT __c) { return append(1, __c); }
00239 
00240 #if defined (_STLP_MEMBER_TEMPLATES)
00241   template <class _InputIter>
00242   _Self& append(_InputIter __first, _InputIter __last) {
00243     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
00244     size_type __old_capacity = capacity();
00245     _M_non_dbg_impl.append(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
00246     _Compare_Capacity(__old_capacity);
00247     return *this;
00248   }
00249 #endif
00250 
00251 #if !defined (_STLP_MEMBER_TEMPLATES) || \
00252     !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
00253   _Self& append(const _CharT* __f, const _CharT* __l) {
00254     _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
00255     _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
00256     size_type __old_capacity = capacity();
00257     _M_non_dbg_impl.append(__f, __l);
00258     _Compare_Capacity(__old_capacity);
00259     return *this;
00260   }
00261 
00262   _Self& append(const_iterator __f, const_iterator __l) {
00263     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
00264     size_type __old_capacity = capacity();
00265     _M_non_dbg_impl.append(__f._M_iterator, __l._M_iterator);
00266     _Compare_Capacity(__old_capacity);
00267     return *this;
00268   }
00269 #endif
00270 
00271   _Self& append(const _Self& __s) {
00272     size_type __old_capacity = capacity();
00273     _M_non_dbg_impl.append(__s._M_non_dbg_impl);
00274     _Compare_Capacity(__old_capacity);
00275     return *this;
00276   }
00277 
00278   _Self& append(const _Self& __s, size_type __pos, size_type __n) {
00279     size_type __old_capacity = capacity();
00280     _M_non_dbg_impl.append(__s._M_non_dbg_impl, __pos, __n);
00281     _Compare_Capacity(__old_capacity);
00282     return *this;
00283   }
00284 
00285   _Self& append(const _CharT* __s, size_type __n) {
00286     _STLP_FIX_LITERAL_BUG(__s)
00287     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00288     size_type __old_capacity = capacity();
00289     _M_non_dbg_impl.append(__s, __n);
00290     _Compare_Capacity(__old_capacity);
00291     return *this;
00292   }
00293 
00294   _Self& append(const _CharT* __s) {
00295     _STLP_FIX_LITERAL_BUG(__s)
00296     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00297     size_type __old_capacity = capacity();
00298     _M_non_dbg_impl.append(__s);
00299     _Compare_Capacity(__old_capacity);
00300     return *this;
00301   }
00302 
00303   _Self& append(size_type __n, _CharT __c) {
00304     size_type __old_capacity = this->capacity();
00305     _M_non_dbg_impl.append(__n, __c);
00306     _Compare_Capacity(__old_capacity);
00307     return *this;
00308   }
00309 
00310   void push_back(_CharT __c) {
00311     size_type __old_capacity = this->capacity();
00312     _M_non_dbg_impl.push_back(__c);
00313     _Compare_Capacity(__old_capacity);
00314   }
00315 
00316   void pop_back() {
00317     _Invalidate_iterator(this->end());
00318     _M_non_dbg_impl.pop_back();
00319   }
00320 
00321   // Assign
00322 private:
00323   void _M_check_assign(size_type __n) {
00324     if (__n > capacity()) {
00325       _Invalidate_all();
00326     }
00327     else if (__n < size()) {
00328       _Invalidate_iterators(begin() + __n, end());
00329     }
00330   }
00331 
00332 public:
00333   _Self& assign(const _Self& __s) {
00334     _M_check_assign(__s.size());
00335     _M_non_dbg_impl.assign(__s._M_non_dbg_impl);
00336     return *this;
00337   }
00338 
00339   _Self& assign(const _Self& __s, size_type __pos, size_type __n) {
00340     if (__pos < __s.size()) {
00341       _M_check_assign((min) (__n, __s.size() - __pos));
00342     }
00343     _M_non_dbg_impl.assign(__s._M_non_dbg_impl, __pos, __n);
00344     return *this;
00345   }
00346 
00347   _Self& assign(const _CharT* __s, size_type __n) {
00348     _STLP_FIX_LITERAL_BUG(__s)
00349     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00350     _M_check_assign((min) (_Traits::length(__s), __n));
00351     _M_non_dbg_impl.assign(__s, __s + __n);
00352     return *this;
00353   }
00354 
00355   _Self& assign(const _CharT* __s) {
00356     _STLP_FIX_LITERAL_BUG(__s)
00357     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00358     _M_check_assign(_Traits::length(__s));
00359     _M_non_dbg_impl.assign(__s);
00360     return *this;
00361   }
00362 
00363   _Self& assign(size_type __n, _CharT __c) {
00364     _M_check_assign(__n);
00365     _M_non_dbg_impl.assign(__n, __c);
00366     return *this;
00367   }
00368 
00369 #if defined(_STLP_MEMBER_TEMPLATES)
00370 private:
00371   template <class _Integer>
00372   void _M_assign_dispatch(_Integer __n, _Integer __x, const __true_type& /*_Integral*/) {
00373     _M_check_assign(__n);
00374     _M_non_dbg_impl.assign((size_type)__n, (_CharT)__x);
00375   }
00376 
00377   template <class _InputIter>
00378   void _M_assign_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/)  {
00379     _M_check_assign(distance(__f, __l));
00380     _M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l));
00381   }
00382 public:
00383   template <class _InputIter>
00384   inline _Self& assign(_InputIter __first, _InputIter __last) {
00385     _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
00386     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
00387     typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
00388     _M_assign_dispatch(__first, __last, _Integral());
00389     return *this;
00390   }
00391 #endif
00392 
00393 #if !defined (_STLP_MEMBER_TEMPLATES) || \
00394     !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
00395   _Self& assign(const _CharT* __f, const _CharT* __l) {
00396     _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
00397     _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
00398     _M_check_assign(distance(__f, __l));
00399     _M_non_dbg_impl.assign(__f, __l);
00400     return *this;
00401   }
00402   _Self& assign(const_iterator __f, const_iterator __l) {
00403     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
00404     _M_check_assign(distance(__f, __l));
00405     _M_non_dbg_impl.assign(__f._M_iterator, __l._M_iterator);
00406     return *this;
00407   }
00408 #endif
00409 
00410   // Insert
00411   _Self& insert(size_type __pos, const _Self& __s) {
00412     size_type __old_capacity = capacity();
00413     _M_non_dbg_impl.insert(__pos, __s._M_non_dbg_impl);
00414     _Compare_Capacity(__old_capacity);
00415     return *this;
00416   }
00417 
00418   _Self& insert(size_type __pos, const _Self& __s,
00419                 size_type __beg, size_type __n) {
00420     size_type __old_capacity = capacity();
00421     _M_non_dbg_impl.insert(__pos, __s._M_non_dbg_impl, __beg, __n);
00422     _Compare_Capacity(__old_capacity);
00423     return *this;
00424   }
00425 
00426   _Self& insert(size_type __pos, const _CharT* __s, size_type __n) {
00427     _STLP_FIX_LITERAL_BUG(__s)
00428     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00429     size_type __old_capacity = capacity();
00430     _M_non_dbg_impl.insert(__pos, __s, __n);
00431     _Compare_Capacity(__old_capacity);
00432     return *this;
00433   }
00434 
00435   _Self& insert(size_type __pos, const _CharT* __s) {
00436     _STLP_FIX_LITERAL_BUG(__s)
00437     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00438     return insert(__pos, __s, _Traits::length(__s));
00439   }
00440 
00441   _Self& insert(size_type __pos, size_type __n, _CharT __c) {
00442     size_type __old_capacity = capacity();
00443     _M_non_dbg_impl.insert(__pos, __n, __c);
00444     _Compare_Capacity(__old_capacity);
00445     return *this;
00446   }
00447 
00448   iterator insert(iterator __p, _CharT __c) {
00449     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
00450     size_type __old_capacity = capacity();
00451     typename _Base::iterator __ret = _M_non_dbg_impl.insert(__p._M_iterator, __c);
00452     _Compare_Capacity(__old_capacity);
00453     return iterator(&_M_iter_list, __ret);
00454   }
00455 
00456   void insert(iterator __p, size_t __n, _CharT __c) {
00457     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
00458     size_type __old_capacity = capacity();
00459     _M_non_dbg_impl.insert(__p._M_iterator, __n, __c);
00460     _Compare_Capacity(__old_capacity);
00461   }
00462 
00463 #if defined (_STLP_MEMBER_TEMPLATES)
00464 private:
00465   template <class _RandomIter>
00466   void _M_insert_aux (iterator __p, _RandomIter __first, _RandomIter __last,
00467                       const __true_type& /*_IsIterator*/)
00468   { _M_non_dbg_impl.insert(__p._M_iterator, __first._M_iterator, __last._M_iterator); }
00469 
00470   template<class _InputIter>
00471   void _M_insert_aux (iterator __p, _InputIter __first, _InputIter __last,
00472                       const __false_type& /*_IsIterator*/) {
00473     _M_non_dbg_impl.insert(__p._M_iterator,
00474                            _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
00475   }
00476 
00477 public:
00478   template <class _InputIter>
00479   void insert(iterator __p, _InputIter __first, _InputIter __last) {
00480     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
00481     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first,__last))
00482 
00483     /* In debug mode we are encapsulating non debug string iterators in debug one.
00484      * Doing so the non debug implementation will not check for self insertion
00485      * (x.insert(x.begin(), x.begin(), x.end()). To avoid this problem we try to
00486      * guess when _InputIter is iterator or const_iterator and in this case call
00487      * the non debug insert method with non debug string iterator.
00488      */
00489     typedef typename _AreSameUnCVTypes<_InputIter, iterator>::_Ret _IsNonConstIterator;
00490     typedef typename _AreSameUnCVTypes<_InputIter, const_iterator>::_Ret _IsConstIterator;
00491     typedef typename _Lor2<_IsNonConstIterator, _IsConstIterator>::_Ret _IsIterator;
00492 
00493     size_type __old_capacity = this->capacity();
00494     _M_insert_aux(__p, __first, __last, _IsIterator());
00495     _Compare_Capacity(__old_capacity);
00496   }
00497 #endif
00498 
00499 #if !defined (_STLP_MEMBER_TEMPLATES) || \
00500     !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
00501   void insert(iterator __p, const_iterator __f, const_iterator __l) {
00502     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
00503     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f,__l))
00504     size_type __old_capacity = capacity();
00505     _M_non_dbg_impl.insert(__p._M_iterator, __f._M_iterator, __l._M_iterator);
00506     _Compare_Capacity(__old_capacity);
00507   }
00508   void insert(iterator __p, const _CharT* __f, const _CharT* __l) {
00509     _STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l)
00510     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
00511     _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f,__l))
00512     size_type __old_capacity = capacity();
00513     _M_non_dbg_impl.insert(__p._M_iterator, __f, __l);
00514     _Compare_Capacity(__old_capacity);
00515   }
00516 #endif
00517 
00518   // Erase.
00519   _Self& erase(size_type __pos = 0, size_type __n = npos) {
00520     if (__pos < size()) {
00521       _Invalidate_iterators(begin() + __pos, end());
00522     }
00523     _M_non_dbg_impl.erase(__pos, __n);
00524     return *this;
00525   }
00526   iterator erase(iterator __pos) {
00527     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
00528     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
00529     _Invalidate_iterators(__pos, end());
00530     return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator));
00531   }
00532   iterator erase(iterator __f, iterator __l) {
00533     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
00534     _Invalidate_iterators(__f, end());
00535     return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__f._M_iterator, __l._M_iterator));
00536   }
00537 
00538   // Substring.
00539   _Self substr(size_type __pos = 0, size_type __n = npos) const
00540   { return _M_non_dbg_impl.substr(__pos, __n); }
00541 
00542   // Replace.  (Conceptually equivalent to erase followed by insert.)
00543   _Self& replace(size_type __pos, size_type __n, const _Self& __s) {
00544     size_type __old_capacity = capacity();
00545     _M_non_dbg_impl.replace(__pos, __n, __s._M_non_dbg_impl);
00546     _Compare_Capacity(__old_capacity);
00547     return *this;
00548   }
00549 
00550   _Self& replace(size_type __pos1, size_type __n1, const _Self& __s,
00551                  size_type __pos2, size_type __n2) {
00552     size_type __old_capacity = capacity();
00553     _M_non_dbg_impl.replace(__pos1, __n1, __s._M_non_dbg_impl, __pos2, __n2);
00554     _Compare_Capacity(__old_capacity);
00555     return *this;
00556   }
00557 
00558   _Self& replace(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2) {
00559     _STLP_FIX_LITERAL_BUG(__s)
00560     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00561     size_type __old_capacity = capacity();
00562     _M_non_dbg_impl.replace(__pos, __n1, __s, __n2);
00563     _Compare_Capacity(__old_capacity);
00564     return *this;
00565   }
00566 
00567   _Self& replace(size_type __pos, size_type __n1, const _CharT* __s) {
00568     _STLP_FIX_LITERAL_BUG(__s)
00569     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00570     size_type __old_capacity = capacity();
00571     _M_non_dbg_impl.replace(__pos, __n1, __s);
00572     _Compare_Capacity(__old_capacity);
00573     return *this;
00574   }
00575 
00576   _Self& replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c) {
00577     size_type __old_capacity = capacity();
00578     _M_non_dbg_impl.replace(__pos, __n1, __n2, __c);
00579     _Compare_Capacity(__old_capacity);
00580     return *this;
00581   }
00582 
00583   _Self& replace(iterator __f, iterator __l, const _Self& __s) {
00584     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
00585     size_type __old_capacity = capacity();
00586     _M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s._M_non_dbg_impl);
00587     _Compare_Capacity(__old_capacity);
00588     return *this;
00589   }
00590 
00591   _Self& replace(iterator __f, iterator __l, const _CharT* __s, size_type __n) {
00592     _STLP_FIX_LITERAL_BUG(__s)
00593     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
00594     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00595     size_type __old_capacity = capacity();
00596     _M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s, __n);
00597     _Compare_Capacity(__old_capacity);
00598     return *this;
00599   }
00600 
00601   _Self& replace(iterator __f, iterator __l, const _CharT* __s) {
00602     _STLP_FIX_LITERAL_BUG(__s)
00603     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
00604     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00605     size_type __old_capacity = capacity();
00606     _M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s);
00607     _Compare_Capacity(__old_capacity);
00608     return *this;
00609   }
00610 
00611   _Self& replace(iterator __f, iterator __l, size_type __n, _CharT __c) {
00612     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
00613     size_type __old_capacity = capacity();
00614     _M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __n, __c);
00615     _Compare_Capacity(__old_capacity);
00616     return *this;
00617   }
00618 
00619 #if defined (_STLP_MEMBER_TEMPLATES)
00620 private:
00621   template <class _RandomIter>
00622   void _M_replace_aux(iterator __first, iterator __last,
00623                       _RandomIter __f, _RandomIter __l, __true_type const& /*_IsIterator*/)
00624   { _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator, __f._M_iterator, __l._M_iterator); }
00625 
00626   template <class _InputIter>
00627   void _M_replace_aux(iterator __first, iterator __last,
00628                       _InputIter __f, _InputIter __l, __false_type const& /*_IsIterator*/) {
00629     _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator,
00630                             _STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l));
00631   }
00632 
00633 public:
00634   template <class _InputIter>
00635   _Self& replace(iterator __first, iterator __last,
00636                  _InputIter __f, _InputIter __l) {
00637     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
00638     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
00639 
00640     /* See insert comment for reson of iterator detection.
00641      */
00642     typedef typename _AreSameUnCVTypes<_InputIter, iterator>::_Ret _IsNonConstIterator;
00643     typedef typename _AreSameUnCVTypes<_InputIter, const_iterator>::_Ret _IsConstIterator;
00644     typedef typename _Lor2<_IsNonConstIterator, _IsConstIterator>::_Ret _IsIterator;
00645 
00646     size_type __old_capacity = capacity();
00647     _M_replace_aux(__first, __last, __f, __l, _IsIterator());
00648     _Compare_Capacity(__old_capacity);
00649     return *this;
00650   }
00651 #endif
00652 
00653 #if !defined (_STLP_MEMBER_TEMPLATES) || \
00654     !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
00655   _Self& replace(iterator __first, iterator __last,
00656                  const_iterator __f, const_iterator __l) {
00657     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
00658     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
00659     size_type __old_capacity = capacity();
00660     _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator,
00661                             __f._M_iterator, __l._M_iterator);
00662     _Compare_Capacity(__old_capacity);
00663     return *this;
00664   }
00665 
00666   _Self& replace(iterator __first, iterator __last,
00667                  const _CharT* __f, const _CharT* __l) {
00668     _STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l)
00669     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
00670     _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
00671     size_type __old_capacity = capacity();
00672     _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator, __f, __l);
00673     _Compare_Capacity(__old_capacity);
00674     return *this;
00675   }
00676 #endif
00677 
00678   // Other modifier member functions.
00679   void swap(_Self& __s) {
00680     _M_iter_list._Swap_owners(__s._M_iter_list);
00681     _M_non_dbg_impl.swap(__s._M_non_dbg_impl);
00682   }
00683 
00684   int compare(const _Self& __s) const
00685   { return _M_non_dbg_impl.compare(__s._M_non_dbg_impl); }
00686   int compare(size_type __pos, size_type __n, const _Self& __s) const
00687   { return _M_non_dbg_impl.compare(__pos, __n, __s._M_non_dbg_impl); }
00688   int compare(size_type __pos1, size_type __n1, const _Self& __s,
00689               size_type __pos2, size_type __n2) const
00690   { return _M_non_dbg_impl.compare(__pos1, __n1, __s._M_non_dbg_impl, __pos2, __n2); }
00691   int compare(const _CharT* __s) const {
00692     _STLP_FIX_LITERAL_BUG(__s)
00693     return _M_non_dbg_impl.compare(__s);
00694   }
00695   int compare(size_type __pos, size_type __n, const _CharT* __s) const {
00696     _STLP_FIX_LITERAL_BUG(__s)
00697     return _M_non_dbg_impl.compare(__pos, __n, __s);
00698   }
00699   int compare(size_type __pos1, size_type __n1, const _CharT* __s,
00700               size_type __n2) const {
00701     _STLP_FIX_LITERAL_BUG(__s)
00702     return _M_non_dbg_impl.compare(__pos1, __n1, __s, __n2);
00703   }
00704 
00705   // Helper functions for compare.
00706   static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1,
00707                                    const _CharT* __f2, const _CharT* __l2)
00708   { return _Base::_M_compare(__f1, __l1, __f2, __l2); }
00709   static int _STLP_CALL _M_compare(const_iterator __f1, const_iterator __l1,
00710                                    const _CharT* __f2, const _CharT* __l2)
00711   { return _Base::_M_compare(__f1._M_iterator, __l1._M_iterator, __f2, __l2); }
00712   static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1,
00713                                    const_iterator __f2, const_iterator __l2)
00714   { return _Base::_M_compare(__f1, __l1, __f2._M_iterator, __l2._M_iterator); }
00715   static int _STLP_CALL _M_compare(const_iterator __f1, const_iterator __l1,
00716                                    const_iterator __f2, const_iterator __l2)
00717   { return _Base::_M_compare(__f1._M_iterator, __l1._M_iterator, __f2._M_iterator, __l2._M_iterator); }
00718 
00719   const _CharT* c_str() const { return _M_non_dbg_impl.c_str(); }
00720   const _CharT* data()  const { return _M_non_dbg_impl.data(); }
00721 
00722   size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
00723   { return _M_non_dbg_impl.copy(__s, __n, __pos); }
00724 
00725   // find.
00726   size_type find(const _Self& __s, size_type __pos = 0) const
00727   { return _M_non_dbg_impl.find(__s._M_non_dbg_impl, __pos); }
00728   size_type find(const _CharT* __s, size_type __pos = 0) const {
00729     _STLP_FIX_LITERAL_BUG(__s)
00730     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00731     return _M_non_dbg_impl.find(__s, __pos);
00732   }
00733   size_type find(const _CharT* __s, size_type __pos, size_type __n) const {
00734     _STLP_FIX_LITERAL_BUG(__s)
00735     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00736     return _M_non_dbg_impl.find(__s, __pos, __n);
00737   }
00738   // WIE: Versant schema compiler 5.2.2 ICE workaround
00739   size_type find(_CharT __c) const { return find(__c, 0); }
00740   size_type find(_CharT __c, size_type __pos /* = 0 */) const
00741   { return _M_non_dbg_impl.find(__c, __pos); }
00742 
00743   // rfind.
00744   size_type rfind(const _Self& __s, size_type __pos = npos) const
00745   { return _M_non_dbg_impl.rfind(__s._M_non_dbg_impl, __pos); }
00746   size_type rfind(const _CharT* __s, size_type __pos = npos) const {
00747     _STLP_FIX_LITERAL_BUG(__s)
00748     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00749     return _M_non_dbg_impl.rfind(__s, __pos);
00750   }
00751   size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const {
00752     _STLP_FIX_LITERAL_BUG(__s)
00753     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00754     return _M_non_dbg_impl.rfind(__s, __pos, __n);
00755   }
00756   size_type rfind(_CharT __c, size_type __pos = npos) const
00757   { return _M_non_dbg_impl.rfind(__c, __pos); }
00758 
00759   // find_first_of
00760   size_type find_first_of(const _Self& __s, size_type __pos = 0) const
00761   { return _M_non_dbg_impl.find_first_of(__s._M_non_dbg_impl, __pos); }
00762   size_type find_first_of(const _CharT* __s, size_type __pos = 0) const {
00763     _STLP_FIX_LITERAL_BUG(__s)
00764     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00765     return _M_non_dbg_impl.find_first_of(__s, __pos);
00766   }
00767   size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const {
00768     _STLP_FIX_LITERAL_BUG(__s)
00769     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00770     return _M_non_dbg_impl.find_first_of(__s, __pos, __n);
00771   }
00772   size_type find_first_of(_CharT __c, size_type __pos = 0) const
00773   { return _M_non_dbg_impl.find_first_of(__c, __pos); }
00774 
00775   // find_last_of
00776   size_type find_last_of(const _Self& __s, size_type __pos = npos) const
00777   { return _M_non_dbg_impl.find_last_of(__s._M_non_dbg_impl, __pos); }
00778   size_type find_last_of(const _CharT* __s, size_type __pos = npos) const {
00779     _STLP_FIX_LITERAL_BUG(__s)
00780     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00781     return _M_non_dbg_impl.find_last_of(__s, __pos);
00782   }
00783   size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const {
00784     _STLP_FIX_LITERAL_BUG(__s)
00785     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00786     return _M_non_dbg_impl.find_last_of(__s, __pos, __n);
00787   }
00788   size_type find_last_of(_CharT __c, size_type __pos = npos) const
00789   { return _M_non_dbg_impl.rfind(__c, __pos); }
00790 
00791   // find_first_not_of
00792   size_type find_first_not_of(const _Self& __s, size_type __pos = 0) const
00793   { return _M_non_dbg_impl.find_first_not_of(__s._M_non_dbg_impl, __pos); }
00794   size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const {
00795     _STLP_FIX_LITERAL_BUG(__s)
00796     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00797     return _M_non_dbg_impl.find_first_not_of(__s, __pos);
00798   }
00799   size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const {
00800     _STLP_FIX_LITERAL_BUG(__s)
00801     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00802     return _M_non_dbg_impl.find_first_not_of(__s, __pos, __n);
00803   }
00804   size_type find_first_not_of(_CharT __c, size_type __pos = 0) const
00805   { return _M_non_dbg_impl.find_first_not_of(__c, __pos); }
00806 
00807   // find_last_not_of
00808   size_type find_last_not_of(const _Self& __s, size_type __pos = npos) const
00809   { return _M_non_dbg_impl.find_last_not_of(__s._M_non_dbg_impl, __pos); }
00810   size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const {
00811     _STLP_FIX_LITERAL_BUG(__s)
00812     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00813     return _M_non_dbg_impl.find_last_not_of(__s, __pos);
00814   }
00815   size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const {
00816     _STLP_FIX_LITERAL_BUG(__s)
00817     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
00818     return _M_non_dbg_impl.find_last_not_of(__s, __pos, __n);
00819   }
00820   size_type find_last_not_of(_CharT __c, size_type __pos = npos) const
00821   { return _M_non_dbg_impl.find_last_not_of(__c, __pos); }
00822 
00823 #if defined (_STLP_USE_TEMPLATE_EXPRESSION)
00824 #  include <stl/debug/_string_sum_methods.h>
00825 #endif /* _STLP_USE_TEMPLATE_EXPRESSION */
00826 };
00827 
00828 // This is a hook to instantiate STLport exports in a designated DLL
00829 #if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
00830 _STLP_MOVE_TO_PRIV_NAMESPACE
00831 _STLP_EXPORT_TEMPLATE_CLASS __construct_checker<_STLP_NON_DBG_STRING_NAME <char, char_traits<char>, allocator<char> > >;
00832 _STLP_MOVE_TO_STD_NAMESPACE
00833 _STLP_EXPORT_TEMPLATE_CLASS basic_string<char, char_traits<char>, allocator<char> >;
00834 #  if defined (_STLP_HAS_WCHAR_T)
00835 _STLP_MOVE_TO_PRIV_NAMESPACE
00836 _STLP_EXPORT_TEMPLATE_CLASS __construct_checker<_STLP_NON_DBG_STRING_NAME <wchar_t, char_traits<wchar_t>, allocator<wchar_t> > >;
00837 _STLP_MOVE_TO_STD_NAMESPACE
00838 _STLP_EXPORT_TEMPLATE_CLASS basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;
00839 #  endif
00840 #endif /* _STLP_USE_TEMPLATE_EXPORT */
00841 
00842 #undef _STLP_NON_DBG_STRING
00843 #undef _STLP_NON_DBG_STRING_NAME
00844 
00845 #if !defined (_STLP_STATIC_CONST_INIT_BUG)
00846 #  if defined (__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 96)
00847 template <class _CharT, class _Traits, class _Alloc>
00848 const size_t basic_string<_CharT, _Traits, _Alloc>::npos = ~(size_t) 0;
00849 #  else
00850 template <class _CharT, class _Traits, class _Alloc>
00851 const size_t basic_string<_CharT, _Traits, _Alloc>::npos;
00852 #  endif
00853 #endif
00854 
00855 #if defined (basic_string)
00856 _STLP_MOVE_TO_STD_NAMESPACE
00857 #undef basic_string
00858 #endif
00859 
00860 _STLP_END_NAMESPACE
00861 
00862 #endif /* _STLP_DBG_STRING */
00863 
00864 // Local Variables:
00865 // mode:C++
00866 // End:



Generated on Mon Mar 10 15:32:39 2008 by  doxygen 1.5.1