ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

_string.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1994
00003  * Hewlett-Packard Company
00004  *
00005  * Copyright (c) 1996,1997
00006  * Silicon Graphics Computer Systems, Inc.
00007  *
00008  * Copyright (c) 1997
00009  * Moscow Center for SPARC Technology
00010  *
00011  * Copyright (c) 1999
00012  * Boris Fomitchev
00013  *
00014  * This material is provided "as is", with absolutely no warranty expressed
00015  * or implied. Any use is at your own risk.
00016  *
00017  * Permission to use or copy this software for any purpose is hereby granted
00018  * without fee, provided the above notices are retained on all copies.
00019  * Permission to modify the code and to distribute modified code is granted,
00020  * provided the above notices are retained, and a notice that the code was
00021  * modified is included with the above copyright notice.
00022  */
00023 
00024 #ifndef _STLP_STRING_C
00025 #define _STLP_STRING_C
00026 
00027 #ifndef _STLP_INTERNAL_STRING_H
00028 #  include <stl/_string.h>
00029 #endif
00030 
00031 #ifndef _STLP_INTERNAL_CTRAITS_FUNCTIONS_H
00032 #  include <stl/_ctraits_fns.h>
00033 #endif
00034 
00035 #ifndef _STLP_INTERNAL_FUNCTION_H
00036 #  include <stl/_function.h>
00037 #endif
00038 
00039 #if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
00040 #  define basic_string _STLP_NO_MEM_T_NAME(str)
00041 #elif defined (_STLP_DEBUG)
00042 #  define basic_string _STLP_NON_DBG_NAME(str)
00043 #endif
00044 
00045 #if defined (_STLP_NESTED_TYPE_PARAM_BUG)
00046 #  define __size_type__ size_t
00047 #  define size_type size_t
00048 #  define iterator _CharT*
00049 #else
00050 #  define __size_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_string<_CharT,_Traits,_Alloc>::size_type
00051 #endif
00052 
00053 _STLP_BEGIN_NAMESPACE
00054 
00055 _STLP_MOVE_TO_PRIV_NAMESPACE
00056 
00057 // A helper class to use a char_traits as a function object.
00058 template <class _Traits>
00059 struct _Not_within_traits : public unary_function<typename _Traits::char_type, bool> {
00060   typedef typename _Traits::char_type _CharT;
00061   const _CharT* _M_first;
00062   const _CharT* _M_last;
00063 
00064   _Not_within_traits(const _CharT* __f, const _CharT* __l)
00065     : _M_first(__f), _M_last(__l) {}
00066 
00067   bool operator()(const _CharT& __x) const {
00068     return find_if(_M_first, _M_last,
00069                    _STLP_PRIV _Eq_char_bound<_Traits>(__x)) == _M_last;
00070   }
00071 };
00072 
00073 template <class _InputIter, class _CharT, class _Traits>
00074 inline _InputIter __str_find_first_of_aux(_InputIter __first1, _InputIter __last1,
00075                                           const _CharT* __first2, const _CharT* __last2,
00076                                           _Traits*, const __true_type& /* _STLportTraits */)
00077 { return __find_first_of(__first1, __last1, __first2, __last2); }
00078 
00079 template <class _InputIter, class _CharT, class _Traits>
00080 inline _InputIter __str_find_first_of_aux(_InputIter __first1, _InputIter __last1,
00081                                           const _CharT* __first2, const _CharT* __last2,
00082                                           _Traits*, const __false_type& /* _STLportTraits */)
00083 { return __find_first_of(__first1, __last1, __first2, __last2, _STLP_PRIV _Eq_traits<_Traits>()); }
00084 
00085 template <class _InputIter, class _CharT, class _Traits>
00086 inline _InputIter __str_find_first_of(_InputIter __first1, _InputIter __last1,
00087                                       const _CharT* __first2, const _CharT* __last2,
00088                                       _Traits* __traits) {
00089 #if !defined (__BORLANDC__)
00090   typedef typename _IsSTLportClass<_Traits>::_Ret _STLportTraits;
00091 #else
00092   enum { _Is = _IsSTLportClass<_Traits>::_Is };
00093   typedef typename __bool2type<_Is>::_Ret _STLportTraits;
00094 #endif
00095   return __str_find_first_of_aux(__first1, __last1, __first2, __last2, __traits, _STLportTraits());
00096 }
00097 
00098 template <class _InputIter, class _CharT, class _Traits>
00099 inline _InputIter __str_find_first_not_of_aux3(_InputIter __first1, _InputIter __last1,
00100                                                const _CharT* __first2, const _CharT* __last2,
00101                                                _Traits* /* __traits */, const __true_type& __useStrcspnLikeAlgo)
00102 { return __find_first_of_aux2(__first1, __last1, __first2, __last2, __first2, not1(_Identity<bool>()), __useStrcspnLikeAlgo); }
00103 
00104 template <class _InputIter, class _CharT, class _Traits>
00105 inline _InputIter __str_find_first_not_of_aux3(_InputIter __first1, _InputIter __last1,
00106                                                const _CharT* __first2, const _CharT* __last2,
00107                                                _Traits* /* __traits */, const __false_type& /* _UseStrcspnLikeAlgo */)
00108 { return _STLP_STD::find_if(__first1, __last1, _STLP_PRIV _Not_within_traits<_Traits>(__first2, __last2)); }
00109 
00110 template <class _InputIter, class _CharT, class _Tp, class _Traits>
00111 inline _InputIter __str_find_first_not_of_aux2(_InputIter __first1, _InputIter __last1,
00112                                                const _CharT* __first2, const _CharT* __last2,
00113                                                _Tp* __pt, _Traits* __traits) {
00114   typedef typename _IsIntegral<_Tp>::_Ret _IsIntegral;
00115   typedef typename _IsCharLikeType<_CharT>::_Ret _IsCharLike;
00116   typedef typename _Land2<_IsIntegral, _IsCharLike>::_Ret _UseStrcspnLikeAlgo;
00117   return __str_find_first_not_of_aux3(__first1, __last1, __first2, __last2, __traits, _UseStrcspnLikeAlgo());
00118 }
00119 
00120 template <class _InputIter, class _CharT, class _Traits>
00121 inline _InputIter __str_find_first_not_of_aux1(_InputIter __first1, _InputIter __last1,
00122                                                const _CharT* __first2, const _CharT* __last2,
00123                                                _Traits* __traits, const __true_type& /* _STLportTraits */)
00124 { return __str_find_first_not_of_aux2(__first1, __last1, __first2, __last2,
00125                                       _STLP_VALUE_TYPE(__first1, _InputIter), __traits); }
00126 
00127 template <class _InputIter, class _CharT, class _Traits>
00128 inline _InputIter __str_find_first_not_of_aux1(_InputIter __first1, _InputIter __last1,
00129                                                const _CharT* __first2, const _CharT* __last2,
00130                                                _Traits*, const __false_type& /* _STLportTraits */)
00131 { return _STLP_STD::find_if(__first1, __last1, _STLP_PRIV _Not_within_traits<_Traits>(__first2, __last2)); }
00132 
00133 template <class _InputIter, class _CharT, class _Traits>
00134 inline _InputIter __str_find_first_not_of(_InputIter __first1, _InputIter __last1,
00135                                           const _CharT* __first2, const _CharT* __last2,
00136                                           _Traits* __traits) {
00137 #if !defined (__BORLANDC__)
00138   typedef typename _IsSTLportClass<_Traits>::_Ret _STLportTraits;
00139 #else
00140   enum { _Is = _IsSTLportClass<_Traits>::_Is };
00141   typedef typename __bool2type<_Is>::_Ret _STLportTraits;
00142 #endif
00143   return __str_find_first_not_of_aux1(__first1, __last1, __first2, __last2, __traits, _STLportTraits());
00144 }
00145 
00146 // ------------------------------------------------------------
00147 // Non-inline declarations.
00148 
00149 #if !defined (basic_string)
00150 _STLP_MOVE_TO_STD_NAMESPACE
00151 #endif
00152 
00153 // Change the string's capacity so that it is large enough to hold
00154 //  at least __res_arg elements, plus the terminating _CharT().  Note that,
00155 //  if __res_arg < capacity(), this member function may actually decrease
00156 //  the string's capacity.
00157 template <class _CharT, class _Traits, class _Alloc>
00158 void basic_string<_CharT,_Traits,_Alloc>::reserve(size_type __res_arg) {
00159   if (__res_arg > max_size())
00160     this->_M_throw_length_error();
00161 
00162   size_type __n = (max)(__res_arg, size()) + 1;
00163   if (__n < this->_M_capacity())
00164     return;
00165 
00166   _M_reserve(__n);
00167 }
00168 
00169 template <class _CharT, class _Traits, class _Alloc>
00170 void basic_string<_CharT,_Traits,_Alloc>::_M_reserve(size_type __n) {
00171   pointer __new_start = this->_M_start_of_storage.allocate(__n, __n);
00172   pointer __new_finish = _STLP_PRIV __ucopy(this->_M_Start(), this->_M_Finish(), __new_start);
00173   _M_construct_null(__new_finish);
00174   this->_M_deallocate_block();
00175   this->_M_reset(__new_start, __new_finish, __new_start + __n);
00176 }
00177 
00178 template <class _CharT, class _Traits, class _Alloc>
00179 basic_string<_CharT,_Traits,_Alloc>&
00180 basic_string<_CharT,_Traits,_Alloc>::append(size_type __n, _CharT __c) {
00181   if (__n > 0) {
00182     if (__n > max_size() - size())
00183       this->_M_throw_length_error();
00184     if (__n >= this->_M_rest())
00185       _M_reserve(_M_compute_next_size(__n));
00186     _STLP_PRIV __uninitialized_fill_n(this->_M_finish + 1, __n - 1, __c);
00187     _M_construct_null(this->_M_finish + __n);
00188     _Traits::assign(*end(), __c);
00189     this->_M_finish += __n;
00190   }
00191   return *this;
00192 }
00193 
00194 template <class _CharT, class _Traits, class _Alloc>
00195 basic_string<_CharT, _Traits, _Alloc>&
00196 basic_string<_CharT, _Traits, _Alloc>::_M_append(const _CharT* __first, const _CharT* __last) {
00197   if (__first != __last) {
00198     size_type __n = __STATIC_CAST(size_type, __last - __first);
00199     if (__n >= this->_M_rest()) {
00200       size_type __len = _M_compute_next_size(__n);
00201       pointer __new_start = this->_M_start_of_storage.allocate(__len, __len);
00202       pointer __new_finish = _STLP_PRIV __ucopy(this->_M_Start(), this->_M_Finish(), __new_start);
00203       __new_finish = _STLP_PRIV __ucopy(__first, __last, __new_finish);
00204       _M_construct_null(__new_finish);
00205       this->_M_deallocate_block();
00206       this->_M_reset(__new_start, __new_finish, __new_start + __len);
00207     }
00208     else {
00209       const _CharT* __f1 = __first;
00210       ++__f1;
00211       _STLP_PRIV __ucopy(__f1, __last, this->_M_finish + 1);
00212       _M_construct_null(this->_M_finish + __n);
00213       _Traits::assign(*end(), *__first);
00214       this->_M_finish += __n;
00215     }
00216   }
00217   return *this;
00218 }
00219 
00220 template <class _CharT, class _Traits, class _Alloc>
00221 basic_string<_CharT,_Traits,_Alloc>&
00222 basic_string<_CharT,_Traits,_Alloc>::assign(size_type __n, _CharT __c) {
00223   if (__n <= size()) {
00224     _Traits::assign(this->_M_Start(), __n, __c);
00225     erase(begin() + __n, end());
00226   }
00227   else {
00228     if (__n < capacity()) {
00229       _Traits::assign(this->_M_Start(), size(), __c);
00230       append(__n - size(), __c);
00231     }
00232     else {
00233       _Self __str(__n, __c);
00234       this->swap(__str);
00235     }
00236   }
00237   return *this;
00238 }
00239 
00240 template <class _CharT, class _Traits, class _Alloc>
00241 basic_string<_CharT,_Traits,_Alloc>&
00242 basic_string<_CharT,_Traits,_Alloc>::_M_assign(const _CharT* __f, const _CharT* __l) {
00243   ptrdiff_t __n = __l - __f;
00244   if (__STATIC_CAST(size_type, __n) <= size()) {
00245     _Traits::copy(this->_M_Start(), __f, __n);
00246     erase(begin() + __n, end());
00247   }
00248   else {
00249     _Traits::copy(this->_M_Start(), __f, size());
00250     _M_append(__f + size(), __l);
00251   }
00252   return *this;
00253 }
00254 
00255 template <class _CharT, class _Traits, class _Alloc>
00256 _CharT* basic_string<_CharT,_Traits,_Alloc> ::_M_insert_aux(_CharT* __p,
00257                                                             _CharT __c) {
00258   pointer __new_pos = __p;
00259   if (this->_M_rest() > 1 ) {
00260     _M_construct_null(this->_M_finish + 1);
00261     _Traits::move(__p + 1, __p, this->_M_finish - __p);
00262     _Traits::assign(*__p, __c);
00263     ++this->_M_finish;
00264   }
00265   else {
00266     size_type __len = _M_compute_next_size(1);
00267     pointer __new_start = this->_M_start_of_storage.allocate(__len, __len);
00268     __new_pos = _STLP_PRIV __ucopy(this->_M_Start(), __p, __new_start);
00269     _Traits::assign(*__new_pos, __c);
00270     pointer __new_finish = __new_pos + 1;
00271     __new_finish = _STLP_PRIV __ucopy(__p, this->_M_finish, __new_finish);
00272     _M_construct_null(__new_finish);
00273     this->_M_deallocate_block();
00274     this->_M_reset(__new_start, __new_finish, __new_start + __len);
00275   }
00276   return __new_pos;
00277 }
00278 
00279 template <class _CharT, class _Traits, class _Alloc>
00280 void basic_string<_CharT,_Traits,_Alloc>::insert(iterator __pos,
00281                                                  size_t __n, _CharT __c) {
00282   if (__n != 0) {
00283     if (this->_M_rest() > __n) {
00284       const size_type __elems_after = this->_M_finish - __pos;
00285       pointer __old_finish = this->_M_finish;
00286       if (__elems_after >= __n) {
00287         _STLP_PRIV __ucopy((this->_M_finish - __n) + 1, this->_M_finish + 1, this->_M_finish + 1);
00288         this->_M_finish += __n;
00289         _Traits::move(__pos + __n, __pos, (__elems_after - __n) + 1);
00290         _Traits::assign(__pos, __n, __c);
00291       }
00292       else {
00293         _STLP_PRIV __uninitialized_fill_n(this->_M_finish + 1, __n - __elems_after - 1, __c);
00294         this->_M_finish += __n - __elems_after;
00295         _STLP_PRIV __ucopy(__pos, __old_finish + 1, this->_M_finish);
00296         this->_M_finish += __elems_after;
00297         _Traits::assign(__pos, __elems_after + 1, __c);
00298       }
00299     }
00300     else {
00301       size_type __len = _M_compute_next_size(__n);
00302       pointer __new_start = this->_M_start_of_storage.allocate(__len, __len);
00303       pointer __new_finish = _STLP_PRIV __ucopy(this->_M_Start(), __pos, __new_start);
00304       __new_finish = _STLP_PRIV __uninitialized_fill_n(__new_finish, __n, __c);
00305       __new_finish = _STLP_PRIV __ucopy(__pos, this->_M_finish, __new_finish);
00306       _M_construct_null(__new_finish);
00307       this->_M_deallocate_block();
00308       this->_M_reset(__new_start, __new_finish, __new_start + __len);
00309     }
00310   }
00311 }
00312 
00313 template <class _CharT, class _Traits, class _Alloc>
00314 void basic_string<_CharT,_Traits,_Alloc>::_M_insert(iterator __pos,
00315                                                     const _CharT* __first, const _CharT* __last,
00316                                                     bool __self_ref) {
00317   //this version has to take care about the auto referencing
00318   if (__first != __last) {
00319     const size_t __n = __last - __first;
00320     if (this->_M_rest() > __n) {
00321       const size_t __elems_after = this->_M_finish - __pos;
00322       pointer __old_finish = this->_M_finish;
00323       if (__elems_after >= __n) {
00324         _STLP_PRIV __ucopy((this->_M_finish - __n) + 1, this->_M_finish + 1, this->_M_finish + 1);
00325         this->_M_finish += __n;
00326         _Traits::move(__pos + __n, __pos, (__elems_after - __n) + 1);
00327         if (!__self_ref || __last < __pos) {
00328           _M_copy(__first, __last, __pos);
00329         }
00330         else {
00331           //We have to check that the source buffer hasn't move
00332           if (__first >= __pos) {
00333             //The source buffer has move
00334             __first += __n;
00335             __last += __n;
00336             _M_copy(__first, __last, __pos);
00337           }
00338           else {
00339             //The source buffer hasn't move, it has been duplicated
00340             _M_move(__first, __last, __pos);
00341           }
00342         }
00343       }
00344       else {
00345         const_iterator __mid = __first;
00346         __mid += __elems_after + 1;
00347         _STLP_PRIV __ucopy(__mid, __last, this->_M_finish + 1);
00348         this->_M_finish += __n - __elems_after;
00349         _STLP_PRIV __ucopy(__pos, __old_finish + 1, this->_M_finish);
00350         this->_M_finish += __elems_after;
00351         if (!__self_ref)
00352           _M_copy(__first, __mid, __pos);
00353         else
00354           _M_move(__first, __mid, __pos);
00355       }
00356     }
00357     else {
00358       size_type __len = _M_compute_next_size(__n);
00359       pointer __new_start = this->_M_start_of_storage.allocate(__len, __len);
00360       pointer __new_finish = _STLP_PRIV __ucopy(this->_M_Start(), __pos, __new_start);
00361       __new_finish = _STLP_PRIV __ucopy(__first, __last, __new_finish);
00362       __new_finish = _STLP_PRIV __ucopy(__pos, this->_M_finish, __new_finish);
00363       _M_construct_null(__new_finish);
00364       this->_M_deallocate_block();
00365       this->_M_reset(__new_start, __new_finish, __new_start + __len);
00366     }
00367   }
00368 }
00369 
00370 template <class _CharT, class _Traits, class _Alloc>
00371 basic_string<_CharT,_Traits,_Alloc>&
00372 basic_string<_CharT,_Traits,_Alloc> ::replace(iterator __first, iterator __last,
00373                                               size_type __n, _CharT __c) {
00374   size_type __len = (size_type)(__last - __first);
00375 
00376   if (__len >= __n) {
00377     _Traits::assign(__first, __n, __c);
00378     erase(__first + __n, __last);
00379   }
00380   else {
00381     _Traits::assign(__first, __len, __c);
00382     insert(__last, __n - __len, __c);
00383   }
00384   return *this;
00385 }
00386 
00387 template <class _CharT, class _Traits, class _Alloc>
00388 basic_string<_CharT,_Traits,_Alloc>&
00389 basic_string<_CharT,_Traits,_Alloc> ::_M_replace(iterator __first, iterator __last,
00390                                                  const _CharT* __f, const _CharT* __l,
00391                                                  bool __self_ref) {
00392   const ptrdiff_t       __n = __l - __f;
00393   const difference_type __len = __last - __first;
00394   if (__len >= __n) {
00395     if (!__self_ref || __l < __first || __f >= __last)
00396       _M_copy(__f, __l, __first);
00397     else
00398       _M_move(__f, __l, __first);
00399     erase(__first + __n, __last);
00400   } else if (!__self_ref || (__f >= __last) || (__l <= __first)) { // no overlap
00401     const_iterator __m = __f + __len;
00402     _M_copy(__f, __m, __first);
00403     _M_insert(__last, __m, __l, __self_ref );
00404   } else if (__f < __first) { // we have to take care of overlaping
00405     const_iterator __m = __f + __len;
00406     // We have to deal with possible reallocation because we do insert first.
00407     const difference_type __off_dest = __first - this->begin();
00408     const difference_type __off_src = __f - this->begin();
00409     _M_insert(__last, __m, __l, true);
00410     _Traits::move(begin() + __off_dest, begin() + __off_src, __len);
00411   } else {
00412     const_iterator __m = __f + __len;
00413     _Traits::move(__first, __f, __len);
00414     _M_insert(__last, __m, __l, true);
00415   }
00416   return *this;
00417 }
00418 
00419 template <class _CharT, class _Traits, class _Alloc>
00420 __size_type__ basic_string<_CharT,_Traits,_Alloc>::find( const _CharT* __s, size_type __pos,
00421                                                          size_type __n) const
00422 {
00423   const size_t __len = size();
00424   if (__pos >= __len || __pos + __n > __len) {
00425     if ( __n == 0 && __pos <= __len ) { // marginal case
00426       return __pos;
00427     }
00428     return npos;
00429   }
00430 
00431   const_pointer __result =
00432     _STLP_STD::search(this->_M_Start() + __pos, this->_M_Finish(),
00433                       __s, __s + __n, _STLP_PRIV _Eq_traits<_Traits>());
00434   return __result != this->_M_Finish() ? __result - this->_M_Start() : npos;
00435 }
00436 
00437 template <class _CharT, class _Traits, class _Alloc>
00438 __size_type__ basic_string<_CharT,_Traits,_Alloc>::find(_CharT __c, size_type __pos) const
00439 {
00440   if (__pos >= size()) { /*__pos + 1 > size()*/
00441     return npos;
00442   }
00443 
00444   const_pointer __result =
00445     _STLP_STD::find_if(this->_M_Start() + __pos, this->_M_Finish(),
00446                        _STLP_PRIV _Eq_char_bound<_Traits>(__c));
00447   return __result != this->_M_Finish() ? __result - this->_M_Start() : npos;
00448 }
00449 
00450 template <class _CharT, class _Traits, class _Alloc>
00451 __size_type__ basic_string<_CharT,_Traits,_Alloc>::rfind(const _CharT* __s, size_type __pos,
00452                                                          size_type __n) const
00453 {
00454   const size_type __len = size();
00455   if ( __len < __n ) {
00456     return npos;
00457   }
00458   const_pointer __last = this->_M_Start() + (min)( __len - __n, __pos) + __n;
00459   if ( __n == 0 ) { // marginal case
00460     return __last - this->_M_Start();
00461   }
00462   const_pointer __result = _STLP_STD::find_end(this->_M_Start(), __last,
00463                                                __s, __s + __n, _STLP_PRIV _Eq_traits<_Traits>());
00464   return __result != __last ? __result - this->_M_Start() : npos;
00465 }
00466 
00467 template <class _CharT, class _Traits, class _Alloc>
00468 __size_type__ basic_string<_CharT,_Traits,_Alloc>::rfind(_CharT __c, size_type __pos) const
00469 {
00470   const size_type __len = size();
00471   if ( __len < 1 ) {
00472     return npos;
00473   }
00474   const_iterator __last = begin() + (min)(__len - 1, __pos) + 1;
00475   const_reverse_iterator __rresult =
00476     _STLP_STD::find_if(const_reverse_iterator(__last), rend(),
00477                        _STLP_PRIV _Eq_char_bound<_Traits>(__c));
00478   return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;
00479 }
00480 
00481 template <class _CharT, class _Traits, class _Alloc> __size_type__
00482 basic_string<_CharT,_Traits,_Alloc> ::find_first_of(const _CharT* __s, size_type __pos,
00483                                                     size_type __n) const {
00484   if (__pos >= size()) /*__pos + 1 > size()*/
00485     return npos;
00486   else {
00487     const_iterator __result = _STLP_PRIV __str_find_first_of(begin() + __pos, end(),
00488                                                              __s, __s + __n,
00489                                                              __STATIC_CAST(_Traits*, 0));
00490     return __result != end() ? __result - begin() : npos;
00491   }
00492 }
00493 
00494 template <class _CharT, class _Traits, class _Alloc>
00495  __size_type__
00496 basic_string<_CharT,_Traits,_Alloc> ::find_last_of(const _CharT* __s, size_type __pos,
00497                                                    size_type __n) const
00498 {
00499   const size_type __len = size();
00500   if ( __len < 1 ) {
00501     return npos;
00502   }
00503   const const_iterator __last = begin() + (min)(__len - 1, __pos) + 1;
00504   const const_reverse_iterator __rresult =
00505     _STLP_PRIV __str_find_first_of(const_reverse_iterator(__last), rend(),
00506                                    __s, __s + __n,
00507                                    __STATIC_CAST(_Traits*, 0));
00508   return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;
00509 }
00510 
00511 
00512 template <class _CharT, class _Traits, class _Alloc> __size_type__
00513 basic_string<_CharT,_Traits,_Alloc> ::find_first_not_of(const _CharT* __s, size_type __pos,
00514                                                         size_type __n) const {
00515   typedef typename _Traits::char_type _CharType;
00516   if (__pos >= size()) /*__pos + 1 >= size()*/
00517     return npos;
00518   else {
00519     const_pointer __result = _STLP_PRIV __str_find_first_not_of(this->_M_Start() + __pos, this->_M_Finish(),
00520                                                                 __STATIC_CAST(const _CharType*, __s),
00521                                                                 __STATIC_CAST(const _CharType*, __s) + __n,
00522                                                                 __STATIC_CAST(_Traits*, 0));
00523     return __result != this->_M_finish ? __result - this->_M_Start() : npos;
00524   }
00525 }
00526 
00527 template <class _CharT, class _Traits, class _Alloc> __size_type__
00528 basic_string<_CharT,_Traits,_Alloc> ::find_first_not_of(_CharT __c, size_type __pos) const {
00529   if (1 > size())
00530     return npos;
00531   else {
00532     const_pointer __result = _STLP_STD::find_if(this->_M_Start() + __pos, this->_M_Finish(),
00533                                                 _STLP_PRIV _Neq_char_bound<_Traits>(__c));
00534     return __result != this->_M_finish ? __result - this->_M_Start() : npos;
00535   }
00536 }
00537 
00538 template <class _CharT, class _Traits, class _Alloc>
00539 __size_type__
00540 basic_string<_CharT,_Traits,_Alloc>::find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
00541 {
00542   typedef typename _Traits::char_type _CharType;
00543   const size_type __len = size();
00544   if ( __len < 1 ) {
00545     return npos;
00546   }
00547   const_iterator __last = begin() + (min)(__len - 1, __pos) + 1;
00548   const_reverse_iterator __rlast = const_reverse_iterator(__last);
00549   const_reverse_iterator __rresult =
00550     _STLP_PRIV __str_find_first_not_of(__rlast, rend(),
00551                                        __STATIC_CAST(const _CharType*, __s),
00552                                        __STATIC_CAST(const _CharType*, __s) + __n,
00553                                        __STATIC_CAST(_Traits*, 0));
00554   return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;
00555 }
00556 
00557 template <class _CharT, class _Traits, class _Alloc>
00558 __size_type__
00559 basic_string<_CharT, _Traits, _Alloc>::find_last_not_of(_CharT __c, size_type __pos) const
00560 {
00561   const size_type __len = size();
00562   if ( __len < 1 ) {
00563     return npos;
00564   }
00565   const_iterator __last = begin() + (min)(__len - 1, __pos) + 1;
00566   const_reverse_iterator __rlast = const_reverse_iterator(__last);
00567   const_reverse_iterator __rresult =
00568     _STLP_STD::find_if(__rlast, rend(),
00569                        _STLP_PRIV _Neq_char_bound<_Traits>(__c));
00570   return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;
00571 }
00572 
00573 #if !defined (basic_string)
00574 _STLP_MOVE_TO_PRIV_NAMESPACE
00575 #endif
00576 
00577 template <class _CharT, class _Traits, class _Alloc>
00578 void _STLP_CALL _S_string_copy(const basic_string<_CharT,_Traits,_Alloc>& __s,
00579                                _CharT* __buf, size_t __n) {
00580   if (__n > 0) {
00581     __n = (min) (__n - 1, __s.size());
00582     _STLP_STD::copy(__s.begin(), __s.begin() + __n, __buf);
00583     __buf[__n] = _CharT();
00584   }
00585 }
00586 
00587 _STLP_MOVE_TO_STD_NAMESPACE
00588 
00589 _STLP_END_NAMESPACE
00590 
00591 #include <stl/_range_errors.h>
00592 
00593 _STLP_BEGIN_NAMESPACE
00594 
00595 _STLP_MOVE_TO_PRIV_NAMESPACE
00596 
00597 // _String_base methods
00598 template <class _Tp, class _Alloc>
00599 void _String_base<_Tp,_Alloc>::_M_throw_length_error() const
00600 { __stl_throw_length_error("basic_string"); }
00601 
00602 template <class _Tp, class _Alloc>
00603 void _String_base<_Tp, _Alloc>::_M_throw_out_of_range() const
00604 { __stl_throw_out_of_range("basic_string"); }
00605 
00606 template <class _Tp, class _Alloc>
00607 void _String_base<_Tp, _Alloc>::_M_allocate_block(size_t __n) {
00608   if ((__n <= (max_size() + 1)) && (__n > 0)) {
00609 #if defined (_STLP_USE_SHORT_STRING_OPTIM)
00610     if (__n > _DEFAULT_SIZE) {
00611       this->_M_start_of_storage._M_data = _M_start_of_storage.allocate(__n, __n);
00612       this->_M_finish = this->_M_start_of_storage._M_data;
00613       this->_M_buffers._M_end_of_storage = this->_M_start_of_storage._M_data + __n;
00614     }
00615 #else
00616     this->_M_start_of_storage._M_data = _M_start_of_storage.allocate(__n, __n);
00617     this->_M_finish = this->_M_start_of_storage._M_data;
00618     this->_M_end_of_storage = this->_M_start_of_storage._M_data + __n;
00619 #endif
00620   } else {
00621     this->_M_throw_length_error();
00622   }
00623 }
00624 
00625 #if !defined (basic_string)
00626 _STLP_MOVE_TO_STD_NAMESPACE
00627 #endif
00628 
00629 #if defined (_STLP_DONT_SUP_DFLT_PARAM)
00630 template <class _CharT, class _Traits, class _Alloc>
00631 basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT* __s)
00632   : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) {
00633   _STLP_FIX_LITERAL_BUG(__s)
00634   _M_range_initialize(__s, __s + traits_type::length(__s));
00635 }
00636 #endif
00637 
00638 template <class _CharT, class _Traits, class _Alloc>
00639 basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT* __s,
00640                                                     const allocator_type& __a)
00641   : _STLP_PRIV _String_base<_CharT,_Alloc>(__a) {
00642   _STLP_FIX_LITERAL_BUG(__s)
00643   _M_range_initialize(__s, __s + traits_type::length(__s));
00644 }
00645 
00646 template <class _CharT, class _Traits, class _Alloc>
00647 basic_string<_CharT, _Traits, _Alloc>::basic_string(const basic_string<_CharT, _Traits, _Alloc> & __s)
00648   : _STLP_PRIV _String_base<_CharT,_Alloc>(__s.get_allocator())
00649 { _M_range_initialize(__s._M_Start(), __s._M_Finish()); }
00650 
00651 #if defined (basic_string)
00652 _STLP_MOVE_TO_STD_NAMESPACE
00653 #  undef basic_string
00654 #endif
00655 
00656 #if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION)
00657 template <class _CharT, class _Traits, class _Alloc>
00658 const size_t basic_string<_CharT, _Traits, _Alloc>::npos;
00659 #endif
00660 
00661 _STLP_END_NAMESPACE
00662 
00663 #undef __size_type__
00664 #if defined (_STLP_NESTED_TYPE_PARAM_BUG)
00665 #  undef size_type
00666 #  undef iterator
00667 #endif
00668 
00669 #endif /*  _STLP_STRING_C */
00670 
00671 // Local Variables:
00672 // mode:C++
00673 // End:

Generated on Thu May 24 2012 04:30:11 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.