3 * Silicon Graphics Computer Systems, Inc.
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
11 * Permission to use or copy this software for any purpose is hereby granted
12 * without fee, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
18 #ifndef _STLP_STREAMBUF_C
19 #define _STLP_STREAMBUF_C
21 #ifndef _STLP_INTERNAL_STREAMBUF
22 # include <stl/_streambuf.h>
26 //----------------------------------------------------------------------
27 // Non-inline basic_streambuf<> member functions.
29 #if !defined (_STLP_MSVC) || (_STLP_MSVC >= 1300) || !defined (_STLP_USE_STATIC_LIB)
30 template <class _CharT
, class _Traits
>
31 basic_streambuf
<_CharT
, _Traits
>::basic_streambuf()
32 : _M_gbegin(0), _M_gnext(0), _M_gend(0),
33 _M_pbegin(0), _M_pnext(0), _M_pend(0),
35 // _M_lock._M_initialize();
39 template <class _CharT
, class _Traits
>
40 basic_streambuf
<_CharT
, _Traits
>::~basic_streambuf()
43 template <class _CharT
, class _Traits
>
45 basic_streambuf
<_CharT
, _Traits
>::pubimbue(const locale
& __loc
) {
47 locale __tmp
= _M_locale
;
52 template <class _CharT
, class _Traits
>
54 basic_streambuf
<_CharT
, _Traits
>::xsgetn(_CharT
* __s
, streamsize __n
) {
55 streamsize __result
= 0;
56 const int_type __eof
= _Traits::eof();
58 while (__result
< __n
) {
59 if (_M_gnext
< _M_gend
) {
60 size_t __chunk
= (min
) (__STATIC_CAST(size_t,_M_gend
- _M_gnext
),
61 __STATIC_CAST(size_t,__n
- __result
));
62 _Traits::copy(__s
, _M_gnext
, __chunk
);
68 int_type __c
= this->sbumpc();
69 if (!_Traits::eq_int_type(__c
, __eof
)) {
70 *__s
= _Traits::to_char_type(__c
);
82 template <class _CharT
, class _Traits
>
84 basic_streambuf
<_CharT
, _Traits
>::xsputn(const _CharT
* __s
, streamsize __n
)
86 streamsize __result
= 0;
87 const int_type __eof
= _Traits::eof();
89 while (__result
< __n
) {
90 if (_M_pnext
< _M_pend
) {
91 size_t __chunk
= (min
) (__STATIC_CAST(size_t,_M_pend
- _M_pnext
),
92 __STATIC_CAST(size_t,__n
- __result
));
93 _Traits::copy(_M_pnext
, __s
, __chunk
);
99 else if (!_Traits::eq_int_type(this->overflow(_Traits::to_int_type(*__s
)),
110 template <class _CharT
, class _Traits
>
112 basic_streambuf
<_CharT
, _Traits
>::_M_xsputnc(_CharT __c
, streamsize __n
)
114 streamsize __result
= 0;
115 const int_type __eof
= _Traits::eof();
117 while (__result
< __n
) {
118 if (_M_pnext
< _M_pend
) {
119 size_t __chunk
= (min
) (__STATIC_CAST(size_t,_M_pend
- _M_pnext
),
120 __STATIC_CAST(size_t,__n
- __result
));
121 _Traits::assign(_M_pnext
, __chunk
, __c
);
126 else if (!_Traits::eq_int_type(this->overflow(_Traits::to_int_type(__c
)),
135 template <class _CharT
, class _Traits
>
136 _STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf
<_CharT
, _Traits
>::int_type
137 basic_streambuf
<_CharT
, _Traits
>::_M_snextc_aux()
139 int_type __eof
= _Traits::eof();
140 if (_M_gend
== _M_gnext
)
141 return _Traits::eq_int_type(this->uflow(), __eof
) ? __eof
: this->sgetc();
144 return this->underflow();
148 template <class _CharT
, class _Traits
>
149 _STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf
<_CharT
, _Traits
>::int_type
150 basic_streambuf
<_CharT
, _Traits
>::pbackfail(int_type
) {
151 return _Traits::eof();
154 template <class _CharT
, class _Traits
>
155 _STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf
<_CharT
, _Traits
>::int_type
156 basic_streambuf
<_CharT
, _Traits
>::overflow(int_type
) {
157 return _Traits::eof();
160 template <class _CharT
, class _Traits
>
161 _STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf
<_CharT
, _Traits
>::int_type
162 basic_streambuf
<_CharT
, _Traits
>::uflow() {
163 return ( _Traits::eq_int_type(this->underflow(),_Traits::eof()) ?
165 _Traits::to_int_type(*_M_gnext
++));
168 template <class _CharT
, class _Traits
>
169 _STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf
<_CharT
, _Traits
>::int_type
170 basic_streambuf
<_CharT
, _Traits
>::underflow()
171 { return _Traits::eof(); }
173 template <class _CharT
, class _Traits
>
175 basic_streambuf
<_CharT
, _Traits
>::showmanyc()
178 template <class _CharT
, class _Traits
>
180 basic_streambuf
<_CharT
, _Traits
>::imbue(const locale
&) {}
182 template <class _CharT
, class _Traits
>
184 basic_streambuf
<_CharT
, _Traits
>::sync() { return 0; }
186 template <class _CharT
, class _Traits
>
187 _STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf
<_CharT
, _Traits
>::pos_type
188 basic_streambuf
<_CharT
, _Traits
>::seekpos(pos_type
, ios_base::openmode
)
189 { return pos_type(-1); }
191 template <class _CharT
, class _Traits
>
192 _STLP_TYPENAME_ON_RETURN_TYPE basic_streambuf
<_CharT
, _Traits
>::pos_type
193 basic_streambuf
<_CharT
, _Traits
>::seekoff(off_type
, ios_base::seekdir
,
195 { return pos_type(-1); }
197 template <class _CharT
, class _Traits
>
198 basic_streambuf
<_CharT
, _Traits
>*
199 basic_streambuf
<_CharT
, _Traits
>:: setbuf(char_type
*, streamsize
)