epoc32/include/tools/stlport/stl/_streambuf.c
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/tools/stlport/stl/_streambuf.c	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,208 @@
     1.4 +/*
     1.5 + * Copyright (c) 1999
     1.6 + * Silicon Graphics Computer Systems, Inc.
     1.7 + *
     1.8 + * Copyright (c) 1999
     1.9 + * Boris Fomitchev
    1.10 + *
    1.11 + * This material is provided "as is", with absolutely no warranty expressed
    1.12 + * or implied. Any use is at your own risk.
    1.13 + *
    1.14 + * Permission to use or copy this software for any purpose is hereby granted
    1.15 + * without fee, provided the above notices are retained on all copies.
    1.16 + * Permission to modify the code and to distribute modified code is granted,
    1.17 + * provided the above notices are retained, and a notice that the code was
    1.18 + * modified is included with the above copyright notice.
    1.19 + *
    1.20 + */
    1.21 +#ifndef _STLP_STREAMBUF_C
    1.22 +#define _STLP_STREAMBUF_C
    1.23 +
    1.24 +#ifndef _STLP_INTERNAL_STREAMBUF
    1.25 +#  include <stl/_streambuf.h>
    1.26 +#endif
    1.27 +
    1.28 +_STLP_BEGIN_NAMESPACE
    1.29 +//----------------------------------------------------------------------
    1.30 +// Non-inline basic_streambuf<> member functions.
    1.31 +
    1.32 +#if !defined (_STLP_MSVC) || (_STLP_MSVC >= 1300) || !defined (_STLP_USE_STATIC_LIB)
    1.33 +template <class _CharT, class _Traits>
    1.34 +basic_streambuf<_CharT, _Traits>::basic_streambuf()
    1.35 +  : _M_gbegin(0), _M_gnext(0), _M_gend(0),
    1.36 +    _M_pbegin(0), _M_pnext(0), _M_pend(0),
    1.37 +    _M_locale() {
    1.38 +  //  _M_lock._M_initialize();
    1.39 +}
    1.40 +#endif
    1.41 +
    1.42 +template <class _CharT, class _Traits>
    1.43 +basic_streambuf<_CharT, _Traits>::~basic_streambuf()
    1.44 +{}
    1.45 +
    1.46 +template <class _CharT, class _Traits>
    1.47 +locale
    1.48 +basic_streambuf<_CharT, _Traits>::pubimbue(const locale& __loc) {
    1.49 +  this->imbue(__loc);
    1.50 +  locale __tmp = _M_locale;
    1.51 +  _M_locale = __loc;
    1.52 +  return __tmp;
    1.53 +}
    1.54 +
    1.55 +template <class _CharT, class _Traits>
    1.56 +streamsize
    1.57 +basic_streambuf<_CharT, _Traits>::xsgetn(_CharT* __s, streamsize __n) {
    1.58 +  streamsize __result = 0;
    1.59 +  const int_type __eof = _Traits::eof();
    1.60 +
    1.61 +  while (__result < __n) {
    1.62 +    if (_M_gnext < _M_gend) {
    1.63 +      size_t __chunk = (min) (__STATIC_CAST(size_t,_M_gend - _M_gnext),
    1.64 +                              __STATIC_CAST(size_t,__n - __result));
    1.65 +      _Traits::copy(__s, _M_gnext, __chunk);
    1.66 +      __result += __chunk;
    1.67 +      __s += __chunk;
    1.68 +      _M_gnext += __chunk;
    1.69 +    }
    1.70 +    else {
    1.71 +      int_type __c = this->sbumpc();
    1.72 +      if (!_Traits::eq_int_type(__c, __eof)) {
    1.73 +        *__s = _Traits::to_char_type(__c);
    1.74 +        ++__result;
    1.75 +        ++__s;
    1.76 +      }
    1.77 +      else
    1.78 +        break;
    1.79 +    }
    1.80 +  }
    1.81 +
    1.82 +  return __result;
    1.83 +}
    1.84 +
    1.85 +template <class _CharT, class _Traits>
    1.86 +streamsize
    1.87 +basic_streambuf<_CharT, _Traits>::xsputn(const _CharT* __s, streamsize __n)
    1.88 +{
    1.89 +  streamsize __result = 0;
    1.90 +  const int_type __eof = _Traits::eof();
    1.91 +
    1.92 +  while (__result < __n) {
    1.93 +    if (_M_pnext < _M_pend) {
    1.94 +      size_t __chunk = (min) (__STATIC_CAST(size_t,_M_pend - _M_pnext),
    1.95 +                           __STATIC_CAST(size_t,__n - __result));
    1.96 +      _Traits::copy(_M_pnext, __s, __chunk);
    1.97 +      __result += __chunk;
    1.98 +      __s += __chunk;
    1.99 +      _M_pnext += __chunk;
   1.100 +    }
   1.101 +
   1.102 +    else if (!_Traits::eq_int_type(this->overflow(_Traits::to_int_type(*__s)),
   1.103 +                                   __eof)) {
   1.104 +      ++__result;
   1.105 +      ++__s;
   1.106 +    }
   1.107 +    else
   1.108 +      break;
   1.109 +  }
   1.110 +  return __result;
   1.111 +}
   1.112 +
   1.113 +template <class _CharT, class _Traits>
   1.114 +streamsize
   1.115 +basic_streambuf<_CharT, _Traits>::_M_xsputnc(_CharT __c, streamsize __n)
   1.116 +{
   1.117 +  streamsize __result = 0;
   1.118 +  const int_type __eof = _Traits::eof();
   1.119 +
   1.120 +  while (__result < __n) {
   1.121 +    if (_M_pnext < _M_pend) {
   1.122 +      size_t __chunk = (min) (__STATIC_CAST(size_t,_M_pend - _M_pnext),
   1.123 +                           __STATIC_CAST(size_t,__n - __result));
   1.124 +      _Traits::assign(_M_pnext, __chunk, __c);
   1.125 +      __result += __chunk;
   1.126 +      _M_pnext += __chunk;
   1.127 +    }
   1.128 +
   1.129 +    else if (!_Traits::eq_int_type(this->overflow(_Traits::to_int_type(__c)),
   1.130 +                                   __eof))
   1.131 +      ++__result;
   1.132 +    else
   1.133 +      break;
   1.134 +  }
   1.135 +  return __result;
   1.136 +}
   1.137 +
   1.138 +template <class _CharT, class _Traits>
   1.139 +_STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::int_type
   1.140 +basic_streambuf<_CharT, _Traits>::_M_snextc_aux()
   1.141 +{
   1.142 +  int_type __eof = _Traits::eof();
   1.143 +  if (_M_gend == _M_gnext)
   1.144 +    return _Traits::eq_int_type(this->uflow(), __eof) ? __eof : this->sgetc();
   1.145 +  else {
   1.146 +    _M_gnext = _M_gend;
   1.147 +    return this->underflow();
   1.148 +  }
   1.149 +}
   1.150 +
   1.151 +template <class _CharT, class _Traits>
   1.152 +_STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::int_type
   1.153 +basic_streambuf<_CharT, _Traits>::pbackfail(int_type) {
   1.154 + return _Traits::eof();
   1.155 +}
   1.156 +
   1.157 +template <class _CharT, class _Traits>
   1.158 +_STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::int_type
   1.159 +basic_streambuf<_CharT, _Traits>::overflow(int_type) {
   1.160 +  return _Traits::eof();
   1.161 +}
   1.162 +
   1.163 +template <class _CharT, class _Traits>
   1.164 +_STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::int_type
   1.165 +basic_streambuf<_CharT, _Traits>::uflow() {
   1.166 +    return ( _Traits::eq_int_type(this->underflow(),_Traits::eof()) ?
   1.167 +             _Traits::eof() :
   1.168 +             _Traits::to_int_type(*_M_gnext++));
   1.169 +}
   1.170 +
   1.171 +template <class _CharT, class _Traits>
   1.172 +_STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::int_type
   1.173 +basic_streambuf<_CharT, _Traits>::underflow()
   1.174 +{ return _Traits::eof(); }
   1.175 +
   1.176 +template <class _CharT, class _Traits>
   1.177 +streamsize
   1.178 +basic_streambuf<_CharT, _Traits>::showmanyc()
   1.179 +{ return 0; }
   1.180 +
   1.181 +template <class _CharT, class _Traits>
   1.182 +void
   1.183 +basic_streambuf<_CharT, _Traits>::imbue(const locale&) {}
   1.184 +
   1.185 +template <class _CharT, class _Traits>
   1.186 +int
   1.187 +basic_streambuf<_CharT, _Traits>::sync() { return 0; }
   1.188 +
   1.189 +template <class _CharT, class _Traits>
   1.190 +_STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::pos_type
   1.191 +basic_streambuf<_CharT, _Traits>::seekpos(pos_type, ios_base::openmode)
   1.192 +{ return pos_type(-1); }
   1.193 +
   1.194 +template <class _CharT, class _Traits>
   1.195 +_STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::pos_type
   1.196 +basic_streambuf<_CharT, _Traits>::seekoff(off_type, ios_base::seekdir,
   1.197 +                                          ios_base::openmode)
   1.198 +{ return pos_type(-1); }
   1.199 +
   1.200 +template <class _CharT, class _Traits>
   1.201 +basic_streambuf<_CharT, _Traits>*
   1.202 +basic_streambuf<_CharT, _Traits>:: setbuf(char_type*, streamsize)
   1.203 +{ return this; }
   1.204 +
   1.205 +_STLP_END_NAMESPACE
   1.206 +
   1.207 +#endif
   1.208 +
   1.209 +// Local Variables:
   1.210 +// mode:C++
   1.211 +// End: