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;
88 file() {
return this->_M_file; }
95 syncungetc(int_type __c);
98 syncputc(int_type __c);
103 int_type __c = this->syncgetc();
104 return this->syncungetc(__c);
111 _M_unget_buf = this->syncgetc();
116 pbackfail(int_type __c = traits_type::eof())
119 const int_type __eof = traits_type::eof();
122 if (traits_type::eq_int_type(__c, __eof))
124 if (!traits_type::eq_int_type(_M_unget_buf, __eof))
125 __ret = this->syncungetc(_M_unget_buf);
130 __ret = this->syncungetc(__c);
133 _M_unget_buf = __eof;
141 overflow(int_type __c = traits_type::eof())
144 if (traits_type::eq_int_type(__c, traits_type::eof()))
146 if (std::fflush(_M_file))
149 __ret = traits_type::not_eof(__c);
152 __ret = this->syncputc(__c);
161 {
return std::fflush(_M_file); }
175 #ifdef _GLIBCXX_USE_LFS
176 if (!fseeko64(_M_file, __off, __whence))
179 if (!fseek(_M_file, __off, __whence))
187 std::ios_base::openmode __mode =
193 inline stdio_sync_filebuf<char>::int_type
194 stdio_sync_filebuf<char>::syncgetc()
195 {
return std::getc(_M_file); }
198 inline stdio_sync_filebuf<char>::int_type
199 stdio_sync_filebuf<char>::syncungetc(int_type __c)
200 {
return std::ungetc(__c, _M_file); }
203 inline stdio_sync_filebuf<char>::int_type
204 stdio_sync_filebuf<char>::syncputc(int_type __c)
205 {
return std::putc(__c, _M_file); }
213 _M_unget_buf = traits_type::to_int_type(__s[__ret - 1]);
215 _M_unget_buf = traits_type::eof();
222 {
return std::fwrite(__s, 1, __n, _M_file); }
224 #ifdef _GLIBCXX_USE_WCHAR_T
226 inline stdio_sync_filebuf<wchar_t>::int_type
227 stdio_sync_filebuf<wchar_t>::syncgetc()
228 {
return std::getwc(_M_file); }
231 inline stdio_sync_filebuf<wchar_t>::int_type
232 stdio_sync_filebuf<wchar_t>::syncungetc(int_type __c)
233 {
return std::ungetwc(__c, _M_file); }
236 inline stdio_sync_filebuf<wchar_t>::int_type
237 stdio_sync_filebuf<wchar_t>::syncputc(int_type __c)
238 {
return std::putwc(__c, _M_file); }
245 const int_type __eof = traits_type::eof();
248 int_type __c = this->syncgetc();
249 if (traits_type::eq_int_type(__c, __eof))
251 __s[__ret] = traits_type::to_char_type(__c);
256 _M_unget_buf = traits_type::to_int_type(__s[__ret - 1]);
258 _M_unget_buf = traits_type::eof();
264 stdio_sync_filebuf<wchar_t>::xsputn(
const wchar_t* __s,
268 const int_type __eof = traits_type::eof();
271 if (traits_type::eq_int_type(this->syncputc(*__s++), __eof))
279 #if _GLIBCXX_EXTERN_TEMPLATE
280 extern template class stdio_sync_filebuf<char>;
281 #ifdef _GLIBCXX_USE_WCHAR_T
282 extern template class stdio_sync_filebuf<wchar_t>;
286 _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...