1.1 --- a/epoc32/include/stdapis/stlport/stl/_string.c Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stlport/stl/_string.c Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,627 @@
1.4 -_string.c
1.5 +/*
1.6 + * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
1.7 + *
1.8 + * Copyright (c) 1994
1.9 + * Hewlett-Packard Company
1.10 + *
1.11 + * Copyright (c) 1996,1997
1.12 + * Silicon Graphics Computer Systems, Inc.
1.13 + *
1.14 + * Copyright (c) 1997
1.15 + * Moscow Center for SPARC Technology
1.16 + *
1.17 + * Copyright (c) 1999
1.18 + * Boris Fomitchev
1.19 + *
1.20 + * This material is provided "as is", with absolutely no warranty expressed
1.21 + * or implied. Any use is at your own risk.
1.22 + *
1.23 + * Permission to use or copy this software for any purpose is hereby granted
1.24 + * without fee, provided the above notices are retained on all copies.
1.25 + * Permission to modify the code and to distribute modified code is granted,
1.26 + * provided the above notices are retained, and a notice that the code was
1.27 + * modified is included with the above copyright notice.
1.28 + *
1.29 + */
1.30 +#ifndef _STLP_STRING_C
1.31 +#define _STLP_STRING_C
1.32 +
1.33 +#ifndef _STLP_STRING_H
1.34 +# include <stl/_string.h>
1.35 +#endif
1.36 +
1.37 +# ifdef _STLP_DEBUG
1.38 +# define basic_string _Nondebug_string
1.39 +# endif
1.40 +
1.41 +# if defined (_STLP_USE_OWN_NAMESPACE) || !defined (_STLP_USE_NATIVE_STRING)
1.42 +
1.43 +# if defined (_STLP_NESTED_TYPE_PARAM_BUG)
1.44 +# define __size_type__ size_t
1.45 +# define size_type size_t
1.46 +# define iterator _CharT*
1.47 +# else
1.48 +# define __size_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_string<_CharT,_Traits,_Alloc>::size_type
1.49 +# endif
1.50 +
1.51 +_STLP_BEGIN_NAMESPACE
1.52 +
1.53 +// ------------------------------------------------------------
1.54 +// Non-inline declarations.
1.55 +
1.56 +
1.57 +// Change the string's capacity so that it is large enough to hold
1.58 +// at least __res_arg elements, plus the terminating _CharT(). Note that,
1.59 +// if __res_arg < capacity(), this member function may actually decrease
1.60 +// the string's capacity.
1.61 +template <class _CharT, class _Traits, class _Alloc>
1.62 +_STLP_EXP_DECLSPEC void basic_string<_CharT,_Traits,_Alloc>::reserve(size_type __res_arg) {
1.63 +
1.64 + if (__res_arg >= capacity())
1.65 + {
1.66 + if (__res_arg > max_size())
1.67 + this->_M_throw_length_error();
1.68 +
1.69 + size_type __n = __res_arg + 1;
1.70 + _STLP_LEAVE_VOLATILE pointer __new_start = this->_M_end_of_storage.allocate(__n);
1.71 + _STLP_LEAVE_VOLATILE pointer __new_finish = __new_start;
1.72 +
1.73 + _STLP_TRY {
1.74 + __new_finish = uninitialized_copy(this->_M_start, this->_M_finish, __new_start);
1.75 + _M_construct_null(__new_finish);
1.76 + }
1.77 + _STLP_UNWIND((_STLP_STD::_Destroy(__new_start, __new_finish),
1.78 + this->_M_end_of_storage.deallocate(__new_start, __n)));
1.79 +
1.80 + _STLP_STD::_Destroy(this->_M_start, this->_M_finish + 1);
1.81 + this->_M_deallocate_block();
1.82 + this->_M_start = __new_start;
1.83 + this->_M_finish = __new_finish;
1.84 + this->_M_end_of_storage._M_data = __new_start + __n;
1.85 + }
1.86 +}
1.87 +
1.88 +template <class _CharT, class _Traits, class _Alloc>
1.89 +_STLP_EXP_DECLSPEC basic_string<_CharT,_Traits,_Alloc>&
1.90 +basic_string<_CharT,_Traits,_Alloc>::append(size_type __n, _CharT __c)
1.91 +{
1.92 + if (__n > max_size() || size() > max_size() - __n)
1.93 + this->_M_throw_length_error();
1.94 + if (size() + __n > capacity())
1.95 + reserve(size() + (max)(size(), __n));
1.96 + if (__n > 0) {
1.97 + uninitialized_fill_n(this->_M_finish + 1, __n - 1, __c);
1.98 + _STLP_TRY {
1.99 + _M_construct_null(this->_M_finish + __n);
1.100 + }
1.101 + _STLP_UNWIND(_STLP_STD::_Destroy(this->_M_finish + 1, this->_M_finish + __n));
1.102 + _Traits::assign(*end(), __c);
1.103 + this->_M_finish += __n;
1.104 + }
1.105 + return *this;
1.106 +}
1.107 +
1.108 +#ifndef _STLP_MEMBER_TEMPLATES
1.109 +
1.110 +template <class _CharT, class _Traits, class _Alloc>
1.111 +_STLP_EXP_DECLSPEC basic_string<_CharT, _Traits, _Alloc>&
1.112 +basic_string<_CharT, _Traits, _Alloc>::append(const _CharT* __first,
1.113 + const _CharT* __last)
1.114 +{
1.115 + if (__first != __last) {
1.116 + const size_type __old_size = size();
1.117 + ptrdiff_t __n = __last - __first;
1.118 + if ((size_type)__n > max_size() || __old_size > max_size() - __n)
1.119 + this->_M_throw_length_error();
1.120 + if (__old_size + __n > capacity()) {
1.121 + const size_type __len = __old_size + (max)(__old_size, (size_t) __n) + 1;
1.122 + pointer __new_start = this->_M_end_of_storage.allocate(__len);
1.123 + _STLP_LEAVE_VOLATILE pointer __new_finish = __new_start;
1.124 + _STLP_TRY {
1.125 + __new_finish = uninitialized_copy(this->_M_start, this->_M_finish, __new_start);
1.126 + __new_finish = uninitialized_copy(__first, __last, __new_finish);
1.127 + _M_construct_null(__new_finish);
1.128 + }
1.129 + _STLP_UNWIND((_STLP_STD::_Destroy(__new_start,__new_finish),
1.130 + this->_M_end_of_storage.deallocate(__new_start,__len)));
1.131 + _STLP_STD::_Destroy(this->_M_start, this->_M_finish + 1);
1.132 + this->_M_deallocate_block();
1.133 + this->_M_start = __new_start;
1.134 + this->_M_finish = __new_finish;
1.135 + this->_M_end_of_storage._M_data = __new_start + __len;
1.136 + }
1.137 + else {
1.138 + const _CharT* __f1 = __first;
1.139 + ++__f1;
1.140 + uninitialized_copy(__f1, __last, this->_M_finish + 1);
1.141 + _STLP_TRY {
1.142 + _M_construct_null(this->_M_finish + __n);
1.143 + }
1.144 + _STLP_UNWIND(_STLP_STD::_Destroy(this->_M_finish + 1, this->_M_finish + __n));
1.145 + _Traits::assign(*end(), *__first);
1.146 + this->_M_finish += __n;
1.147 + }
1.148 + }
1.149 + return *this;
1.150 +}
1.151 +
1.152 +#endif /* _STLP_MEMBER_TEMPLATES */
1.153 +
1.154 +template <class _CharT, class _Traits, class _Alloc>
1.155 +_STLP_EXP_DECLSPEC basic_string<_CharT,_Traits,_Alloc>&
1.156 +basic_string<_CharT,_Traits,_Alloc>::assign(size_type __n, _CharT __c) {
1.157 + if (__n <= size()) {
1.158 + _Traits::assign(this->_M_start, __n, __c);
1.159 + erase(begin() + __n, end());
1.160 + }
1.161 + else {
1.162 + _Traits::assign(this->_M_start, size(), __c);
1.163 + append(__n - size(), __c);
1.164 + }
1.165 + return *this;
1.166 +}
1.167 +
1.168 +template <class _CharT, class _Traits, class _Alloc>
1.169 +_CharT* basic_string<_CharT,_Traits,_Alloc> ::_M_insert_aux(_CharT* __p,
1.170 + _CharT __c)
1.171 +{
1.172 + pointer __new_pos = __p;
1.173 + if (this->_M_finish + 1 < this->_M_end_of_storage._M_data) {
1.174 + _M_construct_null(this->_M_finish + 1);
1.175 + _Traits::move(__p + 1, __p, this->_M_finish - __p);
1.176 + _Traits::assign(*__p, __c);
1.177 + ++this->_M_finish;
1.178 + }
1.179 + else {
1.180 + const size_type __old_len = size();
1.181 + const size_type __len = __old_len +
1.182 + (max)(__old_len, __STATIC_CAST(size_type,1)) + 1;
1.183 + pointer __new_start = this->_M_end_of_storage.allocate(__len);
1.184 + _STLP_LEAVE_VOLATILE pointer __new_finish = __new_start;
1.185 + _STLP_TRY {
1.186 + __new_pos = uninitialized_copy(this->_M_start, __p, __new_start);
1.187 + _Construct(__new_pos, __c);
1.188 + __new_finish = __new_pos + 1;
1.189 + __new_finish = uninitialized_copy(__p, this->_M_finish, __new_finish);
1.190 + _M_construct_null(__new_finish);
1.191 + }
1.192 + _STLP_UNWIND((_STLP_STD::_Destroy(__new_start,__new_finish),
1.193 + this->_M_end_of_storage.deallocate(__new_start,__len)));
1.194 + _STLP_STD::_Destroy(this->_M_start, this->_M_finish + 1);
1.195 + this->_M_deallocate_block();
1.196 + this->_M_start = __new_start;
1.197 + this->_M_finish = __new_finish;
1.198 + this->_M_end_of_storage._M_data = __new_start + __len;
1.199 + }
1.200 + return __new_pos;
1.201 +}
1.202 +
1.203 +template <class _CharT, class _Traits, class _Alloc>
1.204 +_STLP_EXP_DECLSPEC void basic_string<_CharT,_Traits,_Alloc>::insert(iterator __position,
1.205 + size_t __n, _CharT __c)
1.206 +{
1.207 + if (__n != 0) {
1.208 + if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n + 1) {
1.209 + const size_type __elems_after = this->_M_finish - __position;
1.210 + pointer __old_finish = this->_M_finish;
1.211 + if (__elems_after >= __n) {
1.212 + uninitialized_copy((this->_M_finish - __n) + 1, this->_M_finish + 1,
1.213 + this->_M_finish + 1);
1.214 + this->_M_finish += __n;
1.215 + _Traits::move(__position + __n,
1.216 + __position, (__elems_after - __n) + 1);
1.217 + _Traits::assign(__position, __n, __c);
1.218 + }
1.219 + else {
1.220 + uninitialized_fill_n(this->_M_finish + 1, __n - __elems_after - 1, __c);
1.221 + this->_M_finish += __n - __elems_after;
1.222 + _STLP_TRY {
1.223 + uninitialized_copy(__position, __old_finish + 1, this->_M_finish);
1.224 + this->_M_finish += __elems_after;
1.225 + }
1.226 + _STLP_UNWIND((_STLP_STD::_Destroy(__old_finish + 1, this->_M_finish),
1.227 + this->_M_finish = __old_finish));
1.228 + _Traits::assign(__position, __elems_after + 1, __c);
1.229 + }
1.230 + }
1.231 + else {
1.232 + const size_type __old_size = size();
1.233 + const size_type __len = __old_size + (max)(__old_size, __n) + 1;
1.234 + pointer __new_start = this->_M_end_of_storage.allocate(__len);
1.235 + _STLP_LEAVE_VOLATILE pointer __new_finish = __new_start;
1.236 + _STLP_TRY {
1.237 + __new_finish = uninitialized_copy(this->_M_start, __position, __new_start);
1.238 + __new_finish = uninitialized_fill_n(__new_finish, __n, __c);
1.239 + __new_finish = uninitialized_copy(__position, this->_M_finish,
1.240 + __new_finish);
1.241 + _M_construct_null(__new_finish);
1.242 + }
1.243 + _STLP_UNWIND((_STLP_STD::_Destroy(__new_start,__new_finish),
1.244 + this->_M_end_of_storage.deallocate(__new_start,__len)));
1.245 + _STLP_STD::_Destroy(this->_M_start, this->_M_finish + 1);
1.246 + this->_M_deallocate_block();
1.247 + this->_M_start = __new_start;
1.248 + this->_M_finish = __new_finish;
1.249 + this->_M_end_of_storage._M_data = __new_start + __len;
1.250 + }
1.251 + }
1.252 +}
1.253 +
1.254 +#ifndef _STLP_MEMBER_TEMPLATES
1.255 +
1.256 +template <class _CharT, class _Traits, class _Alloc>
1.257 +_STLP_EXP_DECLSPEC void
1.258 +basic_string<_CharT,_Traits,_Alloc>::insert(iterator __position,
1.259 + const _CharT* __first,
1.260 + const _CharT* __last)
1.261 +{
1.262 + if (__first != __last) {
1.263 + const ptrdiff_t __n = __last - __first;
1.264 + if (this->_M_end_of_storage._M_data - this->_M_finish >= __n + 1) {
1.265 + const ptrdiff_t __elems_after = this->_M_finish - __position;
1.266 + pointer __old_finish = this->_M_finish;
1.267 + if (__elems_after >= __n) {
1.268 + uninitialized_copy((this->_M_finish - __n) + 1, this->_M_finish + 1,
1.269 + this->_M_finish + 1);
1.270 + this->_M_finish += __n;
1.271 + _Traits::move(__position + __n,
1.272 + __position, (__elems_after - __n) + 1);
1.273 + _M_copy(__first, __last, __position);
1.274 + }
1.275 + else {
1.276 + const _CharT* __mid = __first;
1.277 + advance(__mid, __elems_after + 1);
1.278 + uninitialized_copy(__mid, __last, this->_M_finish + 1);
1.279 + this->_M_finish += __n - __elems_after;
1.280 + _STLP_TRY {
1.281 + uninitialized_copy(__position, __old_finish + 1, this->_M_finish);
1.282 + this->_M_finish += __elems_after;
1.283 + }
1.284 + _STLP_UNWIND((_STLP_STD::_Destroy(__old_finish + 1, this->_M_finish),
1.285 + this->_M_finish = __old_finish));
1.286 + _M_copy(__first, __mid, __position);
1.287 + }
1.288 + }
1.289 + else {
1.290 + size_type __old_size = size();
1.291 + size_type __len
1.292 + = __old_size + (max)(__old_size, __STATIC_CAST(const size_type,__n)) + 1;
1.293 + pointer __new_start = this->_M_end_of_storage.allocate(__len);
1.294 + _STLP_LEAVE_VOLATILE pointer __new_finish = __new_start;
1.295 + _STLP_TRY {
1.296 + __new_finish = uninitialized_copy(this->_M_start, __position, __new_start);
1.297 + __new_finish = uninitialized_copy(__first, __last, __new_finish);
1.298 + __new_finish
1.299 + = uninitialized_copy(__position, this->_M_finish, __new_finish);
1.300 + _M_construct_null(__new_finish);
1.301 + }
1.302 + _STLP_UNWIND((_STLP_STD::_Destroy(__new_start,__new_finish),
1.303 + this->_M_end_of_storage.deallocate(__new_start,__len)));
1.304 + _STLP_STD::_Destroy(this->_M_start, this->_M_finish + 1);
1.305 + this->_M_deallocate_block();
1.306 + this->_M_start = __new_start;
1.307 + this->_M_finish = __new_finish;
1.308 + this->_M_end_of_storage._M_data = __new_start + __len;
1.309 + }
1.310 + }
1.311 +}
1.312 +
1.313 +#endif /* _STLP_MEMBER_TEMPLATES */
1.314 +
1.315 +template <class _CharT, class _Traits, class _Alloc>
1.316 +_STLP_EXP_DECLSPEC basic_string<_CharT,_Traits,_Alloc>&
1.317 +basic_string<_CharT,_Traits,_Alloc>::replace(iterator __first, iterator __last, size_type __n, _CharT __c)
1.318 +{
1.319 + size_type __len = (size_type)(__last - __first);
1.320 +
1.321 + if (__len >= __n) {
1.322 + _Traits::assign(__first, __n, __c);
1.323 + erase(__first + __n, __last);
1.324 + }
1.325 + else {
1.326 + _Traits::assign(__first, __len, __c);
1.327 + insert(__last, __n - __len, __c);
1.328 + }
1.329 + return *this;
1.330 +}
1.331 +
1.332 +#ifndef _STLP_MEMBER_TEMPLATES
1.333 +
1.334 +
1.335 +template <class _CharT, class _Traits, class _Alloc>
1.336 +_STLP_EXP_DECLSPEC basic_string<_CharT,_Traits,_Alloc>&
1.337 +basic_string<_CharT,_Traits,_Alloc> ::replace(iterator __first, iterator __last,
1.338 + const _CharT* __f, const _CharT* __l)
1.339 +{
1.340 + const ptrdiff_t __n = __l - __f;
1.341 + const difference_type __len = __last - __first;
1.342 + if (__len >= __n) {
1.343 + _M_copy(__f, __l, __first);
1.344 + erase(__first + __n, __last);
1.345 + }
1.346 + else {
1.347 + const _CharT* __m = __f + __len;
1.348 + _M_copy(__f, __m, __first);
1.349 + insert(__last, __m, __l);
1.350 + }
1.351 + return *this;
1.352 +}
1.353 +
1.354 +#endif /* _STLP_MEMBER_TEMPLATES */
1.355 +
1.356 +template <class _CharT, class _Traits, class _Alloc>
1.357 +_STLP_EXP_DECLSPEC __size_type__
1.358 +basic_string<_CharT,_Traits,_Alloc> ::find(const _CharT* __s, size_type __pos, size_type __n) const
1.359 +{
1.360 +#ifndef __SYMBIAN32__ // A different implementation without using search
1.361 + if (__pos + __n > size())
1.362 + return npos;
1.363 + else {
1.364 + const const_pointer __result =
1.365 + _STLP_STD::search((const _CharT*)this->_M_start + __pos, (const _CharT*)this->_M_finish,
1.366 + __s, __s + __n, _Eq_traits<_Traits>());
1.367 + return __result != this->_M_finish ? __result - this->_M_start : npos;
1.368 + }
1.369 +#else
1.370 + const size_type __len = this->size();
1.371 + size_t __tpos = __pos;
1.372 + const _CharT* __data = this->_M_start;
1.373 + while (__tpos + __n <= __len) {
1.374 + if (traits_type::compare(__data + __tpos, __s, __n) == 0)
1.375 + return __tpos;
1.376 + ++__tpos;
1.377 + }
1.378 + return npos;
1.379 +#endif //__SYMBIAN32__
1.380 +}
1.381 +
1.382 +template <class _CharT, class _Traits, class _Alloc>
1.383 +_STLP_EXP_DECLSPEC __size_type__
1.384 +basic_string<_CharT,_Traits,_Alloc> ::find(_CharT __c, size_type __pos) const
1.385 +{
1.386 + if (__pos >= size())
1.387 + return npos;
1.388 + else {
1.389 + const const_pointer __result =
1.390 + _STLP_STD::find_if((const _CharT*)this->_M_start + __pos, (const _CharT*)this->_M_finish,
1.391 + _Eq_char_bound<_Traits>(__c));
1.392 + return __result != this->_M_finish ? __result - this->_M_start : npos;
1.393 + }
1.394 +}
1.395 +
1.396 +template <class _CharT, class _Traits, class _Alloc>
1.397 +_STLP_EXP_DECLSPEC __size_type__
1.398 +basic_string<_CharT,_Traits,_Alloc> ::rfind(const _CharT* __s, size_type __pos, size_type __n) const
1.399 +{
1.400 + const size_t __len = size();
1.401 +
1.402 + if (__n > __len)
1.403 + return npos;
1.404 + else if (__n == 0)
1.405 + return (min) (__len, __pos);
1.406 + else {
1.407 + const_pointer __last = this->_M_start + (min) (__len - __n, __pos) + __n;
1.408 + const_pointer __result = _STLP_STD::find_end((const_pointer)this->_M_start, __last,
1.409 + __s, __s + __n,
1.410 + _Eq_traits<_Traits>());
1.411 + return __result != __last ? __result - this->_M_start : npos;
1.412 + }
1.413 +}
1.414 +
1.415 +template <class _CharT, class _Traits, class _Alloc>
1.416 +_STLP_EXP_DECLSPEC __size_type__
1.417 +basic_string<_CharT,_Traits,_Alloc> ::rfind(_CharT __c, size_type __pos) const
1.418 +{
1.419 + const size_type __len = size();
1.420 +
1.421 + if (__len < 1)
1.422 + return npos;
1.423 + else {
1.424 + const const_iterator __last = begin() + (min) (__len - 1, __pos) + 1;
1.425 + const_reverse_iterator __rresult =
1.426 + _STLP_STD::find_if(const_reverse_iterator(__last), rend(),
1.427 + _Eq_char_bound<_Traits>(__c));
1.428 + return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;
1.429 + }
1.430 +}
1.431 +
1.432 +template <class _CharT, class _Traits, class _Alloc>
1.433 +_STLP_EXP_DECLSPEC __size_type__
1.434 +basic_string<_CharT,_Traits,_Alloc>
1.435 + ::find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
1.436 +{
1.437 + if (__pos >= size())
1.438 + return npos;
1.439 + else {
1.440 + const_iterator __result = __find_first_of(begin() + __pos, end(),
1.441 + __s, __s + __n,
1.442 + _Eq_traits<_Traits>());
1.443 + return __result != end() ? __result - begin() : npos;
1.444 + }
1.445 +}
1.446 +
1.447 +
1.448 +template <class _CharT, class _Traits, class _Alloc>
1.449 +_STLP_EXP_DECLSPEC __size_type__
1.450 +basic_string<_CharT,_Traits,_Alloc>
1.451 + ::find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
1.452 +{
1.453 + const size_type __len = size();
1.454 +
1.455 + if (__len < 1)
1.456 + return npos;
1.457 + else {
1.458 + const const_iterator __last = begin() + (min) (__len - 1, __pos) + 1;
1.459 + const const_reverse_iterator __rresult =
1.460 + __find_first_of(const_reverse_iterator(__last), rend(),
1.461 + __s, __s + __n,
1.462 + _Eq_traits<_Traits>());
1.463 + return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;
1.464 + }
1.465 +}
1.466 +
1.467 +
1.468 +template <class _CharT, class _Traits, class _Alloc>
1.469 +_STLP_EXP_DECLSPEC __size_type__
1.470 +basic_string<_CharT,_Traits,_Alloc> ::find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
1.471 +{
1.472 + typedef typename _Traits::char_type _CharType;
1.473 + if (__pos > size())
1.474 + return npos;
1.475 + else {
1.476 + const_pointer __result = _STLP_STD::find_if((const _CharT*)this->_M_start + __pos,
1.477 + (const _CharT*)this->_M_finish,
1.478 + _Not_within_traits<_Traits>((const _CharType*)__s,
1.479 + (const _CharType*)__s + __n));
1.480 + return __result != this->_M_finish ? __result - this->_M_start : npos;
1.481 + }
1.482 +}
1.483 +
1.484 +template <class _CharT, class _Traits, class _Alloc>
1.485 +_STLP_EXP_DECLSPEC __size_type__
1.486 +basic_string<_CharT,_Traits,_Alloc> ::find_first_not_of(_CharT __c, size_type __pos) const
1.487 +{
1.488 + if (__pos > size())
1.489 + return npos;
1.490 + else {
1.491 + const_pointer __result = _STLP_STD::find_if((const _CharT*)this->_M_start + __pos, (const _CharT*)this->_M_finish,
1.492 + _Neq_char_bound<_Traits>(__c));
1.493 + return __result != this->_M_finish ? __result - this->_M_start : npos;
1.494 + }
1.495 +}
1.496 +
1.497 +template <class _CharT, class _Traits, class _Alloc>
1.498 +_STLP_EXP_DECLSPEC __size_type__
1.499 +basic_string<_CharT,_Traits,_Alloc> ::find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
1.500 +{
1.501 + typedef typename _Traits::char_type _CharType;
1.502 + const size_type __len = size();
1.503 +
1.504 + if (__len < 1)
1.505 + return npos;
1.506 + else {
1.507 + const_iterator __last = begin() + (min) (__len - 1, __pos) + 1;
1.508 + const_reverse_iterator __rlast = const_reverse_iterator(__last);
1.509 + const_reverse_iterator __rresult =
1.510 + _STLP_STD::find_if(__rlast, rend(),
1.511 + _Not_within_traits<_Traits>((const _CharType*)__s,
1.512 + (const _CharType*)__s + __n));
1.513 + return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;
1.514 + }
1.515 +}
1.516 +
1.517 +template <class _CharT, class _Traits, class _Alloc>
1.518 +_STLP_EXP_DECLSPEC __size_type__
1.519 +basic_string<_CharT, _Traits, _Alloc> ::find_last_not_of(_CharT __c, size_type __pos) const
1.520 +{
1.521 + const size_type __len = size();
1.522 +
1.523 + if (__len < 1)
1.524 + return npos;
1.525 + else {
1.526 + const_iterator __last = begin() + (min) (__len - 1, __pos) + 1;
1.527 + const_reverse_iterator __rlast = const_reverse_iterator(__last);
1.528 + const_reverse_iterator __rresult =
1.529 + _STLP_STD::find_if(__rlast, rend(),
1.530 + _Neq_char_bound<_Traits>(__c));
1.531 + return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;
1.532 + }
1.533 +}
1.534 +
1.535 +template <class _CharT, class _Traits, class _Alloc>
1.536 +void _STLP_CALL _S_string_copy(const basic_string<_CharT,_Traits,_Alloc>& __s,
1.537 + _CharT* __buf,
1.538 + size_t __n)
1.539 +{
1.540 + if (__n > 0) {
1.541 + __n = (min) (__n - 1, __s.size());
1.542 + _STLP_STD::copy(__s.begin(), __s.begin() + __n, __buf);
1.543 + __buf[__n] = _CharT();
1.544 + }
1.545 +}
1.546 +_STLP_END_NAMESPACE
1.547 +
1.548 +// _string_fwd has to see clean basic_string
1.549 +# undef basic_string
1.550 +
1.551 +# if !defined (_STLP_LINK_TIME_INSTANTIATION)
1.552 +# include <stl/_string_fwd.c>
1.553 +# endif
1.554 +
1.555 +# ifdef _STLP_DEBUG
1.556 +# define basic_string _Nondebug_string
1.557 +# endif
1.558 +
1.559 +# include <stl/_range_errors.h>
1.560 +_STLP_BEGIN_NAMESPACE
1.561 +
1.562 +// _String_base methods
1.563 +template <class _Tp, class _Alloc>
1.564 +void _String_base<_Tp,_Alloc>::_M_throw_length_error() const {
1.565 + __stl_throw_length_error("basic_string");
1.566 +}
1.567 +
1.568 +template <class _Tp, class _Alloc>
1.569 +void _String_base<_Tp, _Alloc>::_M_throw_out_of_range() const {
1.570 + __stl_throw_out_of_range("basic_string");
1.571 +}
1.572 +
1.573 +template <class _Tp, class _Alloc>
1.574 +void _String_base<_Tp, _Alloc>::_M_allocate_block(size_t __n) {
1.575 + if ((__n <= (max_size()+1)) && (__n>0)){
1.576 + _M_start = _M_end_of_storage.allocate(__n);
1.577 + _M_finish = _M_start;
1.578 + _M_end_of_storage._M_data = _M_start + __n;
1.579 + }
1.580 + else
1.581 + _M_throw_length_error();
1.582 +}
1.583 +
1.584 +template <class _CharT, class _Traits, class _Alloc>
1.585 +_STLP_EXP_DECLSPEC basic_string<_CharT, _Traits, _Alloc>::basic_string()
1.586 + : _String_base<_CharT,_Alloc>(allocator_type())
1.587 +{
1.588 + this->_M_start = this->_M_end_of_storage.allocate(8);
1.589 + this->_M_finish = this->_M_start;
1.590 + this->_M_end_of_storage._M_data = this->_M_start + 8;
1.591 + _M_terminate_string();
1.592 + _STLP_POP_CLEANUP_ITEM
1.593 +}
1.594 +
1.595 +
1.596 +template <class _CharT, class _Traits, class _Alloc>
1.597 +_STLP_EXP_DECLSPEC basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT* __s,
1.598 + const allocator_type& __a)
1.599 + : _String_base<_CharT,_Alloc>(__a)
1.600 +{
1.601 + _STLP_FIX_LITERAL_BUG(__s)
1.602 + _M_range_initialize(__s, __s + traits_type::length(__s));
1.603 + _STLP_POP_CLEANUP_ITEM
1.604 +}
1.605 +
1.606 +
1.607 +template <class _CharT, class _Traits, class _Alloc>
1.608 +_STLP_EXP_DECLSPEC basic_string<_CharT, _Traits, _Alloc>::basic_string(const basic_string<_CharT, _Traits, _Alloc> & __s)
1.609 + : _String_base<_CharT,_Alloc>(__s.get_allocator())
1.610 +{
1.611 + _M_range_initialize(__s._M_start, __s._M_finish);
1.612 + _STLP_POP_CLEANUP_ITEM
1.613 +}
1.614 +
1.615 +# if defined ( __SUNPRO_CC) && ! defined(_STLP_STATIC_CONST_INIT_BUG)
1.616 +template <class _CharT, class _Traits, class _Alloc> const size_t basic_string<_CharT, _Traits, _Alloc>::npos;
1.617 +# endif
1.618 +
1.619 +_STLP_END_NAMESPACE
1.620 +
1.621 +# undef basic_string
1.622 +# undef __size_type__
1.623 +# undef size_type
1.624 +# undef iterator
1.625 +# endif /* NATIVE */
1.626 +
1.627 +#endif /* _STLP_STRING_C */
1.628 +
1.629 +// Local Variables:
1.630 +// mode:C++
1.631 +// End: