27#ifndef _STLP_INTERNAL_STRING_H
31#ifndef _STLP_INTERNAL_CTRAITS_FUNCTIONS_H
35#ifndef _STLP_INTERNAL_FUNCTION_H
39#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
40# define basic_string _STLP_NO_MEM_T_NAME(str)
41#elif defined (_STLP_DEBUG)
42# define basic_string _STLP_NON_DBG_NAME(str)
45#if defined (_STLP_NESTED_TYPE_PARAM_BUG)
46# define __size_type__ size_t
47# define size_type size_t
48# define iterator _CharT*
50# define __size_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_string<_CharT,_Traits,_Alloc>::size_type
58template <
class _Traits>
60 typedef typename _Traits::char_type
_CharT;
73template <
class _InputIter,
class _CharT,
class _Traits>
75 const _CharT* __first2,
const _CharT* __last2,
79template <
class _InputIter,
class _CharT,
class _Traits>
81 const _CharT* __first2,
const _CharT* __last2,
85template <
class _InputIter,
class _CharT,
class _Traits>
87 const _CharT* __first2,
const _CharT* __last2,
89#if !defined (__BORLANDC__)
98template <
class _InputIter,
class _CharT,
class _Traits>
100 const _CharT* __first2,
const _CharT* __last2,
101 _Traits* ,
const __true_type& __useStrcspnLikeAlgo)
104template <
class _InputIter,
class _CharT,
class _Traits>
106 const _CharT* __first2,
const _CharT* __last2,
110template <
class _InputIter,
class _CharT,
class _Tp,
class _Traits>
112 const _CharT* __first2,
const _CharT* __last2,
113 _Tp* __pt, _Traits* __traits) {
120template <
class _InputIter,
class _CharT,
class _Traits>
122 const _CharT* __first2,
const _CharT* __last2,
127template <
class _InputIter,
class _CharT,
class _Traits>
129 const _CharT* __first2,
const _CharT* __last2,
133template <
class _InputIter,
class _CharT,
class _Traits>
135 const _CharT* __first2,
const _CharT* __last2,
137#if !defined (__BORLANDC__)
149#if !defined (basic_string)
157template <
class _CharT,
class _Traits,
class _Alloc>
160 this->_M_throw_length_error();
163 if (__n < this->_M_capacity())
169template <
class _CharT,
class _Traits,
class _Alloc>
171 pointer __new_start = this->_M_start_of_storage.allocate(
__n,
__n);
173 _M_construct_null(__new_finish);
174 this->_M_deallocate_block();
175 this->_M_reset(__new_start, __new_finish, __new_start +
__n);
178template <
class _CharT,
class _Traits,
class _Alloc>
183 this->_M_throw_length_error();
184 if (
__n >= this->_M_rest())
185 _M_reserve(_M_compute_next_size(
__n));
187 _M_construct_null(this->_M_finish +
__n);
188 _Traits::assign(*
end(),
__c);
189 this->_M_finish +=
__n;
194template <
class _CharT,
class _Traits,
class _Alloc>
199 if (
__n >= this->_M_rest()) {
201 pointer __new_start = this->_M_start_of_storage.allocate(__len, __len);
204 _M_construct_null(__new_finish);
205 this->_M_deallocate_block();
206 this->_M_reset(__new_start, __new_finish, __new_start + __len);
209 const _CharT* __f1 = __first;
212 _M_construct_null(this->_M_finish +
__n);
213 _Traits::assign(*
end(), *__first);
214 this->_M_finish +=
__n;
220template <
class _CharT,
class _Traits,
class _Alloc>
224 _Traits::assign(this->_M_Start(),
__n,
__c);
228 if (
__n < capacity()) {
229 _Traits::assign(this->_M_Start(),
size(),
__c);
240template <
class _CharT,
class _Traits,
class _Alloc>
245 _Traits::copy(this->_M_Start(), __f,
__n);
249 _Traits::copy(this->_M_Start(), __f,
size());
250 _M_append(__f +
size(), __l);
255template <
class _CharT,
class _Traits,
class _Alloc>
259 if (this->_M_rest() > 1 ) {
260 _M_construct_null(this->_M_finish + 1);
261 _Traits::move(__p + 1, __p, this->_M_finish - __p);
262 _Traits::assign(*__p,
__c);
266 size_type __len = _M_compute_next_size(1);
267 pointer __new_start = this->_M_start_of_storage.allocate(__len, __len);
269 _Traits::assign(*__new_pos,
__c);
270 pointer __new_finish = __new_pos + 1;
272 _M_construct_null(__new_finish);
273 this->_M_deallocate_block();
274 this->_M_reset(__new_start, __new_finish, __new_start + __len);
279template <
class _CharT,
class _Traits,
class _Alloc>
283 if (this->_M_rest() >
__n) {
284 const size_type __elems_after = this->_M_finish - __pos;
285 pointer __old_finish = this->_M_finish;
286 if (__elems_after >=
__n) {
288 this->_M_finish +=
__n;
289 _Traits::move(__pos +
__n, __pos, (__elems_after -
__n) + 1);
290 _Traits::assign(__pos,
__n,
__c);
294 this->_M_finish +=
__n - __elems_after;
296 this->_M_finish += __elems_after;
297 _Traits::assign(__pos, __elems_after + 1,
__c);
302 pointer __new_start = this->_M_start_of_storage.allocate(__len, __len);
306 _M_construct_null(__new_finish);
307 this->_M_deallocate_block();
308 this->_M_reset(__new_start, __new_finish, __new_start + __len);
313template <
class _CharT,
class _Traits,
class _Alloc>
315 const _CharT* __first,
const _CharT*
__last,
320 if (this->_M_rest() >
__n) {
321 const size_t __elems_after = this->_M_finish - __pos;
322 pointer __old_finish = this->_M_finish;
323 if (__elems_after >=
__n) {
325 this->_M_finish +=
__n;
326 _Traits::move(__pos +
__n, __pos, (__elems_after -
__n) + 1);
327 if (!__self_ref ||
__last < __pos) {
328 _M_copy(__first,
__last, __pos);
332 if (__first >= __pos) {
336 _M_copy(__first,
__last, __pos);
340 _M_move(__first,
__last, __pos);
345 const_iterator __mid = __first;
346 __mid += __elems_after + 1;
348 this->_M_finish +=
__n - __elems_after;
350 this->_M_finish += __elems_after;
352 _M_copy(__first, __mid, __pos);
354 _M_move(__first, __mid, __pos);
358 size_type __len = _M_compute_next_size(
__n);
359 pointer __new_start = this->_M_start_of_storage.allocate(__len, __len);
363 _M_construct_null(__new_finish);
364 this->_M_deallocate_block();
365 this->_M_reset(__new_start, __new_finish, __new_start + __len);
370template <
class _CharT,
class _Traits,
class _Alloc>
377 _Traits::assign(__first,
__n,
__c);
381 _Traits::assign(__first, __len,
__c);
387template <
class _CharT,
class _Traits,
class _Alloc>
390 const _CharT* __f,
const _CharT* __l,
393 const difference_type __len =
__last - __first;
395 if (!__self_ref || __l < __first || __f >=
__last)
396 _M_copy(__f, __l, __first);
398 _M_move(__f, __l, __first);
400 }
else if (!__self_ref || (__f >=
__last) || (__l <= __first)) {
401 const_iterator __m = __f + __len;
402 _M_copy(__f, __m, __first);
403 _M_insert(
__last, __m, __l, __self_ref );
404 }
else if (__f < __first) {
405 const_iterator __m = __f + __len;
407 const difference_type __off_dest = __first - this->
begin();
408 const difference_type __off_src = __f - this->
begin();
409 _M_insert(
__last, __m, __l,
true);
410 _Traits::move(
begin() + __off_dest,
begin() + __off_src, __len);
412 const_iterator __m = __f + __len;
413 _Traits::move(__first, __f, __len);
419template <
class _CharT,
class _Traits,
class _Alloc>
423 const size_t __len =
size();
424 if (__pos >= __len || __pos +
__n > __len) {
425 if (
__n == 0 && __pos <= __len ) {
432 _STLP_STD::search(this->_M_Start() + __pos, this->_M_Finish(),
434 return __result != this->_M_Finish() ? __result - this->_M_Start() :
npos;
437template <
class _CharT,
class _Traits,
class _Alloc>
440 if (__pos >=
size()) {
445 _STLP_STD::find_if(this->_M_Start() + __pos, this->_M_Finish(),
447 return __result != this->_M_Finish() ? __result - this->_M_Start() :
npos;
450template <
class _CharT,
class _Traits,
class _Alloc>
458 const_pointer
__last = this->_M_Start() + (
min)( __len -
__n, __pos) +
__n;
460 return __last - this->_M_Start();
462 const_pointer __result = _STLP_STD::find_end(this->_M_Start(),
__last,
464 return __result !=
__last ? __result - this->_M_Start() :
npos;
467template <
class _CharT,
class _Traits,
class _Alloc>
475 const_reverse_iterator __rresult =
476 _STLP_STD::find_if(const_reverse_iterator(
__last), rend(),
478 return __rresult != rend() ? (__rresult.base() - 1) -
begin() :
npos;
481template <
class _CharT,
class _Traits,
class _Alloc>
__size_type__
494template <
class _CharT,
class _Traits,
class _Alloc>
504 const const_reverse_iterator __rresult =
508 return __rresult != rend() ? (__rresult.base() - 1) -
begin() :
npos;
512template <
class _CharT,
class _Traits,
class _Alloc>
__size_type__
515 typedef typename _Traits::char_type _CharType;
523 return __result != this->_M_finish ? __result - this->_M_Start() :
npos;
527template <
class _CharT,
class _Traits,
class _Alloc>
__size_type__
532 const_pointer __result = _STLP_STD::find_if(this->_M_Start() + __pos, this->_M_Finish(),
534 return __result != this->_M_finish ? __result - this->_M_Start() :
npos;
538template <
class _CharT,
class _Traits,
class _Alloc>
542 typedef typename _Traits::char_type _CharType;
548 const_reverse_iterator __rlast = const_reverse_iterator(
__last);
549 const_reverse_iterator __rresult =
554 return __rresult != rend() ? (__rresult.base() - 1) -
begin() :
npos;
557template <
class _CharT,
class _Traits,
class _Alloc>
566 const_reverse_iterator __rlast = const_reverse_iterator(
__last);
567 const_reverse_iterator __rresult =
568 _STLP_STD::find_if(__rlast, rend(),
570 return __rresult != rend() ? (__rresult.base() - 1) -
begin() :
npos;
573#if !defined (basic_string)
577template <
class _CharT,
class _Traits,
class _Alloc>
579 _CharT* __buf,
size_t __n) {
583 __buf[
__n] = _CharT();
598template <
class _Tp,
class _Alloc>
602template <
class _Tp,
class _Alloc>
606template <
class _Tp,
class _Alloc>
609#if defined (_STLP_USE_SHORT_STRING_OPTIM)
610 if (
__n > _DEFAULT_SIZE) {
611 this->_M_start_of_storage._M_data = _M_start_of_storage.allocate(
__n,
__n);
612 this->_M_finish = this->_M_start_of_storage._M_data;
613 this->_M_buffers._M_end_of_storage = this->_M_start_of_storage._M_data +
__n;
616 this->_M_start_of_storage._M_data = _M_start_of_storage.allocate(
__n,
__n);
617 this->_M_finish = this->_M_start_of_storage._M_data;
618 this->_M_end_of_storage = this->_M_start_of_storage._M_data +
__n;
621 this->_M_throw_length_error();
625#if !defined (basic_string)
629#if defined (_STLP_DONT_SUP_DFLT_PARAM)
630template <
class _CharT,
class _Traits,
class _Alloc>
634 _M_range_initialize(__s, __s + traits_type::length(__s));
638template <
class _CharT,
class _Traits,
class _Alloc>
646template <
class _CharT,
class _Traits,
class _Alloc>
651#if defined (basic_string)
656#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION)
657template <
class _CharT,
class _Traits,
class _Alloc>
664#if defined (_STLP_NESTED_TYPE_PARAM_BUG)
_STLP_INLINE_LOOP _InputIter __last
_InputIter __find_first_of(_InputIter __first1, _InputIter __last1, _ForwardIter __first2, _ForwardIter __last2)
_InputIter __find_first_of_aux2(_InputIter __first1, _InputIter __last1, _ForwardIter __first2, _ForwardIter __last2, _Tp2 *, _Predicate __pred, const __true_type &)
_STLP_MOVE_TO_STD_NAMESPACE _InputIter find_if(_InputIter __first, _InputIter __last, _Predicate __pred)
unary_negate< _Predicate > not1(const _Predicate &__pred)
#define _STLP_VALUE_TYPE(_It, _Tp)
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_out_of_range(const char *__msg)
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_length_error(const char *__msg)
_InputIter __str_find_first_not_of_aux2(_InputIter __first1, _InputIter __last1, const _CharT *__first2, const _CharT *__last2, _Tp *__pt, _Traits *__traits)
_InputIter __str_find_first_not_of_aux3(_InputIter __first1, _InputIter __last1, const _CharT *__first2, const _CharT *__last2, _Traits *, const __true_type &__useStrcspnLikeAlgo)
_STLP_MOVE_TO_PRIV_NAMESPACE void _STLP_CALL _S_string_copy(const basic_string< _CharT, _Traits, _Alloc > &__s, _CharT *__buf, size_t __n)
_InputIter __str_find_first_of_aux(_InputIter __first1, _InputIter __last1, const _CharT *__first2, const _CharT *__last2, _Traits *, const __true_type &)
_InputIter __str_find_first_not_of(_InputIter __first1, _InputIter __last1, const _CharT *__first2, const _CharT *__last2, _Traits *__traits)
_InputIter __str_find_first_of(_InputIter __first1, _InputIter __last1, const _CharT *__first2, const _CharT *__last2, _Traits *__traits)
_InputIter __str_find_first_not_of_aux1(_InputIter __first1, _InputIter __last1, const _CharT *__first2, const _CharT *__last2, _Traits *__traits, const __true_type &)
_STLP_BEGIN_NAMESPACE _STLP_MOVE_TO_PRIV_NAMESPACE _OutputIter __ucopy(_InputIter __first, _InputIter __last, _OutputIter __result, _Distance *)
_ForwardIter __uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp &__x)
void _STLP_FUNCTION_THROWS _M_throw_out_of_range() const
void _M_allocate_block(size_t __n=_DEFAULT_SIZE)
void _STLP_FUNCTION_THROWS _M_throw_length_error() const
_Self & _M_append(const _CharT *__first, const _CharT *__last)
void _M_reserve(size_type)
basic_string(const allocator_type &__a=allocator_type())
_Base::size_type size_type
size_type find_last_not_of(const _Self &__s, size_type __pos=npos) const
const value_type * const_iterator
size_type find(const _Self &__s, size_type __pos=0) const
void reserve(size_type=0)
_Self & assign(const _Self &__s)
const value_type * const_pointer
size_type rfind(const _Self &__s, size_type __pos=npos) const
_Self & insert(size_type __pos, const _Self &__s)
_Base::allocator_type allocator_type
void _M_insert(iterator __p, const _CharT *__f, const _CharT *__l, bool __self_ref)
_Self & append(const _CharT *__first, const _CharT *__last)
_Self & _M_assign(const _CharT *__f, const _CharT *__l)
void _M_range_initialize(_InputIter __f, _InputIter __l, const input_iterator_tag &__tag)
__kernel_ptrdiff_t ptrdiff_t
#define _STLP_MOVE_TO_STD_NAMESPACE
#define __STATIC_CAST(__x, __y)
#define _STLP_FIX_LITERAL_BUG(__x)
#define _STLP_BEGIN_NAMESPACE
#define _STLP_END_NAMESPACE
#define _STLP_MOVE_TO_PRIV_NAMESPACE
GLsizei const GLvoid * pointer
static void append(struct dump_context *dc, const void *data, unsigned size)
_Not_within_traits(const _CharT *__f, const _CharT *__l)
bool operator()(const _CharT &__x) const
_Traits::char_type _CharT