ReactOS 0.4.15-dev-7942-gd23573b
_streambuf.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 1999
3 * Silicon Graphics Computer Systems, Inc.
4 *
5 * Copyright (c) 1999
6 * Boris Fomitchev
7 *
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
10 *
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.
16 *
17 */
18#ifndef _STLP_STREAMBUF_C
19#define _STLP_STREAMBUF_C
20
21#ifndef _STLP_INTERNAL_STREAMBUF
22# include <stl/_streambuf.h>
23#endif
24
26//----------------------------------------------------------------------
27// Non-inline basic_streambuf<> member functions.
28
29#if !defined (_STLP_MSVC) || (_STLP_MSVC >= 1300) || !defined (_STLP_USE_STATIC_LIB)
30template <class _CharT, class _Traits>
32 : _M_gbegin(0), _M_gnext(0), _M_gend(0),
33 _M_pbegin(0), _M_pnext(0), _M_pend(0),
34 _M_locale() {
35 // _M_lock._M_initialize();
36}
37#endif
38
39template <class _CharT, class _Traits>
41{}
42
43template <class _CharT, class _Traits>
46 this->imbue(__loc);
47 locale __tmp = _M_locale;
48 _M_locale = __loc;
49 return __tmp;
50}
51
52template <class _CharT, class _Traits>
55 streamsize __result = 0;
56 const int_type __eof = _Traits::eof();
57
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);
63 __result += __chunk;
64 __s += __chunk;
65 _M_gnext += __chunk;
66 }
67 else {
68 int_type __c = this->sbumpc();
69 if (!_Traits::eq_int_type(__c, __eof)) {
70 *__s = _Traits::to_char_type(__c);
71 ++__result;
72 ++__s;
73 }
74 else
75 break;
76 }
77 }
78
79 return __result;
80}
81
82template <class _CharT, class _Traits>
85{
86 streamsize __result = 0;
87 const int_type __eof = _Traits::eof();
88
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);
94 __result += __chunk;
95 __s += __chunk;
96 _M_pnext += __chunk;
97 }
98
99 else if (!_Traits::eq_int_type(this->overflow(_Traits::to_int_type(*__s)),
100 __eof)) {
101 ++__result;
102 ++__s;
103 }
104 else
105 break;
106 }
107 return __result;
108}
109
110template <class _CharT, class _Traits>
113{
114 streamsize __result = 0;
115 const int_type __eof = _Traits::eof();
116
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);
122 __result += __chunk;
123 _M_pnext += __chunk;
125
126 else if (!_Traits::eq_int_type(this->overflow(_Traits::to_int_type(__c)),
127 __eof))
128 ++__result;
129 else
130 break;
131 }
132 return __result;
133}
135template <class _CharT, class _Traits>
139 int_type __eof = _Traits::eof();
140 if (_M_gend == _M_gnext)
141 return _Traits::eq_int_type(this->uflow(), __eof) ? __eof : this->sgetc();
142 else {
143 _M_gnext = _M_gend;
144 return this->underflow();
145 }
146}
147
148template <class _CharT, class _Traits>
151 return _Traits::eof();
152}
153
154template <class _CharT, class _Traits>
157 return _Traits::eof();
158}
159
160template <class _CharT, class _Traits>
163 return ( _Traits::eq_int_type(this->underflow(),_Traits::eof()) ?
164 _Traits::eof() :
165 _Traits::to_int_type(*_M_gnext++));
166}
167
168template <class _CharT, class _Traits>
171{ return _Traits::eof(); }
172
173template <class _CharT, class _Traits>
176{ return 0; }
177
178template <class _CharT, class _Traits>
179void
181
182template <class _CharT, class _Traits>
183int
185
186template <class _CharT, class _Traits>
189{ return pos_type(-1); }
191template <class _CharT, class _Traits>
195{ return pos_type(-1); }
196
197template <class _CharT, class _Traits>
200{ return this; }
201
203
204#endif
205
206// Local Variables:
207// mode:C++
208// End:
return __n
Definition: _algo.h:75
ptrdiff_t streamsize
Definition: char_traits.h:81
_CharT char_type
Definition: _streambuf.h:53
virtual pos_type seekoff(off_type, ios_base::seekdir, ios_base::openmode=ios_base::in|ios_base::out)
Definition: _streambuf.c:193
virtual streamsize xsputn(const char_type *__s, streamsize __n)
Definition: _streambuf.c:84
virtual int_type uflow()
Definition: _streambuf.c:162
virtual streamsize _M_xsputnc(char_type __c, streamsize __n)
Definition: _streambuf.c:112
virtual void imbue(const locale &)
Definition: _streambuf.c:180
virtual int_type underflow()
Definition: _streambuf.c:170
virtual streamsize xsgetn(char_type *__s, streamsize __n)
Definition: _streambuf.c:54
locale pubimbue(const locale &)
Definition: _streambuf.c:45
int_type _M_snextc_aux()
Definition: _streambuf.c:137
virtual int_type pbackfail(int_type=traits_type::eof())
Definition: _streambuf.c:150
virtual pos_type seekpos(pos_type, ios_base::openmode=ios_base::in|ios_base::out)
Definition: _streambuf.c:188
_Traits::off_type off_type
Definition: _streambuf.h:56
virtual ~basic_streambuf()
Definition: _streambuf.c:40
virtual int_type overflow(int_type=traits_type::eof())
Definition: _streambuf.c:156
virtual streamsize showmanyc()
Definition: _streambuf.c:175
virtual int sync()
Definition: _streambuf.c:184
_Traits::pos_type pos_type
Definition: _streambuf.h:55
_Traits::int_type int_type
Definition: _streambuf.h:54
virtual basic_streambuf< _CharT, _Traits > * setbuf(char_type *, streamsize)
Definition: _streambuf.c:199
int openmode
Definition: _ios_base.h:59
int seekdir
Definition: _ios_base.h:60
Definition: _locale.h:75
#define _STLP_TYPENAME_ON_RETURN_TYPE
Definition: features.h:600
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_END_NAMESPACE
Definition: features.h:503
#define min(a, b)
Definition: monoChain.cc:55
#define __c
Definition: schilyio.h:209