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