epoc32/include/stdapis/stlportv5/stl/_sstream.c
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/stdapis/stlport/stl/_sstream.c@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     1 /*
     2  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
     3  * Copyright (c) 1999
     4  * Silicon Graphics Computer Systems, Inc.
     5  *
     6  * Copyright (c) 1999 
     7  * Boris Fomitchev
     8  *
     9  * This material is provided "as is", with absolutely no warranty expressed
    10  * or implied. Any use is at your own risk.
    11  *
    12  * Permission to use or copy this software for any purpose is hereby granted 
    13  * without fee, provided the above notices are retained on all copies.
    14  * Permission to modify the code and to distribute modified code is granted,
    15  * provided the above notices are retained, and a notice that the code was
    16  * modified is included with the above copyright notice.
    17  *
    18  */ 
    19 
    20 #ifndef _STLP_SSTREAM_C
    21 #define _STLP_SSTREAM_C
    22 
    23 #ifndef _STLP_SSTREAM_H
    24 # include <stl/_sstream.h>
    25 #include <stl/_stdio_file.h> 
    26 #endif
    27 
    28 # if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
    29 
    30 # if defined ( _STLP_NESTED_TYPE_PARAM_BUG )
    31 // no wint_t is supported for this mode
    32 # define __BSB_int_type__ int
    33 # define __BSB_pos_type__ streampos
    34 # else
    35 # define __BSB_int_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
    36 # define __BSB_pos_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
    37 # endif
    38 
    39 _STLP_BEGIN_NAMESPACE
    40 
    41 //----------------------------------------------------------------------
    42 // Non-inline stringbuf member functions.
    43 
    44 // Constructors.  Note that the base class constructor sets all of the
    45 // get and area pointers to null.
    46 
    47 template <class _CharT, class _Traits, class _Alloc>
    48 _STLP_EXP_DECLSPEC basic_stringbuf<_CharT, _Traits, _Alloc>
    49   ::basic_stringbuf(ios_base::openmode __mode)
    50     : basic_streambuf<_CharT, _Traits>(), _M_mode(__mode), _M_str()
    51 {
    52 #ifdef __SYMBIAN32__
    53 if (_M_mode & ios_base::out) {
    54    if (_M_mode & (ios_base::app | ios_base::ate))
    55        //increment the streampos to reflect the current streampos while writing
    56        _M_str._M_stream_pos += _M_str.size();
    57 }
    58 #endif
    59 }
    60 
    61 template <class _CharT, class _Traits, class _Alloc>
    62 _STLP_EXP_DECLSPEC basic_stringbuf<_CharT, _Traits, _Alloc>
    63   ::basic_stringbuf(const basic_string<_CharT, _Traits, _Alloc>& __s, ios_base::openmode __mode)
    64     : basic_streambuf<_CharT, _Traits>(), _M_mode(__mode), _M_str(__s)
    65 {
    66 #ifdef __SYMBIAN32__
    67 if (_M_mode & ios_base::out) {
    68    if (_M_mode & (ios_base::app | ios_base::ate))
    69      //increment the streampos to reflect the current streampos while writing
    70      _M_str._M_stream_pos += _M_str.size();
    71 }
    72 #endif
    73   _M_set_ptrs();
    74 }
    75 
    76 template <class _CharT, class _Traits, class _Alloc>
    77 _STLP_EXP_DECLSPEC basic_stringbuf<_CharT, _Traits, _Alloc>::~basic_stringbuf()
    78 {}
    79 
    80 // Set the underlying string to a new value.
    81 template <class _CharT, class _Traits, class _Alloc>
    82 _STLP_EXP_DECLSPEC void 
    83 basic_stringbuf<_CharT, _Traits, _Alloc>::str(const basic_string<_CharT, _Traits, _Alloc>& __s)
    84 {
    85   _M_str = __s;
    86   _M_set_ptrs();
    87 }
    88 
    89 template <class _CharT, class _Traits, class _Alloc>
    90 void 
    91 basic_stringbuf<_CharT, _Traits, _Alloc>::_M_set_ptrs() {
    92   _CharT* __data_ptr = __CONST_CAST(_CharT*,_M_str.data());
    93   _CharT* __data_end = __data_ptr + _M_str.size();
    94   // The initial read position is the beginning of the string.
    95   if (_M_mode & ios_base::in) {
    96     if (_M_mode & ios_base::ate)
    97       this->setg(__data_ptr, __data_end, __data_end);
    98     else
    99       this->setg(__data_ptr, __data_ptr, __data_end);
   100   }
   101   
   102   // The initial write position is the beginning of the string.
   103   if (_M_mode & ios_base::out) {
   104     if (_M_mode & (ios_base::app | ios_base::ate))
   105       this->setp(__data_end, __data_end);
   106     else
   107       this->setp(__data_ptr, __data_end);
   108   }
   109 }
   110 
   111 // Precondition: gptr() >= egptr().  Returns a character, if one is available.
   112 template <class _CharT, class _Traits, class _Alloc>
   113 _STLP_EXP_DECLSPEC __BSB_int_type__
   114 basic_stringbuf<_CharT, _Traits, _Alloc>::underflow()
   115 {
   116   return this->gptr() != this->egptr()
   117     ? _Traits::to_int_type(*this->gptr())
   118     : _Traits::eof();
   119 }
   120 
   121 // Precondition: gptr() >= egptr().
   122 template <class _CharT, class _Traits, class _Alloc>
   123 _STLP_EXP_DECLSPEC __BSB_int_type__
   124 basic_stringbuf<_CharT, _Traits, _Alloc>::uflow()
   125 {
   126   if (this->gptr() != this->egptr()) {
   127     int_type __c = _Traits::to_int_type(*this->gptr());
   128     this->gbump(1);
   129     return __c;
   130   }
   131   else
   132     return _Traits::eof();
   133 }
   134 
   135 template <class _CharT, class _Traits, class _Alloc>
   136 _STLP_EXP_DECLSPEC __BSB_int_type__
   137 basic_stringbuf<_CharT, _Traits, _Alloc>::pbackfail(int_type __c)
   138 {
   139   if (this->gptr() != this->eback()) {
   140     if (!_Traits::eq_int_type(__c, _Traits::eof())) {
   141 
   142 if (_Traits::eq(_Traits::to_char_type(__c), this->gptr()[-1])
   143       		|| _M_mode == (ios_base::in | ios_base::out)) {
   144         this->gbump(-1);
   145       	*this->gptr() = _Traits::to_char_type(__c);
   146       	return _Traits::not_eof(__c);
   147       }
   148       else{
   149 	  	return _Traits::eof();
   150 	  }
   151     }
   152     else {
   153       this->gbump(-1);
   154       return _Traits::not_eof(__c);
   155     }
   156   }
   157 	else
   158     return _Traits::eof();
   159 }
   160 
   161 template <class _CharT, class _Traits, class _Alloc>
   162 _STLP_EXP_DECLSPEC __BSB_int_type__
   163 basic_stringbuf<_CharT, _Traits, _Alloc>::overflow(int_type __c)
   164 {
   165   // fbp : reverse order of "ifs" to pass Dietmar's test.
   166   // Apparently, standard allows overflow with eof even for read-only streams.
   167   if (!_Traits::eq_int_type(__c, _Traits::eof())) {
   168     if (_M_mode & ios_base::out) {
   169       if (!(_M_mode & ios_base::in)) {
   170         // It's a write-only streambuf, so we can use special append buffer.
   171         if (this->pptr() == this->epptr())
   172           this->_M_append_buffer();
   173       
   174         if (this->pptr() != this->epptr()) {
   175           *this->pptr() = _Traits::to_char_type(__c);
   176           this->pbump(1);
   177           return __c;
   178         }
   179         else
   180           return _Traits::eof();
   181       }
   182 
   183       else {
   184         // We're not using a special append buffer, just the string itself.
   185         if (this->pptr() == this->epptr()) {
   186           ptrdiff_t __offset = this->gptr() - this->eback();
   187           _M_str.push_back(_Traits::to_char_type(__c));
   188 
   189 	  _CharT* __data_ptr = __CONST_CAST(_CharT*,_M_str.data());
   190 	  size_t __data_size = _M_str.size();
   191 
   192           this->setg(__data_ptr, __data_ptr + __offset, __data_ptr+__data_size);
   193           this->setp(__data_ptr, __data_ptr + __data_size);
   194           this->pbump((int)__data_size);
   195           return __c;
   196         }
   197         else {
   198           *this->pptr() = _Traits::to_char_type(__c);
   199           this->pbump(1);
   200           return __c;
   201         }
   202       }
   203     }
   204     else                          // Overflow always fails if it's read-only 
   205       return _Traits::eof();
   206   }
   207   else                        // __c is EOF, so we don't have to do anything
   208     return _Traits::not_eof(__c);
   209 }
   210 
   211 template <class _CharT, class _Traits, class _Alloc>
   212 _STLP_EXP_DECLSPEC streamsize 
   213 basic_stringbuf<_CharT, _Traits, _Alloc>::xsputn(const char_type* __s,
   214                                                  streamsize __n)
   215 {
   216   streamsize __nwritten = 0;
   217 
   218   if ((_M_mode & ios_base::out) && __n > 0) {
   219     // If the put pointer is somewhere in the middle of the string,
   220     // then overwrite instead of append.
   221     if (this->pbase() == _M_str.data() ) {
   222       ptrdiff_t __avail = _M_str.data() + _M_str.size() - this->pptr();
   223       if (__avail > __n) {
   224         _Traits::copy(this->pptr(), __s, __n);
   225         this->pbump((int)__n);
   226 #ifdef __SYMBIAN32__
   227    //     _M_str._M_stream_pos += __n; //increment streampos to number of characters in stream
   228 #endif
   229         return __n;
   230       }
   231       else {
   232         _Traits::copy(this->pptr(), __s, __avail);
   233         __nwritten += __avail;
   234         __n -= __avail;
   235         __s += __avail;
   236 #ifdef __SYMBIAN32__
   237   //      _M_str._M_stream_pos += __avail;//increment streampos to number of characters in stream
   238 #endif
   239         this->setp(_M_Buf, _M_Buf + __STATIC_CAST(int,_S_BufSiz));
   240       }
   241     }
   242 
   243     // At this point we know we're appending.
   244     if (_M_mode & ios_base::in) {
   245       ptrdiff_t __get_offset = this->gptr() - this->eback();
   246       _M_str.append(__s, __s + __n);
   247       
   248       _CharT* __data_ptr = __CONST_CAST(_CharT*,_M_str.data());
   249       size_t __data_size = _M_str.size();
   250 
   251       this->setg(__data_ptr, __data_ptr + __get_offset, __data_ptr+__data_size);
   252       this->setp(__data_ptr, __data_ptr + __data_size);
   253       this->pbump((int)__data_size);
   254     }
   255     else {
   256       _M_append_buffer();
   257 #ifdef __SYMBIAN32__      
   258       if (_M_str._M_stream_pos >= 0 
   259           && (_M_str._M_stream_pos < _M_str.size())) {          
   260           if((_M_str.size() - _M_str._M_stream_pos) >= __n)
   261           	_M_str.replace(_M_str._M_stream_pos, __n, __s);          
   262           else
   263           	{
   264           	_M_str.replace(_M_str._M_stream_pos, (_M_str.size() - _M_str._M_stream_pos), __s);
   265           	_M_str.append(__s + (__n - (_M_str.size() - _M_str._M_stream_pos)), __s + __n);
   266           	}
   267       } else {
   268           _M_str.append(__s, __s + __n);
   269       }
   270       _M_str._M_stream_pos += __n;
   271 #else //__SYMBIAN32__      
   272       _M_str.append(__s, __s + __n);
   273 #endif // __SYMBIAN32__      
   274     }
   275     __nwritten += __n;
   276   }
   277 
   278   return __nwritten;
   279 }
   280 
   281 template <class _CharT, class _Traits, class _Alloc>
   282 streamsize 
   283 basic_stringbuf<_CharT, _Traits, _Alloc>::_M_xsputnc(char_type __c,
   284                                                      streamsize __n)
   285 {
   286   streamsize __nwritten = 0;
   287 
   288   if ((_M_mode & ios_base::out) && __n > 0) {
   289     // If the put pointer is somewhere in the middle of the string,
   290     // then overwrite instead of append.
   291     if (this->pbase() == _M_str.data()) {
   292       ptrdiff_t __avail = _M_str.data() + _M_str.size() - this->pptr();
   293       if (__avail > __n) {
   294         _Traits::assign(this->pptr(), __n, __c);
   295         this->pbump((int)__n);
   296         return __n;
   297       }
   298       else {
   299         _Traits::assign(this->pptr(), __avail, __c);
   300         __nwritten += __avail;
   301         __n -= __avail;
   302         this->setp(_M_Buf, _M_Buf + __STATIC_CAST(int,_S_BufSiz));
   303       }
   304     }
   305 
   306     // At this point we know we're appending.
   307     if (this->_M_mode & ios_base::in) {
   308       ptrdiff_t __get_offset = this->gptr() - this->eback();
   309       _M_str.append(__n, __c);
   310 
   311       _CharT* __data_ptr = __CONST_CAST(_CharT*,_M_str.data());
   312       size_t __data_size = _M_str.size();
   313 
   314       this->setg(__data_ptr, __data_ptr + __get_offset, __data_ptr+__data_size);
   315       this->setp(__data_ptr, __data_ptr + __data_size);
   316       this->pbump((int)__data_size);
   317 
   318     }
   319     else {
   320       _M_append_buffer();
   321 //      _M_str.append(__n, __c);
   322 #ifdef __SYMBIAN32__      
   323       if (_M_str._M_stream_pos >= 0 
   324           && (_M_str._M_stream_pos < _M_str.size())) {          
   325           if((_M_str.size() - _M_str._M_stream_pos) >= __n)
   326           	_M_str.replace(_M_str._M_stream_pos,__n, __n, __c);          
   327           else
   328           	{
   329           	_M_str.replace(_M_str._M_stream_pos, (_M_str.size() - _M_str._M_stream_pos), (_M_str.size() - _M_str._M_stream_pos), __c);
   330           	_M_str.append(__n, __c);
   331           	}
   332       } else {
   333           _M_str.append(__n, __c);
   334       }
   335       _M_str._M_stream_pos += __n;
   336 #else //__SYMBIAN32__      
   337       _M_str.append(__n, __c);
   338 #endif // __SYMBIAN32__      
   339     }
   340 
   341     __nwritten += __n;
   342   }
   343 
   344   return __nwritten;
   345 }
   346 
   347 // According to the C++ standard the effects of setbuf are implementation
   348 // defined, except that setbuf(0, 0) has no effect.  In this implementation,
   349 // setbuf(<anything>, n), for n > 0, calls reserve(n) on the underlying
   350 // string.
   351 template <class _CharT, class _Traits, class _Alloc>
   352 _STLP_EXP_DECLSPEC basic_streambuf<_CharT, _Traits>*
   353 #ifdef __SYMBIAN32__
   354 basic_stringbuf<_CharT, _Traits, _Alloc>::setbuf(_CharT* __s, streamsize __n)
   355 #else
   356 basic_stringbuf<_CharT, _Traits, _Alloc>::setbuf(_CharT*, streamsize __n)
   357 #endif //__SYMBIAN32__
   358 {
   359   if (__n > 0) {
   360     bool __do_get_area = false;
   361     bool __do_put_area = false;
   362     ptrdiff_t __offg = 0;
   363     ptrdiff_t __offp = 0;
   364 
   365     if (this->pbase() == _M_str.data()) {
   366       __do_put_area = true;
   367       __offp = this->pptr() - this->pbase();
   368     }
   369 
   370     if (this->eback() == _M_str.data()) {
   371       __do_get_area = true;
   372       __offg = this->gptr() - this->eback();
   373     }
   374 
   375     if ((_M_mode & ios_base::out) && !(_M_mode & ios_base::in))
   376       _M_append_buffer();
   377 
   378     _M_str.reserve(__n);
   379 
   380     _CharT* __data_ptr = __CONST_CAST(_CharT*,_M_str.data());
   381 #ifdef __SYMBIAN32__
   382     size_t __data_size = __n;
   383     memmove(__data_ptr, __s, __n*sizeof(_CharT));    
   384     _M_str._M_start = __data_ptr;
   385     _M_str._M_finish = __data_ptr+__n;
   386 #else
   387     size_t __data_size = _M_str.size();
   388 #endif //__SYMBIAN32__
   389 
   390     if (__do_get_area) {
   391 #ifdef __SYMBIAN32__
   392       this->setg(__data_ptr, __data_ptr, __data_ptr+__data_size);
   393 #else
   394       this->setg(__data_ptr, __data_ptr + __offg, __data_ptr+__data_size);
   395 #endif //__SYMBIAN32__      
   396     }
   397 
   398     if (__do_put_area) {
   399       this->setp(__data_ptr, __data_ptr+__data_size);
   400 #ifndef __SYMBIAN32__
   401       this->pbump((int)__offp);
   402 #endif //__SYMBIAN32__      
   403     }
   404   }
   405 
   406   return this;
   407 }
   408 
   409 template <class _CharT, class _Traits, class _Alloc>
   410 _STLP_EXP_DECLSPEC __BSB_pos_type__
   411 basic_stringbuf<_CharT, _Traits, _Alloc>::seekoff(off_type __off, 
   412             ios_base::seekdir __dir,
   413             ios_base::openmode __mode)
   414 {
   415   bool __stl_in  = false;
   416   bool __stl_out = false;
   417   
   418   if ((__mode & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out) ) {
   419     if (__dir == ios_base::beg || __dir == ios_base::end)
   420       __stl_in = __stl_out = true;
   421   }
   422   else if (__mode & ios_base::in)
   423     __stl_in = true;
   424   else if (__mode & ios_base::out)
   425     __stl_out = true;
   426 
   427   if (!__stl_in && !__stl_out)
   428     return pos_type(off_type(-1));
   429   else if ((__stl_in  && (!(_M_mode & ios_base::in) || this->gptr() == 0)) ||
   430            (__stl_out && (!(_M_mode & ios_base::out) || this->pptr() == 0)))
   431     return pos_type(off_type(-1));
   432 
   433 #ifdef __SYMBIAN32__
   434   if (_M_mode & ios_base::out)
   435 #else
   436   if ((_M_mode & ios_base::out) && !(_M_mode & ios_base::in))
   437 #endif
   438     _M_append_buffer();
   439 
   440   streamoff __newoff;
   441   switch(__dir) {
   442   case ios_base::beg:
   443     __newoff = 0;
   444     break;
   445   case ios_base::end:
   446     __newoff = _M_str.size();
   447     break;
   448   case ios_base::cur:
   449     __newoff = __stl_in ? this->gptr() - this->eback() 
   450 #ifdef __SYMBIAN32__    
   451                     : ((this->pbase() != this->_M_str) ? _M_str._M_stream_pos
   452                     : this->pptr() - this->pbase());
   453 #else
   454                     : this->pptr() - this->pbase();
   455 #endif //__SYMBIAN32__                                                            
   456     break;
   457   default:
   458     return pos_type(off_type(-1));
   459   }
   460 
   461   __off += __newoff;
   462 
   463   if (__stl_in) {
   464     ptrdiff_t __n = this->egptr() - this->eback();
   465 
   466     if (__off < 0 || __off > __n)
   467       return pos_type(off_type(-1));
   468     else
   469       this->setg(this->eback(), this->eback() + __off, this->eback() + __n);
   470   }
   471 
   472   if (__stl_out) {
   473     ptrdiff_t __n;
   474 #ifdef __SYMBIAN32__
   475     //if (this->pbase() != this->_M_str) {
   476     void* __data_ptr1 = reinterpret_cast<void*>(this->pbase());
   477 		_CharT* __data_ptr2 = __CONST_CAST(_CharT*,this->_M_str.data());
   478 				
   479        if (__data_ptr1 != __data_ptr2) {
   480         __n = _M_str.size();
   481     } else {
   482 #endif // __SYMBIAN32__
   483     __n = this->epptr() - this->pbase();
   484 #ifdef __SYMBIAN32__
   485     }
   486 #endif //__SYMBIAN32__        
   487     if (__off < 0 || __off > __n)
   488       return pos_type(off_type(-1));
   489     else {
   490 #ifdef __SYMBIAN32__
   491 		void* __data_ptr1 = reinterpret_cast<void*>(this->pbase());
   492 		_CharT* __data_ptr2 = __CONST_CAST(_CharT*,this->_M_str.data());
   493 				
   494        if (__data_ptr1 != __data_ptr2) {
   495            _M_str._M_stream_pos = __off;
   496        } else {
   497 #endif //__SYMBIAN32__
   498       this->setp(this->pbase(), this->pbase() + __n);
   499       this->pbump((int)__off);
   500 #ifdef __SYMBIAN32__      
   501       }
   502 #endif // __SYMBIAN32__      
   503     }
   504   }
   505 
   506   return pos_type(__off);
   507 }
   508 
   509 template <class _CharT, class _Traits, class _Alloc>
   510 _STLP_EXP_DECLSPEC __BSB_pos_type__
   511 basic_stringbuf<_CharT, _Traits, _Alloc>
   512   ::seekpos(pos_type __pos, ios_base::openmode __mode)
   513 {
   514   bool __stl_in  = (__mode & ios_base::in) != 0;
   515   bool __stl_out = (__mode & ios_base::out) != 0;
   516 
   517   if ((__stl_in  && (!(_M_mode & ios_base::in) || this->gptr() == 0)) ||
   518       (__stl_out && (!(_M_mode & ios_base::out) || this->pptr() == 0)) ||
   519       (!__stl_in && !__stl_out))
   520     return pos_type(off_type(-1));
   521 
   522   const off_type __n = __pos - pos_type(off_type(0));
   523   if ((_M_mode & ios_base::out) && !(_M_mode & ios_base::in))
   524     _M_append_buffer();
   525 
   526   if (__stl_in) {
   527     if (__n < 0 || __n > this->egptr() - this->eback())
   528       return pos_type(off_type(-1));
   529     this->setg(this->eback(), this->eback() + __n, this->egptr());
   530   }
   531 
   532   if (__stl_out) {
   533     if (__n < 0 || size_t(__n) > _M_str.size())
   534       return pos_type(off_type(-1));
   535 
   536     _CharT* __data_ptr = __CONST_CAST(_CharT*,_M_str.data());
   537     size_t __data_size = _M_str.size();
   538     
   539     this->setp(__data_ptr, __data_ptr+__data_size);
   540     this->pbump((int)__n);
   541   }
   542 
   543   return __pos;
   544 }
   545 
   546 // This is declared as a const member function because it is 
   547 // called by basic_stringbuf<>::str().  Precondition: this is a
   548 // write-only stringbuf.  We can't use an output buffer for read-
   549 // write stringbufs.  Postcondition: pptr is reset to the beginning
   550 // of the buffer.
   551 template <class _CharT, class _Traits, class _Alloc>
   552 void basic_stringbuf<_CharT, _Traits, _Alloc>::_M_append_buffer() const
   553 
   554 {
   555   // Do we have a buffer to append?
   556   if (this->pbase() == this->_M_Buf && this->pptr() != this->_M_Buf) {
   557     basic_stringbuf<_CharT, _Traits, _Alloc>* __this = __CONST_CAST(_Self*,this);
   558 #ifdef __SYMBIAN32__    
   559     size_t __n = this->pptr() - this->pbase();
   560     if (__this->_M_str._M_stream_pos >= 0 
   561         && (__this->_M_str._M_stream_pos != __this->_M_str.size())) {
   562         {
   563         *(this->pptr()) = (_CharT)0;
   564 #ifdef  __SYMBIAN32__
   565         __this->_M_str.replace(_M_str._M_stream_pos, __n, (const _CharT*)this->pbase(), (const _CharT*)this->pptr()-(const _CharT*)this->pbase());
   566 #else
   567 	__this->_M_str.replace(_M_str._M_stream_pos, __n, (const _CharT*)this->pbase());
   568 
   569 #endif
   570         }
   571     } else {
   572         __this->_M_str.append((const _CharT*)this->pbase(), (const _CharT*)this->pptr());
   573     }
   574     __this->_M_str._M_stream_pos += __n;
   575 #else // __SYMBAIN32__    
   576     __this->_M_str.append((const _CharT*)this->pbase(), (const _CharT*)this->pptr());
   577 #endif // __SYMBIAN32__    
   578     __this->setp(__CONST_CAST(_CharT*,_M_Buf),
   579                  __CONST_CAST(_CharT*,_M_Buf + __STATIC_CAST(int,_S_BufSiz)));
   580   }
   581 
   582   // Have we run off the end of the string?
   583   else if (this->pptr() == this->epptr()) {
   584     basic_stringbuf<_CharT, _Traits, _Alloc>* __this = __CONST_CAST(_Self*,this);
   585     __this->setp(__CONST_CAST(_CharT*,_M_Buf),
   586                  __CONST_CAST(_CharT*,_M_Buf + __STATIC_CAST(int,_S_BufSiz)));
   587   __this->_M_str._M_stream_pos = __this->_M_str._M_finish - __this->_M_str._M_start;
   588   }
   589 }
   590 
   591 //----------------------------------------------------------------------
   592 // Non-inline istringstream member functions.
   593 
   594 template <class _CharT, class _Traits, class _Alloc>
   595 basic_istringstream<_CharT, _Traits, _Alloc>
   596   ::basic_istringstream(ios_base::openmode __mode)
   597     : basic_istream<_CharT, _Traits>(0),
   598       _M_buf(__mode | ios_base::in)
   599 {
   600   this->init(&_M_buf);
   601 }
   602 
   603 template <class _CharT, class _Traits, class _Alloc>
   604 basic_istringstream<_CharT, _Traits, _Alloc>
   605   ::basic_istringstream(const _String& __str,ios_base::openmode __mode)
   606     : basic_istream<_CharT, _Traits>(0),
   607       _M_buf(__str, __mode | ios_base::in)
   608 {
   609   this->init(&_M_buf);
   610 }
   611 
   612 template <class _CharT, class _Traits, class _Alloc>
   613 basic_istringstream<_CharT, _Traits, _Alloc>::~basic_istringstream()
   614 {}
   615 
   616 //----------------------------------------------------------------------
   617 // Non-inline ostringstream member functions.
   618 
   619 template <class _CharT, class _Traits, class _Alloc>
   620 basic_ostringstream<_CharT, _Traits, _Alloc>
   621   ::basic_ostringstream(ios_base::openmode __mode)
   622     : basic_ostream<_CharT, _Traits>(0),
   623       _M_buf(__mode | ios_base::out)
   624 {
   625   this->init(&_M_buf);
   626 }
   627   
   628 template <class _CharT, class _Traits, class _Alloc>
   629 basic_ostringstream<_CharT, _Traits, _Alloc>
   630   ::basic_ostringstream(const _String& __str, ios_base::openmode __mode)
   631     : basic_ostream<_CharT, _Traits>(0),
   632       _M_buf(__str, __mode | ios_base::out)
   633 {
   634   this->init(&_M_buf);
   635 }
   636 
   637 template <class _CharT, class _Traits, class _Alloc>
   638 basic_ostringstream<_CharT, _Traits, _Alloc>::~basic_ostringstream()
   639 {}
   640 
   641 //----------------------------------------------------------------------
   642 // Non-inline stringstream member functions.
   643 
   644 template <class _CharT, class _Traits, class _Alloc>
   645 _STLP_EXP_DECLSPEC basic_stringstream<_CharT, _Traits, _Alloc>
   646   ::basic_stringstream(ios_base::openmode __mode)
   647     : basic_iostream<_CharT, _Traits>(0), _M_buf(__mode)
   648 {
   649    this->init(&_M_buf);
   650 }
   651 
   652 template <class _CharT, class _Traits, class _Alloc>
   653 _STLP_EXP_DECLSPEC basic_stringstream<_CharT, _Traits, _Alloc>
   654   ::basic_stringstream(const _String& __str, ios_base::openmode __mode)
   655     : basic_iostream<_CharT, _Traits>(0), _M_buf(__str, __mode)
   656 {
   657   this->init(&_M_buf);
   658 }
   659 
   660 template <class _CharT, class _Traits, class _Alloc>
   661 basic_stringstream<_CharT, _Traits, _Alloc>::~basic_stringstream()
   662 {}
   663 
   664 _STLP_END_NAMESPACE
   665 
   666 # undef __BSB_int_type__
   667 # undef __BSB_pos_type__
   668 
   669 # endif /* EXPOSE */
   670 
   671 #endif /* _STLP_SSTREAM_C */