1.1 --- a/epoc32/include/stdapis/stlport/stl/_streambuf.c Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stlport/stl/_streambuf.c Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,218 @@
1.4 -_streambuf.c
1.5 +/*
1.6 + * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
1.7 + *
1.8 + * Copyright (c) 1999
1.9 + * Silicon Graphics Computer Systems, Inc.
1.10 + *
1.11 + * Copyright (c) 1999
1.12 + * Boris Fomitchev
1.13 + *
1.14 + * This material is provided "as is", with absolutely no warranty expressed
1.15 + * or implied. Any use is at your own risk.
1.16 + *
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 +#ifndef _STLP_STREAMBUF_C
1.25 +#define _STLP_STREAMBUF_C
1.26 +
1.27 +#ifndef _STLP_INTERNAL_STREAMBUF
1.28 +# include <stl/_streambuf.h>
1.29 +#endif
1.30 +
1.31 +# if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
1.32 +
1.33 +_STLP_BEGIN_NAMESPACE
1.34 +//----------------------------------------------------------------------
1.35 +// Non-inline basic_streambuf<> member functions.
1.36 +
1.37 +template <class _CharT, class _Traits>
1.38 +_STLP_EXP_DECLSPEC basic_streambuf<_CharT, _Traits>::basic_streambuf()
1.39 + : _M_gbegin(0), _M_gnext(0), _M_gend(0),
1.40 + _M_pbegin(0), _M_pnext(0), _M_pend(0),
1.41 + _M_locale()
1.42 +{
1.43 + // _M_lock._M_initialize();
1.44 +}
1.45 +
1.46 +template <class _CharT, class _Traits>
1.47 +_STLP_EXP_DECLSPEC basic_streambuf<_CharT, _Traits>::~basic_streambuf()
1.48 +{}
1.49 +
1.50 +
1.51 +template <class _CharT, class _Traits>
1.52 +_STLP_EXP_DECLSPEC locale
1.53 +basic_streambuf<_CharT, _Traits>::pubimbue(const locale& __loc) {
1.54 + this->imbue(__loc);
1.55 + locale __tmp = _M_locale;
1.56 + _M_locale = __loc;
1.57 + return __tmp;
1.58 +}
1.59 +
1.60 +template <class _CharT, class _Traits>
1.61 +_STLP_EXP_DECLSPEC streamsize
1.62 +basic_streambuf<_CharT, _Traits>::xsgetn(_CharT* __s, streamsize __n)
1.63 +{
1.64 + streamsize __result = 0;
1.65 + const int_type __eof = _Traits::eof();
1.66 +
1.67 + while (__result < __n) {
1.68 + if (_M_gnext < _M_gend) {
1.69 + size_t __chunk = (min) (__STATIC_CAST(size_t,_M_gend - _M_gnext),
1.70 + __STATIC_CAST(size_t,__n - __result));
1.71 + _Traits::copy(__s, _M_gnext, __chunk);
1.72 + __result += __chunk;
1.73 + __s += __chunk;
1.74 + _M_gnext += __chunk;
1.75 + }
1.76 + else {
1.77 + int_type __c = this->sbumpc();
1.78 + if (!_Traits::eq_int_type(__c, __eof)) {
1.79 + *__s = __c;
1.80 + ++__result;
1.81 + ++__s;
1.82 + }
1.83 + else
1.84 + break;
1.85 + }
1.86 + }
1.87 +
1.88 + return __result;
1.89 +}
1.90 +
1.91 +template <class _CharT, class _Traits>
1.92 +_STLP_EXP_DECLSPEC streamsize
1.93 +basic_streambuf<_CharT, _Traits>::xsputn(const _CharT* __s, streamsize __n)
1.94 +{
1.95 + streamsize __result = 0;
1.96 + const int_type __eof = _Traits::eof();
1.97 +
1.98 + while (__result < __n) {
1.99 + if (_M_pnext < _M_pend) {
1.100 + size_t __chunk = (min) (__STATIC_CAST(size_t,_M_pend - _M_pnext),
1.101 + __STATIC_CAST(size_t,__n - __result));
1.102 + _Traits::copy(_M_pnext, __s, __chunk);
1.103 + __result += __chunk;
1.104 + __s += __chunk;
1.105 + _M_pnext += __chunk;
1.106 + }
1.107 +
1.108 + else if (!_Traits::eq_int_type(this->overflow(_Traits::to_int_type(*__s)),
1.109 + __eof)) {
1.110 + ++__result;
1.111 + ++__s;
1.112 + }
1.113 + else
1.114 + break;
1.115 + }
1.116 + return __result;
1.117 +}
1.118 +
1.119 +template <class _CharT, class _Traits>
1.120 +_STLP_EXP_DECLSPEC streamsize
1.121 +basic_streambuf<_CharT, _Traits>::_M_xsputnc(_CharT __c, streamsize __n)
1.122 +{
1.123 + streamsize __result = 0;
1.124 + const int_type __eof = _Traits::eof();
1.125 +
1.126 + while (__result < __n) {
1.127 + if (_M_pnext < _M_pend) {
1.128 + size_t __chunk = (min) (__STATIC_CAST(size_t,_M_pend - _M_pnext),
1.129 + __STATIC_CAST(size_t,__n - __result));
1.130 + _Traits::assign(_M_pnext, __chunk, __c);
1.131 + __result += __chunk;
1.132 + _M_pnext += __chunk;
1.133 + }
1.134 +
1.135 + else if (!_Traits::eq_int_type(this->overflow(_Traits::to_int_type(__c)),
1.136 + __eof))
1.137 + ++__result;
1.138 + else
1.139 + break;
1.140 + }
1.141 + return __result;
1.142 +}
1.143 +
1.144 +template <class _CharT, class _Traits>
1.145 +_STLP_EXP_DECLSPEC _STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::int_type
1.146 +basic_streambuf<_CharT, _Traits>::_M_snextc_aux()
1.147 +{
1.148 + int_type __eof = _Traits::eof();
1.149 + if (_M_gend == _M_gnext)
1.150 + return _Traits::eq_int_type(this->uflow(), __eof) ? __eof : this->sgetc();
1.151 + else {
1.152 + _M_gnext = _M_gend;
1.153 + return this->underflow();
1.154 + }
1.155 +}
1.156 +
1.157 +template <class _CharT, class _Traits>
1.158 +_STLP_EXP_DECLSPEC _STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::int_type
1.159 +basic_streambuf<_CharT, _Traits>::pbackfail(int_type) {
1.160 + return _Traits::eof();
1.161 +}
1.162 +
1.163 +template <class _CharT, class _Traits>
1.164 +_STLP_EXP_DECLSPEC _STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::int_type
1.165 +basic_streambuf<_CharT, _Traits>::overflow(int_type) {
1.166 + return _Traits::eof();
1.167 +}
1.168 +
1.169 +template <class _CharT, class _Traits>
1.170 +_STLP_EXP_DECLSPEC _STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::int_type
1.171 +basic_streambuf<_CharT, _Traits>::uflow() {
1.172 + return ( _Traits::eq_int_type(this->underflow(),_Traits::eof()) ?
1.173 + _Traits::eof() :
1.174 + _Traits::to_int_type(*_M_gnext++));
1.175 +}
1.176 +
1.177 +template <class _CharT, class _Traits>
1.178 +_STLP_EXP_DECLSPEC _STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::int_type
1.179 +basic_streambuf<_CharT, _Traits>::underflow()
1.180 +{ return _Traits::eof(); }
1.181 +
1.182 +template <class _CharT, class _Traits>
1.183 +_STLP_EXP_DECLSPEC streamsize
1.184 +basic_streambuf<_CharT, _Traits>::showmanyc()
1.185 +{ return 0; }
1.186 +
1.187 +template <class _CharT, class _Traits>
1.188 +_STLP_EXP_DECLSPEC void
1.189 +basic_streambuf<_CharT, _Traits>::imbue(const locale&) {}
1.190 +
1.191 +template <class _CharT, class _Traits>
1.192 +_STLP_EXP_DECLSPEC int
1.193 +basic_streambuf<_CharT, _Traits>::sync() { return 0; }
1.194 +
1.195 +template <class _CharT, class _Traits>
1.196 +_STLP_EXP_DECLSPEC _STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::pos_type
1.197 +basic_streambuf<_CharT, _Traits>::seekpos(pos_type, ios_base::openmode)
1.198 +{ return pos_type(-1); }
1.199 +
1.200 +template <class _CharT, class _Traits>
1.201 +_STLP_EXP_DECLSPEC _STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf<_CharT, _Traits>::pos_type
1.202 +basic_streambuf<_CharT, _Traits>::seekoff(off_type, ios_base::seekdir,
1.203 + ios_base::openmode)
1.204 +{ return pos_type(-1); }
1.205 +
1.206 +template <class _CharT, class _Traits>
1.207 +_STLP_EXP_DECLSPEC basic_streambuf<_CharT, _Traits>*
1.208 +basic_streambuf<_CharT, _Traits>:: setbuf(char_type*, streamsize)
1.209 +{ return this; }
1.210 +
1.211 +
1.212 +# if defined (_STLP_USE_TEMPLATE_EXPORT)
1.213 +# if !defined (_STLP_NO_WCHAR_T)
1.214 +_STLP_EXPORT_TEMPLATE_CLASS basic_streambuf<wchar_t, char_traits<wchar_t> >;
1.215 +# endif
1.216 +# endif /* _STLP_USE_TEMPLATE_EXPORT */
1.217 +
1.218 +_STLP_END_NAMESPACE
1.219 +
1.220 +# endif /* EXPOSE */
1.221 +
1.222 +#endif