29 #ifndef _STDIO_SYNC_FILEBUF_H
30 #define _STDIO_SYNC_FILEBUF_H 1
32 #pragma GCC system_header
39 #ifdef _GLIBCXX_USE_WCHAR_T
43 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
45 _GLIBCXX_BEGIN_NAMESPACE_VERSION
55 template<
typename _CharT,
typename _Traits = std::
char_traits<_CharT> >
62 typedef typename traits_type::int_type int_type;
63 typedef typename traits_type::pos_type
pos_type;
64 typedef typename traits_type::off_type
off_type;
68 std::__c_file*
const _M_file;
72 int_type _M_unget_buf;
80 #ifdef _GLIBCXX_STDIO_SYNC_FILEBUF_IMPL
91 file() {
return this->_M_file; }
98 syncungetc(int_type __c);
101 syncputc(int_type __c);
106 int_type __c = this->syncgetc();
107 return this->syncungetc(__c);
114 _M_unget_buf = this->syncgetc();
119 pbackfail(int_type __c = traits_type::eof())
122 const int_type __eof = traits_type::eof();
125 if (traits_type::eq_int_type(__c, __eof))
127 if (!traits_type::eq_int_type(_M_unget_buf, __eof))
128 __ret = this->syncungetc(_M_unget_buf);
133 __ret = this->syncungetc(__c);
136 _M_unget_buf = __eof;
144 overflow(int_type __c = traits_type::eof())
147 if (traits_type::eq_int_type(__c, traits_type::eof()))
149 if (std::fflush(_M_file))
152 __ret = traits_type::not_eof(__c);
155 __ret = this->syncputc(__c);
164 {
return std::fflush(_M_file); }
178 #ifdef _GLIBCXX_USE_LFS
179 if (!fseeko64(_M_file, __off, __whence))
182 if (!fseek(_M_file, __off, __whence))
190 std::ios_base::openmode __mode =
196 inline stdio_sync_filebuf<char>::int_type
197 stdio_sync_filebuf<char>::syncgetc()
198 {
return std::getc(_M_file); }
201 inline stdio_sync_filebuf<char>::int_type
202 stdio_sync_filebuf<char>::syncungetc(int_type __c)
203 {
return std::ungetc(__c, _M_file); }
206 inline stdio_sync_filebuf<char>::int_type
207 stdio_sync_filebuf<char>::syncputc(int_type __c)
208 {
return std::putc(__c, _M_file); }
211 #ifndef _GLIBCXX_STDIO_SYNC_FILEBUF_IMPL
219 _M_unget_buf = traits_type::to_int_type(__s[__ret - 1]);
221 _M_unget_buf = traits_type::eof();
226 #ifndef _GLIBCXX_STDIO_SYNC_FILEBUF_IMPL
231 {
return std::fwrite(__s, 1, __n, _M_file); }
233 #ifdef _GLIBCXX_USE_WCHAR_T
235 inline stdio_sync_filebuf<wchar_t>::int_type
236 stdio_sync_filebuf<wchar_t>::syncgetc()
237 {
return std::getwc(_M_file); }
240 inline stdio_sync_filebuf<wchar_t>::int_type
241 stdio_sync_filebuf<wchar_t>::syncungetc(int_type __c)
242 {
return std::ungetwc(__c, _M_file); }
245 inline stdio_sync_filebuf<wchar_t>::int_type
246 stdio_sync_filebuf<wchar_t>::syncputc(int_type __c)
247 {
return std::putwc(__c, _M_file); }
250 #ifndef _GLIBCXX_STDIO_SYNC_FILEBUF_IMPL
257 const int_type __eof = traits_type::eof();
260 int_type __c = this->syncgetc();
261 if (traits_type::eq_int_type(__c, __eof))
263 __s[__ret] = traits_type::to_char_type(__c);
268 _M_unget_buf = traits_type::to_int_type(__s[__ret - 1]);
270 _M_unget_buf = traits_type::eof();
275 #ifndef _GLIBCXX_STDIO_SYNC_FILEBUF_IMPL
279 stdio_sync_filebuf<wchar_t>::xsputn(
const wchar_t* __s,
283 const int_type __eof = traits_type::eof();
286 if (traits_type::eq_int_type(this->syncputc(*__s++), __eof))
294 #if _GLIBCXX_EXTERN_TEMPLATE
295 extern template class stdio_sync_filebuf<char>;
296 #ifdef _GLIBCXX_USE_WCHAR_T
297 extern template class stdio_sync_filebuf<wchar_t>;
301 _GLIBCXX_END_NAMESPACE_VERSION
static const openmode out
Open for output. Default for ofstream and fstream.
traits_type::pos_type pos_type
static const seekdir cur
Request a seek relative to the current position within the sequence.
std::__c_file *const file()
fpos< mbstate_t > streampos
File position for char streams.
static const seekdir beg
Request a seek relative to the beginning of the stream.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
virtual int_type underflow()
Fetches more data from the controlled sequence.
long long streamoff
Type used by fpos, char_traits<char>, and char_traits<wchar_t>.
virtual int_type uflow()
Fetches more data from the controlled sequence.
static const openmode in
Open for input. Default for ifstream and fstream.
The actual work of input and output (interface).
virtual int_type return traits_type::eof()
Tries to back up the input sequence.
virtual int sync()
Synchronizes the buffer arrays with the controlled sequences.
Class representing stream positions.
traits_type::off_type off_type
Provides a layer of compatibility for C.This GNU extension provides extensions for working with stand...