epoc32/include/stdapis/stlport/stl/_string.c
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 /*
     2  *  © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
     3  *
     4  * Copyright (c) 1994
     5  * Hewlett-Packard Company
     6  *
     7  * Copyright (c) 1996,1997
     8  * Silicon Graphics Computer Systems, Inc.
     9  *
    10  * Copyright (c) 1997
    11  * Moscow Center for SPARC Technology
    12  *
    13  * Copyright (c) 1999 
    14  * Boris Fomitchev
    15  *
    16  * This material is provided "as is", with absolutely no warranty expressed
    17  * or implied. Any use is at your own risk.
    18  *
    19  * Permission to use or copy this software for any purpose is hereby granted 
    20  * without fee, provided the above notices are retained on all copies.
    21  * Permission to modify the code and to distribute modified code is granted,
    22  * provided the above notices are retained, and a notice that the code was
    23  * modified is included with the above copyright notice.
    24  *
    25  */
    26 #ifndef _STLP_STRING_C
    27 #define _STLP_STRING_C
    28 
    29 #ifndef _STLP_STRING_H
    30 # include <stl/_string.h>
    31 #endif
    32 
    33 # ifdef _STLP_DEBUG
    34 #  define basic_string _Nondebug_string
    35 # endif
    36 
    37 # if defined (_STLP_USE_OWN_NAMESPACE) || !defined (_STLP_USE_NATIVE_STRING)
    38 
    39 # if defined (_STLP_NESTED_TYPE_PARAM_BUG)
    40 #  define __size_type__ size_t
    41 #  define size_type size_t
    42 #  define iterator   _CharT*
    43 # else
    44 #  define __size_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_string<_CharT,_Traits,_Alloc>::size_type
    45 # endif
    46 
    47 _STLP_BEGIN_NAMESPACE
    48 
    49 // ------------------------------------------------------------
    50 // Non-inline declarations.
    51 
    52 
    53 // Change the string's capacity so that it is large enough to hold
    54 //  at least __res_arg elements, plus the terminating _CharT().  Note that,
    55 //  if __res_arg < capacity(), this member function may actually decrease
    56 //  the string's capacity.
    57 template <class _CharT, class _Traits, class _Alloc> 
    58 _STLP_EXP_DECLSPEC void basic_string<_CharT,_Traits,_Alloc>::reserve(size_type __res_arg) {
    59 
    60   if (__res_arg >= capacity())
    61     {      
    62       if (__res_arg > max_size())
    63 	this->_M_throw_length_error();
    64 
    65       size_type __n = __res_arg + 1;
    66       _STLP_LEAVE_VOLATILE pointer __new_start = this->_M_end_of_storage.allocate(__n);
    67       _STLP_LEAVE_VOLATILE pointer __new_finish = __new_start;
    68       
    69       _STLP_TRY {
    70 	__new_finish = uninitialized_copy(this->_M_start, this->_M_finish, __new_start);
    71 	_M_construct_null(__new_finish);
    72       }
    73       _STLP_UNWIND((_STLP_STD::_Destroy(__new_start, __new_finish), 
    74 		    this->_M_end_of_storage.deallocate(__new_start, __n)));
    75       
    76       _STLP_STD::_Destroy(this->_M_start, this->_M_finish + 1);
    77       this->_M_deallocate_block();
    78       this->_M_start = __new_start;
    79       this->_M_finish = __new_finish;
    80       this->_M_end_of_storage._M_data = __new_start + __n;
    81     }
    82 }
    83 
    84 template <class _CharT, class _Traits, class _Alloc> 
    85 _STLP_EXP_DECLSPEC basic_string<_CharT,_Traits,_Alloc>& 
    86 basic_string<_CharT,_Traits,_Alloc>::append(size_type __n, _CharT __c) 
    87 {
    88   if (__n > max_size() || size() > max_size() - __n)
    89     this->_M_throw_length_error();
    90   if (size() + __n > capacity())
    91     reserve(size() + (max)(size(), __n));
    92   if (__n > 0) {
    93     uninitialized_fill_n(this->_M_finish + 1, __n - 1, __c);
    94     _STLP_TRY {
    95       _M_construct_null(this->_M_finish + __n);
    96     }
    97     _STLP_UNWIND(_STLP_STD::_Destroy(this->_M_finish + 1, this->_M_finish + __n));
    98     _Traits::assign(*end(), __c);
    99     this->_M_finish += __n;
   100   }
   101   return *this;
   102 }
   103 
   104 #ifndef _STLP_MEMBER_TEMPLATES
   105 
   106 template <class _CharT, class _Traits, class _Alloc> 
   107 _STLP_EXP_DECLSPEC basic_string<_CharT, _Traits, _Alloc>& 
   108 basic_string<_CharT, _Traits, _Alloc>::append(const _CharT* __first,
   109 					      const _CharT* __last)
   110 {
   111   if (__first != __last) {
   112     const size_type __old_size = size();
   113     ptrdiff_t __n = __last - __first;
   114     if ((size_type)__n > max_size() || __old_size > max_size() - __n)
   115       this->_M_throw_length_error();
   116     if (__old_size + __n > capacity()) {
   117       const size_type __len = __old_size + (max)(__old_size, (size_t) __n) + 1;
   118       pointer __new_start = this->_M_end_of_storage.allocate(__len);
   119       _STLP_LEAVE_VOLATILE pointer __new_finish = __new_start;
   120       _STLP_TRY {
   121         __new_finish = uninitialized_copy(this->_M_start, this->_M_finish, __new_start);
   122         __new_finish = uninitialized_copy(__first, __last, __new_finish);
   123         _M_construct_null(__new_finish);
   124       }
   125       _STLP_UNWIND((_STLP_STD::_Destroy(__new_start,__new_finish),
   126                     this->_M_end_of_storage.deallocate(__new_start,__len)));
   127       _STLP_STD::_Destroy(this->_M_start, this->_M_finish + 1);
   128       this->_M_deallocate_block();
   129       this->_M_start = __new_start;
   130       this->_M_finish = __new_finish;
   131       this->_M_end_of_storage._M_data = __new_start + __len; 
   132     }
   133     else {
   134       const _CharT* __f1 = __first;
   135       ++__f1;
   136       uninitialized_copy(__f1, __last, this->_M_finish + 1);
   137       _STLP_TRY {
   138         _M_construct_null(this->_M_finish + __n);
   139       }
   140       _STLP_UNWIND(_STLP_STD::_Destroy(this->_M_finish + 1, this->_M_finish + __n));
   141       _Traits::assign(*end(), *__first);
   142       this->_M_finish += __n;
   143     }
   144   }
   145   return *this;  
   146 }
   147 
   148 #endif /* _STLP_MEMBER_TEMPLATES */
   149 
   150 template <class _CharT, class _Traits, class _Alloc> 
   151 _STLP_EXP_DECLSPEC basic_string<_CharT,_Traits,_Alloc>& 
   152 basic_string<_CharT,_Traits,_Alloc>::assign(size_type __n, _CharT __c) {
   153   if (__n <= size()) {
   154     _Traits::assign(this->_M_start, __n, __c);
   155     erase(begin() + __n, end());
   156   }
   157   else {
   158     _Traits::assign(this->_M_start, size(), __c);
   159     append(__n - size(), __c);
   160   }
   161   return *this;
   162 }
   163 
   164 template <class _CharT, class _Traits, class _Alloc> 
   165 _CharT* basic_string<_CharT,_Traits,_Alloc> ::_M_insert_aux(_CharT* __p,
   166                   _CharT __c)
   167 {
   168   pointer __new_pos = __p;
   169   if (this->_M_finish + 1 < this->_M_end_of_storage._M_data) {
   170     _M_construct_null(this->_M_finish + 1);
   171     _Traits::move(__p + 1, __p, this->_M_finish - __p);
   172     _Traits::assign(*__p, __c);
   173     ++this->_M_finish;
   174   }
   175   else {
   176     const size_type __old_len = size();
   177     const size_type __len = __old_len +
   178                             (max)(__old_len, __STATIC_CAST(size_type,1)) + 1;
   179     pointer __new_start = this->_M_end_of_storage.allocate(__len);
   180     _STLP_LEAVE_VOLATILE pointer __new_finish = __new_start;
   181     _STLP_TRY {
   182       __new_pos = uninitialized_copy(this->_M_start, __p, __new_start);
   183       _Construct(__new_pos, __c);
   184       __new_finish = __new_pos + 1;
   185       __new_finish = uninitialized_copy(__p, this->_M_finish, __new_finish);
   186       _M_construct_null(__new_finish);
   187     }
   188     _STLP_UNWIND((_STLP_STD::_Destroy(__new_start,__new_finish), 
   189                   this->_M_end_of_storage.deallocate(__new_start,__len)));
   190     _STLP_STD::_Destroy(this->_M_start, this->_M_finish + 1);
   191     this->_M_deallocate_block();
   192     this->_M_start = __new_start;
   193     this->_M_finish = __new_finish;
   194     this->_M_end_of_storage._M_data = __new_start + __len;
   195   }
   196   return __new_pos;
   197 }
   198 
   199 template <class _CharT, class _Traits, class _Alloc> 
   200 _STLP_EXP_DECLSPEC void basic_string<_CharT,_Traits,_Alloc>::insert(iterator __position,
   201            size_t __n, _CharT __c)
   202 {
   203   if (__n != 0) {
   204     if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n + 1) {
   205       const size_type __elems_after = this->_M_finish - __position;
   206       pointer __old_finish = this->_M_finish;
   207       if (__elems_after >= __n) {
   208         uninitialized_copy((this->_M_finish - __n) + 1, this->_M_finish + 1,
   209                            this->_M_finish + 1);
   210         this->_M_finish += __n;
   211         _Traits::move(__position + __n,
   212                       __position, (__elems_after - __n) + 1);
   213         _Traits::assign(__position, __n, __c);
   214       }
   215       else {
   216         uninitialized_fill_n(this->_M_finish + 1, __n - __elems_after - 1, __c);
   217         this->_M_finish += __n - __elems_after;
   218         _STLP_TRY {
   219           uninitialized_copy(__position, __old_finish + 1, this->_M_finish);
   220           this->_M_finish += __elems_after;
   221         }
   222         _STLP_UNWIND((_STLP_STD::_Destroy(__old_finish + 1, this->_M_finish), 
   223                       this->_M_finish = __old_finish));
   224         _Traits::assign(__position, __elems_after + 1, __c);
   225       }
   226     }
   227     else {
   228       const size_type __old_size = size();        
   229       const size_type __len = __old_size + (max)(__old_size, __n) + 1;
   230       pointer __new_start = this->_M_end_of_storage.allocate(__len);
   231       _STLP_LEAVE_VOLATILE pointer __new_finish = __new_start;
   232       _STLP_TRY {
   233         __new_finish = uninitialized_copy(this->_M_start, __position, __new_start);
   234         __new_finish = uninitialized_fill_n(__new_finish, __n, __c);
   235         __new_finish = uninitialized_copy(__position, this->_M_finish,
   236                                           __new_finish);
   237         _M_construct_null(__new_finish);
   238       }
   239       _STLP_UNWIND((_STLP_STD::_Destroy(__new_start,__new_finish),
   240                     this->_M_end_of_storage.deallocate(__new_start,__len)));
   241       _STLP_STD::_Destroy(this->_M_start, this->_M_finish + 1);
   242       this->_M_deallocate_block();
   243       this->_M_start = __new_start;
   244       this->_M_finish = __new_finish;
   245       this->_M_end_of_storage._M_data = __new_start + __len;    
   246     }
   247   }
   248 }
   249 
   250 #ifndef _STLP_MEMBER_TEMPLATES
   251 
   252 template <class _CharT, class _Traits, class _Alloc> 
   253 _STLP_EXP_DECLSPEC void 
   254 basic_string<_CharT,_Traits,_Alloc>::insert(iterator __position,
   255                                             const _CharT* __first, 
   256                                             const _CharT* __last)
   257 {
   258   if (__first != __last) {
   259     const ptrdiff_t __n = __last - __first;
   260     if (this->_M_end_of_storage._M_data - this->_M_finish >= __n + 1) {
   261       const ptrdiff_t __elems_after = this->_M_finish - __position;
   262       pointer __old_finish = this->_M_finish;
   263       if (__elems_after >= __n) {
   264         uninitialized_copy((this->_M_finish - __n) + 1, this->_M_finish + 1,
   265                            this->_M_finish + 1);
   266         this->_M_finish += __n;
   267         _Traits::move(__position + __n,
   268                       __position, (__elems_after - __n) + 1);
   269         _M_copy(__first, __last, __position);
   270       }
   271       else {
   272         const _CharT* __mid = __first;
   273         advance(__mid, __elems_after + 1);
   274         uninitialized_copy(__mid, __last, this->_M_finish + 1);
   275         this->_M_finish += __n - __elems_after;
   276         _STLP_TRY {
   277           uninitialized_copy(__position, __old_finish + 1, this->_M_finish);
   278           this->_M_finish += __elems_after;
   279         }
   280         _STLP_UNWIND((_STLP_STD::_Destroy(__old_finish + 1, this->_M_finish), 
   281                       this->_M_finish = __old_finish));
   282         _M_copy(__first, __mid, __position);
   283       }
   284     }
   285     else {
   286       size_type __old_size = size();        
   287       size_type __len
   288         = __old_size + (max)(__old_size, __STATIC_CAST(const size_type,__n)) + 1;
   289       pointer __new_start = this->_M_end_of_storage.allocate(__len);
   290       _STLP_LEAVE_VOLATILE pointer __new_finish = __new_start;
   291       _STLP_TRY {
   292         __new_finish = uninitialized_copy(this->_M_start, __position, __new_start);
   293         __new_finish = uninitialized_copy(__first, __last, __new_finish);
   294         __new_finish
   295           = uninitialized_copy(__position, this->_M_finish, __new_finish);
   296         _M_construct_null(__new_finish);
   297       }
   298       _STLP_UNWIND((_STLP_STD::_Destroy(__new_start,__new_finish),
   299                     this->_M_end_of_storage.deallocate(__new_start,__len)));
   300       _STLP_STD::_Destroy(this->_M_start, this->_M_finish + 1);
   301       this->_M_deallocate_block();
   302       this->_M_start = __new_start;
   303       this->_M_finish = __new_finish;
   304       this->_M_end_of_storage._M_data = __new_start + __len; 
   305     }
   306   }
   307 }
   308 
   309 #endif /* _STLP_MEMBER_TEMPLATES */
   310 
   311 template <class _CharT, class _Traits, class _Alloc> 
   312 _STLP_EXP_DECLSPEC basic_string<_CharT,_Traits,_Alloc>& 
   313 basic_string<_CharT,_Traits,_Alloc>::replace(iterator __first, iterator __last, size_type __n, _CharT __c)
   314 {
   315   size_type __len = (size_type)(__last - __first);
   316   
   317   if (__len >= __n) {
   318     _Traits::assign(__first, __n, __c);
   319     erase(__first + __n, __last);
   320   }
   321   else {
   322     _Traits::assign(__first, __len, __c);
   323     insert(__last, __n - __len, __c);
   324   }
   325   return *this;
   326 }
   327 
   328 #ifndef _STLP_MEMBER_TEMPLATES
   329 
   330 
   331 template <class _CharT, class _Traits, class _Alloc> 
   332 _STLP_EXP_DECLSPEC basic_string<_CharT,_Traits,_Alloc>& 
   333 basic_string<_CharT,_Traits,_Alloc> ::replace(iterator __first, iterator __last,
   334             const _CharT* __f, const _CharT* __l)
   335 {
   336   const ptrdiff_t         __n = __l - __f;
   337   const difference_type __len = __last - __first;
   338   if (__len >= __n) {
   339     _M_copy(__f, __l, __first);
   340     erase(__first + __n, __last);
   341   }
   342   else {
   343     const _CharT* __m = __f + __len;
   344     _M_copy(__f, __m, __first);
   345     insert(__last, __m, __l);
   346   }
   347   return *this;
   348 }
   349 
   350 #endif /* _STLP_MEMBER_TEMPLATES */
   351 
   352 template <class _CharT, class _Traits, class _Alloc> 
   353 _STLP_EXP_DECLSPEC __size_type__
   354 basic_string<_CharT,_Traits,_Alloc> ::find(const _CharT* __s, size_type __pos, size_type __n) const 
   355 {
   356 #ifndef __SYMBIAN32__ // A different implementation without using search
   357   if (__pos + __n > size())
   358     return npos;
   359   else {
   360     const const_pointer __result =
   361       _STLP_STD::search((const _CharT*)this->_M_start + __pos, (const _CharT*)this->_M_finish, 
   362 			__s, __s + __n, _Eq_traits<_Traits>());
   363     return __result != this->_M_finish ? __result - this->_M_start : npos;
   364   }
   365 #else
   366   const size_type __len = this->size();
   367   size_t __tpos = __pos;
   368   const _CharT* __data = this->_M_start;
   369   while (__tpos + __n <= __len) {
   370     if (traits_type::compare(__data + __tpos, __s, __n) == 0)
   371       return __tpos;
   372     ++__tpos;
   373   }
   374   return npos;  
   375 #endif //__SYMBIAN32__  
   376 }
   377 
   378 template <class _CharT, class _Traits, class _Alloc> 
   379 _STLP_EXP_DECLSPEC __size_type__
   380 basic_string<_CharT,_Traits,_Alloc> ::find(_CharT __c, size_type __pos) const 
   381 {
   382   if (__pos >= size())
   383     return npos;
   384   else {
   385     const const_pointer __result =
   386       _STLP_STD::find_if((const _CharT*)this->_M_start + __pos, (const _CharT*)this->_M_finish,
   387 			 _Eq_char_bound<_Traits>(__c));
   388     return __result != this->_M_finish ? __result - this->_M_start : npos;
   389   }
   390 }    
   391 
   392 template <class _CharT, class _Traits, class _Alloc> 
   393 _STLP_EXP_DECLSPEC __size_type__
   394 basic_string<_CharT,_Traits,_Alloc> ::rfind(const _CharT* __s, size_type __pos, size_type __n) const 
   395 {
   396   const size_t __len = size();
   397 
   398   if (__n > __len)
   399     return npos;
   400   else if (__n == 0)
   401     return (min) (__len, __pos);
   402   else {
   403     const_pointer __last = this->_M_start + (min) (__len - __n, __pos) + __n;
   404     const_pointer __result = _STLP_STD::find_end((const_pointer)this->_M_start, __last,
   405 						 __s, __s + __n,
   406 						 _Eq_traits<_Traits>());
   407     return __result != __last ? __result - this->_M_start : npos;
   408   }
   409 }
   410 
   411 template <class _CharT, class _Traits, class _Alloc> 
   412 _STLP_EXP_DECLSPEC __size_type__
   413 basic_string<_CharT,_Traits,_Alloc> ::rfind(_CharT __c, size_type __pos) const 
   414 {
   415   const size_type __len = size();
   416 
   417   if (__len < 1)
   418     return npos;
   419   else {
   420     const const_iterator __last = begin() + (min) (__len - 1, __pos) + 1;
   421     const_reverse_iterator __rresult =
   422       _STLP_STD::find_if(const_reverse_iterator(__last), rend(),
   423               _Eq_char_bound<_Traits>(__c));
   424     return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;
   425   }
   426 }
   427 
   428 template <class _CharT, class _Traits, class _Alloc> 
   429 _STLP_EXP_DECLSPEC __size_type__
   430 basic_string<_CharT,_Traits,_Alloc> 
   431     ::find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
   432 {
   433   if (__pos >= size())
   434     return npos;
   435   else {
   436     const_iterator __result = __find_first_of(begin() + __pos, end(),
   437                                               __s, __s + __n,
   438                                               _Eq_traits<_Traits>());
   439     return __result != end() ? __result - begin() : npos;
   440   }
   441 }
   442 
   443 
   444 template <class _CharT, class _Traits, class _Alloc> 
   445 _STLP_EXP_DECLSPEC __size_type__
   446 basic_string<_CharT,_Traits,_Alloc> 
   447     ::find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
   448 {
   449   const size_type __len = size();
   450 
   451   if (__len < 1)
   452     return npos;
   453   else {
   454     const const_iterator __last = begin() + (min) (__len - 1, __pos) + 1;
   455     const const_reverse_iterator __rresult =
   456       __find_first_of(const_reverse_iterator(__last), rend(),
   457                       __s, __s + __n,
   458                       _Eq_traits<_Traits>());
   459     return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;
   460   }
   461 }
   462 
   463 
   464 template <class _CharT, class _Traits, class _Alloc> 
   465 _STLP_EXP_DECLSPEC __size_type__
   466 basic_string<_CharT,_Traits,_Alloc> ::find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
   467 {
   468   typedef typename _Traits::char_type _CharType;
   469   if (__pos > size())
   470     return npos;
   471   else {
   472     const_pointer __result = _STLP_STD::find_if((const _CharT*)this->_M_start + __pos, 
   473 				      (const _CharT*)this->_M_finish,
   474                                 _Not_within_traits<_Traits>((const _CharType*)__s, 
   475 							    (const _CharType*)__s + __n));
   476     return __result != this->_M_finish ? __result - this->_M_start : npos;
   477   }
   478 }
   479 
   480 template <class _CharT, class _Traits, class _Alloc> 
   481 _STLP_EXP_DECLSPEC __size_type__
   482 basic_string<_CharT,_Traits,_Alloc> ::find_first_not_of(_CharT __c, size_type __pos) const
   483 {
   484   if (__pos > size())
   485     return npos;
   486   else {
   487     const_pointer __result = _STLP_STD::find_if((const _CharT*)this->_M_start + __pos, (const _CharT*)this->_M_finish,
   488 						_Neq_char_bound<_Traits>(__c));
   489     return __result != this->_M_finish ? __result - this->_M_start : npos;
   490   }
   491 }    
   492 
   493 template <class _CharT, class _Traits, class _Alloc> 
   494 _STLP_EXP_DECLSPEC __size_type__
   495 basic_string<_CharT,_Traits,_Alloc> ::find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const 
   496 {
   497   typedef typename _Traits::char_type _CharType;
   498   const size_type __len = size();
   499 
   500   if (__len < 1)
   501     return npos;
   502   else {
   503     const_iterator __last = begin() + (min) (__len - 1, __pos) + 1;
   504     const_reverse_iterator __rlast = const_reverse_iterator(__last);
   505     const_reverse_iterator __rresult =
   506       _STLP_STD::find_if(__rlast, rend(),
   507 			 _Not_within_traits<_Traits>((const _CharType*)__s, 
   508 						     (const _CharType*)__s + __n));
   509     return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;
   510   }
   511 }
   512 
   513 template <class _CharT, class _Traits, class _Alloc> 
   514 _STLP_EXP_DECLSPEC __size_type__
   515 basic_string<_CharT, _Traits, _Alloc> ::find_last_not_of(_CharT __c, size_type __pos) const 
   516 {
   517   const size_type __len = size();
   518 
   519   if (__len < 1)
   520     return npos;
   521   else {
   522     const_iterator __last = begin() + (min) (__len - 1, __pos) + 1;
   523     const_reverse_iterator __rlast = const_reverse_iterator(__last);
   524     const_reverse_iterator __rresult =
   525       _STLP_STD::find_if(__rlast, rend(),
   526 			 _Neq_char_bound<_Traits>(__c));
   527     return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;
   528   }
   529 }
   530 
   531 template <class _CharT, class _Traits, class _Alloc> 
   532 void _STLP_CALL _S_string_copy(const basic_string<_CharT,_Traits,_Alloc>& __s,
   533                     _CharT* __buf,
   534                     size_t __n)
   535 {
   536   if (__n > 0) {
   537     __n = (min) (__n - 1, __s.size());
   538     _STLP_STD::copy(__s.begin(), __s.begin() + __n, __buf);
   539     __buf[__n] = _CharT();
   540   }
   541 }
   542 _STLP_END_NAMESPACE
   543 
   544 // _string_fwd has to see clean basic_string
   545 # undef basic_string
   546 
   547 # if !defined (_STLP_LINK_TIME_INSTANTIATION)
   548 #  include <stl/_string_fwd.c> 
   549 # endif
   550 
   551 # ifdef _STLP_DEBUG
   552 #  define basic_string _Nondebug_string
   553 # endif
   554 
   555 # include <stl/_range_errors.h>  
   556 _STLP_BEGIN_NAMESPACE
   557 
   558 // _String_base methods
   559 template <class _Tp, class _Alloc> 
   560 void _String_base<_Tp,_Alloc>::_M_throw_length_error() const {
   561     __stl_throw_length_error("basic_string");
   562 }
   563 
   564 template <class _Tp, class _Alloc> 
   565 void _String_base<_Tp, _Alloc>::_M_throw_out_of_range() const {
   566     __stl_throw_out_of_range("basic_string");
   567 }
   568 
   569 template <class _Tp, class _Alloc> 
   570 void _String_base<_Tp, _Alloc>::_M_allocate_block(size_t __n) {  
   571   if ((__n <= (max_size()+1)) && (__n>0)){ 
   572     _M_start  = _M_end_of_storage.allocate(__n); 
   573     _M_finish = _M_start; 
   574     _M_end_of_storage._M_data = _M_start + __n; 
   575   } 
   576     else 
   577       _M_throw_length_error(); 
   578 } 
   579  
   580 template <class _CharT, class _Traits, class _Alloc> 
   581 _STLP_EXP_DECLSPEC basic_string<_CharT, _Traits, _Alloc>::basic_string()
   582   : _String_base<_CharT,_Alloc>(allocator_type()) 
   583 {  
   584   this->_M_start = this->_M_end_of_storage.allocate(8); 
   585   this->_M_finish = this->_M_start; 
   586   this->_M_end_of_storage._M_data = this->_M_start + 8; 
   587   _M_terminate_string();  
   588   _STLP_POP_CLEANUP_ITEM
   589 } 
   590 
   591 
   592 template <class _CharT, class _Traits, class _Alloc> 
   593 _STLP_EXP_DECLSPEC basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT* __s, 
   594 						    const allocator_type& __a) 
   595   : _String_base<_CharT,_Alloc>(__a)  
   596 { 
   597   _STLP_FIX_LITERAL_BUG(__s) 
   598     _M_range_initialize(__s, __s + traits_type::length(__s));  
   599   _STLP_POP_CLEANUP_ITEM
   600 } 
   601 
   602 
   603 template <class _CharT, class _Traits, class _Alloc> 
   604 _STLP_EXP_DECLSPEC basic_string<_CharT, _Traits, _Alloc>::basic_string(const basic_string<_CharT, _Traits, _Alloc> & __s)  
   605   : _String_base<_CharT,_Alloc>(__s.get_allocator())  
   606 {  
   607   _M_range_initialize(__s._M_start, __s._M_finish);  
   608   _STLP_POP_CLEANUP_ITEM
   609 } 
   610   
   611 # if defined ( __SUNPRO_CC) && ! defined(_STLP_STATIC_CONST_INIT_BUG)
   612 template <class _CharT, class _Traits, class _Alloc> const size_t basic_string<_CharT, _Traits, _Alloc>::npos;
   613 # endif
   614 
   615 _STLP_END_NAMESPACE
   616 
   617 # undef basic_string
   618 # undef __size_type__
   619 # undef size_type
   620 # undef iterator
   621 # endif /* NATIVE */
   622 
   623 #endif /*  _STLP_STRING_C */
   624 
   625 // Local Variables:
   626 // mode:C++
   627 // End: