1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_sstream.c Wed Mar 31 12:27:01 2010 +0100
1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_sstream.c Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -1,40 +1,36 @@
1.4 /*
1.5 - * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
1.6 * Copyright (c) 1999
1.7 * Silicon Graphics Computer Systems, Inc.
1.8 *
1.9 - * Copyright (c) 1999
1.10 + * Copyright (c) 1999
1.11 * Boris Fomitchev
1.12 *
1.13 * This material is provided "as is", with absolutely no warranty expressed
1.14 * or implied. Any use is at your own risk.
1.15 *
1.16 - * Permission to use or copy this software for any purpose is hereby granted
1.17 + * Permission to use or copy this software for any purpose is hereby granted
1.18 * without fee, provided the above notices are retained on all copies.
1.19 * Permission to modify the code and to distribute modified code is granted,
1.20 * provided the above notices are retained, and a notice that the code was
1.21 * modified is included with the above copyright notice.
1.22 *
1.23 - */
1.24 + */
1.25
1.26 #ifndef _STLP_SSTREAM_C
1.27 #define _STLP_SSTREAM_C
1.28
1.29 -#ifndef _STLP_SSTREAM_H
1.30 -# include <stl/_sstream.h>
1.31 -#include <stl/_stdio_file.h>
1.32 +#ifndef _STLP_INTERNAL_SSTREAM
1.33 +# include <stl/_sstream.h>
1.34 #endif
1.35
1.36 -# if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
1.37 -
1.38 -# if defined ( _STLP_NESTED_TYPE_PARAM_BUG )
1.39 +#if defined ( _STLP_NESTED_TYPE_PARAM_BUG )
1.40 // no wint_t is supported for this mode
1.41 -# define __BSB_int_type__ int
1.42 -# define __BSB_pos_type__ streampos
1.43 -# else
1.44 -# define __BSB_int_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
1.45 -# define __BSB_pos_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
1.46 -# endif
1.47 +# define __BSB_int_type__ int
1.48 +# define __BSB_pos_type__ streampos
1.49 +#else
1.50 +# define __BSB_int_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
1.51 +# define __BSB_pos_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
1.52 +#endif
1.53
1.54 _STLP_BEGIN_NAMESPACE
1.55
1.56 @@ -45,41 +41,26 @@
1.57 // get and area pointers to null.
1.58
1.59 template <class _CharT, class _Traits, class _Alloc>
1.60 -_STLP_EXP_DECLSPEC basic_stringbuf<_CharT, _Traits, _Alloc>
1.61 +basic_stringbuf<_CharT, _Traits, _Alloc>
1.62 ::basic_stringbuf(ios_base::openmode __mode)
1.63 : basic_streambuf<_CharT, _Traits>(), _M_mode(__mode), _M_str()
1.64 -{
1.65 -#ifdef __SYMBIAN32__
1.66 -if (_M_mode & ios_base::out) {
1.67 - if (_M_mode & (ios_base::app | ios_base::ate))
1.68 - //increment the streampos to reflect the current streampos while writing
1.69 - _M_str._M_stream_pos += _M_str.size();
1.70 -}
1.71 -#endif
1.72 -}
1.73 +{}
1.74
1.75 template <class _CharT, class _Traits, class _Alloc>
1.76 -_STLP_EXP_DECLSPEC basic_stringbuf<_CharT, _Traits, _Alloc>
1.77 +basic_stringbuf<_CharT, _Traits, _Alloc>
1.78 ::basic_stringbuf(const basic_string<_CharT, _Traits, _Alloc>& __s, ios_base::openmode __mode)
1.79 : basic_streambuf<_CharT, _Traits>(), _M_mode(__mode), _M_str(__s)
1.80 {
1.81 -#ifdef __SYMBIAN32__
1.82 -if (_M_mode & ios_base::out) {
1.83 - if (_M_mode & (ios_base::app | ios_base::ate))
1.84 - //increment the streampos to reflect the current streampos while writing
1.85 - _M_str._M_stream_pos += _M_str.size();
1.86 -}
1.87 -#endif
1.88 _M_set_ptrs();
1.89 }
1.90
1.91 template <class _CharT, class _Traits, class _Alloc>
1.92 -_STLP_EXP_DECLSPEC basic_stringbuf<_CharT, _Traits, _Alloc>::~basic_stringbuf()
1.93 +basic_stringbuf<_CharT, _Traits, _Alloc>::~basic_stringbuf()
1.94 {}
1.95
1.96 // Set the underlying string to a new value.
1.97 template <class _CharT, class _Traits, class _Alloc>
1.98 -_STLP_EXP_DECLSPEC void
1.99 +void
1.100 basic_stringbuf<_CharT, _Traits, _Alloc>::str(const basic_string<_CharT, _Traits, _Alloc>& __s)
1.101 {
1.102 _M_str = __s;
1.103 @@ -87,7 +68,7 @@
1.104 }
1.105
1.106 template <class _CharT, class _Traits, class _Alloc>
1.107 -void
1.108 +void
1.109 basic_stringbuf<_CharT, _Traits, _Alloc>::_M_set_ptrs() {
1.110 _CharT* __data_ptr = __CONST_CAST(_CharT*,_M_str.data());
1.111 _CharT* __data_end = __data_ptr + _M_str.size();
1.112 @@ -98,7 +79,7 @@
1.113 else
1.114 this->setg(__data_ptr, __data_ptr, __data_end);
1.115 }
1.116 -
1.117 +
1.118 // The initial write position is the beginning of the string.
1.119 if (_M_mode & ios_base::out) {
1.120 if (_M_mode & (ios_base::app | ios_base::ate))
1.121 @@ -110,9 +91,8 @@
1.122
1.123 // Precondition: gptr() >= egptr(). Returns a character, if one is available.
1.124 template <class _CharT, class _Traits, class _Alloc>
1.125 -_STLP_EXP_DECLSPEC __BSB_int_type__
1.126 -basic_stringbuf<_CharT, _Traits, _Alloc>::underflow()
1.127 -{
1.128 +__BSB_int_type__
1.129 +basic_stringbuf<_CharT, _Traits, _Alloc>::underflow() {
1.130 return this->gptr() != this->egptr()
1.131 ? _Traits::to_int_type(*this->gptr())
1.132 : _Traits::eof();
1.133 @@ -120,9 +100,8 @@
1.134
1.135 // Precondition: gptr() >= egptr().
1.136 template <class _CharT, class _Traits, class _Alloc>
1.137 -_STLP_EXP_DECLSPEC __BSB_int_type__
1.138 -basic_stringbuf<_CharT, _Traits, _Alloc>::uflow()
1.139 -{
1.140 +__BSB_int_type__
1.141 +basic_stringbuf<_CharT, _Traits, _Alloc>::uflow() {
1.142 if (this->gptr() != this->egptr()) {
1.143 int_type __c = _Traits::to_int_type(*this->gptr());
1.144 this->gbump(1);
1.145 @@ -133,35 +112,34 @@
1.146 }
1.147
1.148 template <class _CharT, class _Traits, class _Alloc>
1.149 -_STLP_EXP_DECLSPEC __BSB_int_type__
1.150 -basic_stringbuf<_CharT, _Traits, _Alloc>::pbackfail(int_type __c)
1.151 -{
1.152 +__BSB_int_type__
1.153 +basic_stringbuf<_CharT, _Traits, _Alloc>::pbackfail(int_type __c) {
1.154 if (this->gptr() != this->eback()) {
1.155 if (!_Traits::eq_int_type(__c, _Traits::eof())) {
1.156 -
1.157 -if (_Traits::eq(_Traits::to_char_type(__c), this->gptr()[-1])
1.158 - || _M_mode == (ios_base::in | ios_base::out)) {
1.159 + if (_Traits::eq(_Traits::to_char_type(__c), this->gptr()[-1])) {
1.160 this->gbump(-1);
1.161 - *this->gptr() = _Traits::to_char_type(__c);
1.162 - return _Traits::not_eof(__c);
1.163 + return __c;
1.164 }
1.165 - else{
1.166 - return _Traits::eof();
1.167 - }
1.168 + else if (_M_mode & ios_base::out) {
1.169 + this->gbump(-1);
1.170 + *this->gptr() = _Traits::to_char_type(__c);
1.171 + return __c;
1.172 + }
1.173 + else
1.174 + return _Traits::eof();
1.175 }
1.176 else {
1.177 this->gbump(-1);
1.178 return _Traits::not_eof(__c);
1.179 }
1.180 }
1.181 - else
1.182 + else
1.183 return _Traits::eof();
1.184 }
1.185
1.186 template <class _CharT, class _Traits, class _Alloc>
1.187 -_STLP_EXP_DECLSPEC __BSB_int_type__
1.188 -basic_stringbuf<_CharT, _Traits, _Alloc>::overflow(int_type __c)
1.189 -{
1.190 +__BSB_int_type__
1.191 +basic_stringbuf<_CharT, _Traits, _Alloc>::overflow(int_type __c) {
1.192 // fbp : reverse order of "ifs" to pass Dietmar's test.
1.193 // Apparently, standard allows overflow with eof even for read-only streams.
1.194 if (!_Traits::eq_int_type(__c, _Traits::eof())) {
1.195 @@ -170,7 +148,7 @@
1.196 // It's a write-only streambuf, so we can use special append buffer.
1.197 if (this->pptr() == this->epptr())
1.198 this->_M_append_buffer();
1.199 -
1.200 +
1.201 if (this->pptr() != this->epptr()) {
1.202 *this->pptr() = _Traits::to_char_type(__c);
1.203 this->pbump(1);
1.204 @@ -179,15 +157,14 @@
1.205 else
1.206 return _Traits::eof();
1.207 }
1.208 -
1.209 else {
1.210 // We're not using a special append buffer, just the string itself.
1.211 if (this->pptr() == this->epptr()) {
1.212 ptrdiff_t __offset = this->gptr() - this->eback();
1.213 _M_str.push_back(_Traits::to_char_type(__c));
1.214
1.215 - _CharT* __data_ptr = __CONST_CAST(_CharT*,_M_str.data());
1.216 - size_t __data_size = _M_str.size();
1.217 + _CharT* __data_ptr = __CONST_CAST(_CharT*,_M_str.data());
1.218 + size_t __data_size = _M_str.size();
1.219
1.220 this->setg(__data_ptr, __data_ptr + __offset, __data_ptr+__data_size);
1.221 this->setp(__data_ptr, __data_ptr + __data_size);
1.222 @@ -201,7 +178,7 @@
1.223 }
1.224 }
1.225 }
1.226 - else // Overflow always fails if it's read-only
1.227 + else // Overflow always fails if it's read-only
1.228 return _Traits::eof();
1.229 }
1.230 else // __c is EOF, so we don't have to do anything
1.231 @@ -209,10 +186,9 @@
1.232 }
1.233
1.234 template <class _CharT, class _Traits, class _Alloc>
1.235 -_STLP_EXP_DECLSPEC streamsize
1.236 +streamsize
1.237 basic_stringbuf<_CharT, _Traits, _Alloc>::xsputn(const char_type* __s,
1.238 - streamsize __n)
1.239 -{
1.240 + streamsize __n) {
1.241 streamsize __nwritten = 0;
1.242
1.243 if ((_M_mode & ios_base::out) && __n > 0) {
1.244 @@ -221,11 +197,8 @@
1.245 if (this->pbase() == _M_str.data() ) {
1.246 ptrdiff_t __avail = _M_str.data() + _M_str.size() - this->pptr();
1.247 if (__avail > __n) {
1.248 - _Traits::copy(this->pptr(), __s, __n);
1.249 + _Traits::copy(this->pptr(), __s, __STATIC_CAST(size_t, __n));
1.250 this->pbump((int)__n);
1.251 -#ifdef __SYMBIAN32__
1.252 - // _M_str._M_stream_pos += __n; //increment streampos to number of characters in stream
1.253 -#endif
1.254 return __n;
1.255 }
1.256 else {
1.257 @@ -233,9 +206,6 @@
1.258 __nwritten += __avail;
1.259 __n -= __avail;
1.260 __s += __avail;
1.261 -#ifdef __SYMBIAN32__
1.262 - // _M_str._M_stream_pos += __avail;//increment streampos to number of characters in stream
1.263 -#endif
1.264 this->setp(_M_Buf, _M_Buf + __STATIC_CAST(int,_S_BufSiz));
1.265 }
1.266 }
1.267 @@ -243,35 +213,20 @@
1.268 // At this point we know we're appending.
1.269 if (_M_mode & ios_base::in) {
1.270 ptrdiff_t __get_offset = this->gptr() - this->eback();
1.271 - _M_str.append(__s, __s + __n);
1.272 -
1.273 - _CharT* __data_ptr = __CONST_CAST(_CharT*,_M_str.data());
1.274 + _M_str.append(__s, __s + __STATIC_CAST(ptrdiff_t, __n));
1.275 +
1.276 + _CharT* __data_ptr = __CONST_CAST(_CharT*, _M_str.data());
1.277 size_t __data_size = _M_str.size();
1.278
1.279 - this->setg(__data_ptr, __data_ptr + __get_offset, __data_ptr+__data_size);
1.280 + this->setg(__data_ptr, __data_ptr + __get_offset, __data_ptr + __data_size);
1.281 this->setp(__data_ptr, __data_ptr + __data_size);
1.282 this->pbump((int)__data_size);
1.283 }
1.284 else {
1.285 _M_append_buffer();
1.286 -#ifdef __SYMBIAN32__
1.287 - if (_M_str._M_stream_pos >= 0
1.288 - && (_M_str._M_stream_pos < _M_str.size())) {
1.289 - if((_M_str.size() - _M_str._M_stream_pos) >= __n)
1.290 - _M_str.replace(_M_str._M_stream_pos, __n, __s);
1.291 - else
1.292 - {
1.293 - _M_str.replace(_M_str._M_stream_pos, (_M_str.size() - _M_str._M_stream_pos), __s);
1.294 - _M_str.append(__s + (__n - (_M_str.size() - _M_str._M_stream_pos)), __s + __n);
1.295 - }
1.296 - } else {
1.297 - _M_str.append(__s, __s + __n);
1.298 - }
1.299 - _M_str._M_stream_pos += __n;
1.300 -#else //__SYMBIAN32__
1.301 - _M_str.append(__s, __s + __n);
1.302 -#endif // __SYMBIAN32__
1.303 + _M_str.append(__s, __s + __STATIC_CAST(ptrdiff_t, __n));
1.304 }
1.305 +
1.306 __nwritten += __n;
1.307 }
1.308
1.309 @@ -279,10 +234,9 @@
1.310 }
1.311
1.312 template <class _CharT, class _Traits, class _Alloc>
1.313 -streamsize
1.314 +streamsize
1.315 basic_stringbuf<_CharT, _Traits, _Alloc>::_M_xsputnc(char_type __c,
1.316 - streamsize __n)
1.317 -{
1.318 + streamsize __n) {
1.319 streamsize __nwritten = 0;
1.320
1.321 if ((_M_mode & ios_base::out) && __n > 0) {
1.322 @@ -291,8 +245,8 @@
1.323 if (this->pbase() == _M_str.data()) {
1.324 ptrdiff_t __avail = _M_str.data() + _M_str.size() - this->pptr();
1.325 if (__avail > __n) {
1.326 - _Traits::assign(this->pptr(), __n, __c);
1.327 - this->pbump((int)__n);
1.328 + _Traits::assign(this->pptr(), __STATIC_CAST(size_t, __n), __c);
1.329 + this->pbump(__STATIC_CAST(int, __n));
1.330 return __n;
1.331 }
1.332 else {
1.333 @@ -304,41 +258,25 @@
1.334 }
1.335
1.336 // At this point we know we're appending.
1.337 + size_t __app_size = sizeof(streamsize) > sizeof(size_t) ? __STATIC_CAST(size_t, (min)(__n, __STATIC_CAST(streamsize, _M_str.max_size())))
1.338 + : __STATIC_CAST(size_t, __n);
1.339 if (this->_M_mode & ios_base::in) {
1.340 ptrdiff_t __get_offset = this->gptr() - this->eback();
1.341 - _M_str.append(__n, __c);
1.342 + _M_str.append(__app_size, __c);
1.343
1.344 _CharT* __data_ptr = __CONST_CAST(_CharT*,_M_str.data());
1.345 size_t __data_size = _M_str.size();
1.346
1.347 - this->setg(__data_ptr, __data_ptr + __get_offset, __data_ptr+__data_size);
1.348 + this->setg(__data_ptr, __data_ptr + __get_offset, __data_ptr + __data_size);
1.349 this->setp(__data_ptr, __data_ptr + __data_size);
1.350 this->pbump((int)__data_size);
1.351 -
1.352 }
1.353 else {
1.354 _M_append_buffer();
1.355 -// _M_str.append(__n, __c);
1.356 -#ifdef __SYMBIAN32__
1.357 - if (_M_str._M_stream_pos >= 0
1.358 - && (_M_str._M_stream_pos < _M_str.size())) {
1.359 - if((_M_str.size() - _M_str._M_stream_pos) >= __n)
1.360 - _M_str.replace(_M_str._M_stream_pos,__n, __n, __c);
1.361 - else
1.362 - {
1.363 - _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);
1.364 - _M_str.append(__n, __c);
1.365 - }
1.366 - } else {
1.367 - _M_str.append(__n, __c);
1.368 - }
1.369 - _M_str._M_stream_pos += __n;
1.370 -#else //__SYMBIAN32__
1.371 - _M_str.append(__n, __c);
1.372 -#endif // __SYMBIAN32__
1.373 + _M_str.append(__app_size, __c);
1.374 }
1.375
1.376 - __nwritten += __n;
1.377 + __nwritten += __app_size;
1.378 }
1.379
1.380 return __nwritten;
1.381 @@ -349,13 +287,8 @@
1.382 // setbuf(<anything>, n), for n > 0, calls reserve(n) on the underlying
1.383 // string.
1.384 template <class _CharT, class _Traits, class _Alloc>
1.385 -_STLP_EXP_DECLSPEC basic_streambuf<_CharT, _Traits>*
1.386 -#ifdef __SYMBIAN32__
1.387 -basic_stringbuf<_CharT, _Traits, _Alloc>::setbuf(_CharT* __s, streamsize __n)
1.388 -#else
1.389 -basic_stringbuf<_CharT, _Traits, _Alloc>::setbuf(_CharT*, streamsize __n)
1.390 -#endif //__SYMBIAN32__
1.391 -{
1.392 +basic_streambuf<_CharT, _Traits>*
1.393 +basic_stringbuf<_CharT, _Traits, _Alloc>::setbuf(_CharT*, streamsize __n) {
1.394 if (__n > 0) {
1.395 bool __do_get_area = false;
1.396 bool __do_put_area = false;
1.397 @@ -375,31 +308,19 @@
1.398 if ((_M_mode & ios_base::out) && !(_M_mode & ios_base::in))
1.399 _M_append_buffer();
1.400
1.401 - _M_str.reserve(__n);
1.402 + _M_str.reserve(sizeof(streamsize) > sizeof(size_t) ? __STATIC_CAST(size_t, (min)(__n, __STATIC_CAST(streamsize, _M_str.max_size())))
1.403 + : __STATIC_CAST(size_t, __n));
1.404
1.405 - _CharT* __data_ptr = __CONST_CAST(_CharT*,_M_str.data());
1.406 -#ifdef __SYMBIAN32__
1.407 - size_t __data_size = __n;
1.408 - memmove(__data_ptr, __s, __n*sizeof(_CharT));
1.409 - _M_str._M_start = __data_ptr;
1.410 - _M_str._M_finish = __data_ptr+__n;
1.411 -#else
1.412 + _CharT* __data_ptr = __CONST_CAST(_CharT*, _M_str.data());
1.413 size_t __data_size = _M_str.size();
1.414 -#endif //__SYMBIAN32__
1.415
1.416 if (__do_get_area) {
1.417 -#ifdef __SYMBIAN32__
1.418 - this->setg(__data_ptr, __data_ptr, __data_ptr+__data_size);
1.419 -#else
1.420 - this->setg(__data_ptr, __data_ptr + __offg, __data_ptr+__data_size);
1.421 -#endif //__SYMBIAN32__
1.422 + this->setg(__data_ptr, __data_ptr + __offg, __data_ptr + __data_size);
1.423 }
1.424
1.425 if (__do_put_area) {
1.426 - this->setp(__data_ptr, __data_ptr+__data_size);
1.427 -#ifndef __SYMBIAN32__
1.428 + this->setp(__data_ptr, __data_ptr + __data_size);
1.429 this->pbump((int)__offp);
1.430 -#endif //__SYMBIAN32__
1.431 }
1.432 }
1.433
1.434 @@ -407,35 +328,26 @@
1.435 }
1.436
1.437 template <class _CharT, class _Traits, class _Alloc>
1.438 -_STLP_EXP_DECLSPEC __BSB_pos_type__
1.439 -basic_stringbuf<_CharT, _Traits, _Alloc>::seekoff(off_type __off,
1.440 +__BSB_pos_type__
1.441 +basic_stringbuf<_CharT, _Traits, _Alloc>
1.442 + ::seekoff(off_type __off,
1.443 ios_base::seekdir __dir,
1.444 - ios_base::openmode __mode)
1.445 -{
1.446 - bool __stl_in = false;
1.447 - bool __stl_out = false;
1.448 -
1.449 - if ((__mode & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out) ) {
1.450 - if (__dir == ios_base::beg || __dir == ios_base::end)
1.451 - __stl_in = __stl_out = true;
1.452 - }
1.453 - else if (__mode & ios_base::in)
1.454 - __stl_in = true;
1.455 - else if (__mode & ios_base::out)
1.456 - __stl_out = true;
1.457 + ios_base::openmode __mode) {
1.458 + __mode &= _M_mode;
1.459
1.460 - if (!__stl_in && !__stl_out)
1.461 - return pos_type(off_type(-1));
1.462 - else if ((__stl_in && (!(_M_mode & ios_base::in) || this->gptr() == 0)) ||
1.463 - (__stl_out && (!(_M_mode & ios_base::out) || this->pptr() == 0)))
1.464 + bool __imode = (__mode & ios_base::in) != 0;
1.465 + bool __omode = (__mode & ios_base::out) != 0;
1.466 +
1.467 + if ( !(__imode || __omode) )
1.468 return pos_type(off_type(-1));
1.469
1.470 -#ifdef __SYMBIAN32__
1.471 - if (_M_mode & ios_base::out)
1.472 -#else
1.473 + if ( (__imode && (this->gptr() == 0)) || (__omode && (this->pptr() == 0)) )
1.474 + return pos_type(off_type(-1));
1.475 +
1.476 +#ifndef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
1.477 if ((_M_mode & ios_base::out) && !(_M_mode & ios_base::in))
1.478 + _M_append_buffer();
1.479 #endif
1.480 - _M_append_buffer();
1.481
1.482 streamoff __newoff;
1.483 switch(__dir) {
1.484 @@ -446,96 +358,80 @@
1.485 __newoff = _M_str.size();
1.486 break;
1.487 case ios_base::cur:
1.488 - __newoff = __stl_in ? this->gptr() - this->eback()
1.489 -#ifdef __SYMBIAN32__
1.490 - : ((this->pbase() != this->_M_str) ? _M_str._M_stream_pos
1.491 - : this->pptr() - this->pbase());
1.492 -#else
1.493 - : this->pptr() - this->pbase();
1.494 -#endif //__SYMBIAN32__
1.495 + __newoff = __imode ? this->gptr() - this->eback() : this->pptr() - this->pbase();
1.496 +#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
1.497 + if ( __off == 0 ) {
1.498 + return pos_type(__newoff);
1.499 + }
1.500 +#endif
1.501 break;
1.502 default:
1.503 return pos_type(off_type(-1));
1.504 }
1.505
1.506 __off += __newoff;
1.507 +#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
1.508 + _CharT* __data_ptr = __CONST_CAST(_CharT*, _M_str.data());
1.509 + size_t __data_size = _M_str.size();
1.510 +#endif
1.511
1.512 - if (__stl_in) {
1.513 + if (__imode) {
1.514 ptrdiff_t __n = this->egptr() - this->eback();
1.515
1.516 if (__off < 0 || __off > __n)
1.517 return pos_type(off_type(-1));
1.518 - else
1.519 - this->setg(this->eback(), this->eback() + __off, this->eback() + __n);
1.520 + this->setg(this->eback(), this->eback() + __STATIC_CAST(ptrdiff_t, __off),
1.521 + this->eback() + __STATIC_CAST(ptrdiff_t, __n));
1.522 }
1.523
1.524 - if (__stl_out) {
1.525 - ptrdiff_t __n;
1.526 -#ifdef __SYMBIAN32__
1.527 - //if (this->pbase() != this->_M_str) {
1.528 - void* __data_ptr1 = reinterpret_cast<void*>(this->pbase());
1.529 - _CharT* __data_ptr2 = __CONST_CAST(_CharT*,this->_M_str.data());
1.530 -
1.531 - if (__data_ptr1 != __data_ptr2) {
1.532 - __n = _M_str.size();
1.533 - } else {
1.534 -#endif // __SYMBIAN32__
1.535 - __n = this->epptr() - this->pbase();
1.536 -#ifdef __SYMBIAN32__
1.537 - }
1.538 -#endif //__SYMBIAN32__
1.539 + if (__omode) {
1.540 + ptrdiff_t __n = this->epptr() - this->pbase();
1.541 +
1.542 if (__off < 0 || __off > __n)
1.543 return pos_type(off_type(-1));
1.544 - else {
1.545 -#ifdef __SYMBIAN32__
1.546 - void* __data_ptr1 = reinterpret_cast<void*>(this->pbase());
1.547 - _CharT* __data_ptr2 = __CONST_CAST(_CharT*,this->_M_str.data());
1.548 -
1.549 - if (__data_ptr1 != __data_ptr2) {
1.550 - _M_str._M_stream_pos = __off;
1.551 - } else {
1.552 -#endif //__SYMBIAN32__
1.553 - this->setp(this->pbase(), this->pbase() + __n);
1.554 - this->pbump((int)__off);
1.555 -#ifdef __SYMBIAN32__
1.556 - }
1.557 -#endif // __SYMBIAN32__
1.558 - }
1.559 +#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
1.560 + this->setp(__data_ptr, __data_ptr+__data_size);
1.561 +#else
1.562 + this->setp(this->pbase(), this->pbase() + __n);
1.563 +#endif
1.564 + this->pbump((int)__off);
1.565 }
1.566
1.567 return pos_type(__off);
1.568 }
1.569
1.570 template <class _CharT, class _Traits, class _Alloc>
1.571 -_STLP_EXP_DECLSPEC __BSB_pos_type__
1.572 +__BSB_pos_type__
1.573 basic_stringbuf<_CharT, _Traits, _Alloc>
1.574 - ::seekpos(pos_type __pos, ios_base::openmode __mode)
1.575 -{
1.576 - bool __stl_in = (__mode & ios_base::in) != 0;
1.577 - bool __stl_out = (__mode & ios_base::out) != 0;
1.578 + ::seekpos(pos_type __pos, ios_base::openmode __mode) {
1.579 + __mode &= _M_mode;
1.580
1.581 - if ((__stl_in && (!(_M_mode & ios_base::in) || this->gptr() == 0)) ||
1.582 - (__stl_out && (!(_M_mode & ios_base::out) || this->pptr() == 0)) ||
1.583 - (!__stl_in && !__stl_out))
1.584 + bool __imode = (__mode & ios_base::in) != 0;
1.585 + bool __omode = (__mode & ios_base::out) != 0;
1.586 +
1.587 + if ( !(__imode || __omode) )
1.588 + return pos_type(off_type(-1));
1.589 +
1.590 + if ( (__imode && (this->gptr() == 0)) || (__omode && (this->pptr() == 0)) )
1.591 return pos_type(off_type(-1));
1.592
1.593 const off_type __n = __pos - pos_type(off_type(0));
1.594 if ((_M_mode & ios_base::out) && !(_M_mode & ios_base::in))
1.595 _M_append_buffer();
1.596
1.597 - if (__stl_in) {
1.598 + if (__imode) {
1.599 if (__n < 0 || __n > this->egptr() - this->eback())
1.600 return pos_type(off_type(-1));
1.601 - this->setg(this->eback(), this->eback() + __n, this->egptr());
1.602 + this->setg(this->eback(), this->eback() + __STATIC_CAST(ptrdiff_t, __n), this->egptr());
1.603 }
1.604
1.605 - if (__stl_out) {
1.606 + if (__omode) {
1.607 if (__n < 0 || size_t(__n) > _M_str.size())
1.608 return pos_type(off_type(-1));
1.609
1.610 _CharT* __data_ptr = __CONST_CAST(_CharT*,_M_str.data());
1.611 size_t __data_size = _M_str.size();
1.612 -
1.613 +
1.614 this->setp(__data_ptr, __data_ptr+__data_size);
1.615 this->pbump((int)__n);
1.616 }
1.617 @@ -543,48 +439,36 @@
1.618 return __pos;
1.619 }
1.620
1.621 -// This is declared as a const member function because it is
1.622 +// This is declared as a const member function because it is
1.623 // called by basic_stringbuf<>::str(). Precondition: this is a
1.624 // write-only stringbuf. We can't use an output buffer for read-
1.625 // write stringbufs. Postcondition: pptr is reset to the beginning
1.626 // of the buffer.
1.627 template <class _CharT, class _Traits, class _Alloc>
1.628 -void basic_stringbuf<_CharT, _Traits, _Alloc>::_M_append_buffer() const
1.629 -
1.630 -{
1.631 +void basic_stringbuf<_CharT, _Traits, _Alloc>::_M_append_buffer() const {
1.632 // Do we have a buffer to append?
1.633 if (this->pbase() == this->_M_Buf && this->pptr() != this->_M_Buf) {
1.634 basic_stringbuf<_CharT, _Traits, _Alloc>* __this = __CONST_CAST(_Self*,this);
1.635 -#ifdef __SYMBIAN32__
1.636 - size_t __n = this->pptr() - this->pbase();
1.637 - if (__this->_M_str._M_stream_pos >= 0
1.638 - && (__this->_M_str._M_stream_pos != __this->_M_str.size())) {
1.639 - {
1.640 - *(this->pptr()) = (_CharT)0;
1.641 -#ifdef __SYMBIAN32__
1.642 - __this->_M_str.replace(_M_str._M_stream_pos, __n, (const _CharT*)this->pbase(), (const _CharT*)this->pptr()-(const _CharT*)this->pbase());
1.643 -#else
1.644 - __this->_M_str.replace(_M_str._M_stream_pos, __n, (const _CharT*)this->pbase());
1.645 -
1.646 -#endif
1.647 - }
1.648 - } else {
1.649 - __this->_M_str.append((const _CharT*)this->pbase(), (const _CharT*)this->pptr());
1.650 - }
1.651 - __this->_M_str._M_stream_pos += __n;
1.652 -#else // __SYMBAIN32__
1.653 __this->_M_str.append((const _CharT*)this->pbase(), (const _CharT*)this->pptr());
1.654 -#endif // __SYMBIAN32__
1.655 +#ifndef __MWERKS__
1.656 __this->setp(__CONST_CAST(_CharT*,_M_Buf),
1.657 __CONST_CAST(_CharT*,_M_Buf + __STATIC_CAST(int,_S_BufSiz)));
1.658 +#else // CodeWarrior treat const char * and const char [8] as different types
1.659 + __this->setp((_CharT*)_M_Buf,
1.660 + (_CharT*)(_M_Buf + __STATIC_CAST(int,_S_BufSiz)));
1.661 +#endif
1.662 }
1.663
1.664 // Have we run off the end of the string?
1.665 else if (this->pptr() == this->epptr()) {
1.666 basic_stringbuf<_CharT, _Traits, _Alloc>* __this = __CONST_CAST(_Self*,this);
1.667 +#ifndef __MWERKS__
1.668 __this->setp(__CONST_CAST(_CharT*,_M_Buf),
1.669 __CONST_CAST(_CharT*,_M_Buf + __STATIC_CAST(int,_S_BufSiz)));
1.670 - __this->_M_str._M_stream_pos = __this->_M_str._M_finish - __this->_M_str._M_start;
1.671 +#else // CodeWarrior treat const char * and const char [8] as different types
1.672 + __this->setp((_CharT*)_M_Buf,
1.673 + (_CharT*)(_M_Buf + __STATIC_CAST(int,_S_BufSiz)));
1.674 +#endif
1.675 }
1.676 }
1.677
1.678 @@ -595,8 +479,7 @@
1.679 basic_istringstream<_CharT, _Traits, _Alloc>
1.680 ::basic_istringstream(ios_base::openmode __mode)
1.681 : basic_istream<_CharT, _Traits>(0),
1.682 - _M_buf(__mode | ios_base::in)
1.683 -{
1.684 + _M_buf(__mode | ios_base::in) {
1.685 this->init(&_M_buf);
1.686 }
1.687
1.688 @@ -604,8 +487,7 @@
1.689 basic_istringstream<_CharT, _Traits, _Alloc>
1.690 ::basic_istringstream(const _String& __str,ios_base::openmode __mode)
1.691 : basic_istream<_CharT, _Traits>(0),
1.692 - _M_buf(__str, __mode | ios_base::in)
1.693 -{
1.694 + _M_buf(__str, __mode | ios_base::in) {
1.695 this->init(&_M_buf);
1.696 }
1.697
1.698 @@ -620,17 +502,15 @@
1.699 basic_ostringstream<_CharT, _Traits, _Alloc>
1.700 ::basic_ostringstream(ios_base::openmode __mode)
1.701 : basic_ostream<_CharT, _Traits>(0),
1.702 - _M_buf(__mode | ios_base::out)
1.703 -{
1.704 + _M_buf(__mode | ios_base::out) {
1.705 this->init(&_M_buf);
1.706 }
1.707 -
1.708 +
1.709 template <class _CharT, class _Traits, class _Alloc>
1.710 basic_ostringstream<_CharT, _Traits, _Alloc>
1.711 ::basic_ostringstream(const _String& __str, ios_base::openmode __mode)
1.712 : basic_ostream<_CharT, _Traits>(0),
1.713 - _M_buf(__str, __mode | ios_base::out)
1.714 -{
1.715 + _M_buf(__str, __mode | ios_base::out) {
1.716 this->init(&_M_buf);
1.717 }
1.718
1.719 @@ -642,18 +522,16 @@
1.720 // Non-inline stringstream member functions.
1.721
1.722 template <class _CharT, class _Traits, class _Alloc>
1.723 -_STLP_EXP_DECLSPEC basic_stringstream<_CharT, _Traits, _Alloc>
1.724 +basic_stringstream<_CharT, _Traits, _Alloc>
1.725 ::basic_stringstream(ios_base::openmode __mode)
1.726 - : basic_iostream<_CharT, _Traits>(0), _M_buf(__mode)
1.727 -{
1.728 + : basic_iostream<_CharT, _Traits>(0), _M_buf(__mode) {
1.729 this->init(&_M_buf);
1.730 }
1.731
1.732 template <class _CharT, class _Traits, class _Alloc>
1.733 -_STLP_EXP_DECLSPEC basic_stringstream<_CharT, _Traits, _Alloc>
1.734 +basic_stringstream<_CharT, _Traits, _Alloc>
1.735 ::basic_stringstream(const _String& __str, ios_base::openmode __mode)
1.736 - : basic_iostream<_CharT, _Traits>(0), _M_buf(__str, __mode)
1.737 -{
1.738 + : basic_iostream<_CharT, _Traits>(0), _M_buf(__str, __mode) {
1.739 this->init(&_M_buf);
1.740 }
1.741
1.742 @@ -666,6 +544,8 @@
1.743 # undef __BSB_int_type__
1.744 # undef __BSB_pos_type__
1.745
1.746 -# endif /* EXPOSE */
1.747 +#endif /* _STLP_SSTREAM_C */
1.748
1.749 -#endif /* _STLP_SSTREAM_C */
1.750 +// Local Variables:
1.751 +// mode:C++
1.752 +// End: