29 #ifndef _STDIO_SYNC_FILEBUF_H
30 #define _STDIO_SYNC_FILEBUF_H 1
32 #pragma GCC system_header
39 #ifdef _GLIBCXX_USE_WCHAR_T
46 template<typename _CharT, typename _Traits =
std::char_traits<_CharT> >
51 typedef _CharT char_type;
52 typedef _Traits traits_type;
53 typedef typename traits_type::int_type int_type;
54 typedef typename traits_type::pos_type pos_type;
55 typedef typename traits_type::off_type off_type;
59 std::__c_file*
const _M_file;
63 int_type _M_unget_buf;
68 : _M_file(__f), _M_unget_buf(traits_type::eof())
79 file() {
return this->_M_file; }
86 syncungetc(int_type __c);
89 syncputc(int_type __c);
94 int_type __c = this->syncgetc();
95 return this->syncungetc(__c);
102 _M_unget_buf = this->syncgetc();
107 pbackfail(int_type __c = traits_type::eof())
110 const int_type __eof = traits_type::eof();
113 if (traits_type::eq_int_type(__c, __eof))
115 if (!traits_type::eq_int_type(_M_unget_buf, __eof))
116 __ret = this->syncungetc(_M_unget_buf);
121 __ret = this->syncungetc(__c);
124 _M_unget_buf = __eof;
132 overflow(int_type __c = traits_type::eof())
135 if (traits_type::eq_int_type(__c, traits_type::eof()))
137 if (std::fflush(_M_file))
138 __ret = traits_type::eof();
140 __ret = traits_type::not_eof(__c);
143 __ret = this->syncputc(__c);
152 {
return std::fflush(_M_file); }
166 #ifdef _GLIBCXX_USE_LFS
167 if (!fseeko64(_M_file, __off, __whence))
170 if (!fseek(_M_file, __off, __whence))
178 std::ios_base::openmode __mode =
184 inline stdio_sync_filebuf<char>::int_type
185 stdio_sync_filebuf<char>::syncgetc()
186 {
return std::getc(_M_file); }
189 inline stdio_sync_filebuf<char>::int_type
190 stdio_sync_filebuf<char>::syncungetc(int_type __c)
191 {
return std::ungetc(__c, _M_file); }
194 inline stdio_sync_filebuf<char>::int_type
195 stdio_sync_filebuf<char>::syncputc(int_type __c)
196 {
return std::putc(__c, _M_file); }
204 _M_unget_buf = traits_type::to_int_type(__s[__ret - 1]);
206 _M_unget_buf = traits_type::eof();
213 {
return std::fwrite(__s, 1, __n, _M_file); }
215 #ifdef _GLIBCXX_USE_WCHAR_T
217 inline stdio_sync_filebuf<wchar_t>::int_type
218 stdio_sync_filebuf<wchar_t>::syncgetc()
219 {
return std::getwc(_M_file); }
222 inline stdio_sync_filebuf<wchar_t>::int_type
223 stdio_sync_filebuf<wchar_t>::syncungetc(int_type __c)
224 {
return std::ungetwc(__c, _M_file); }
227 inline stdio_sync_filebuf<wchar_t>::int_type
228 stdio_sync_filebuf<wchar_t>::syncputc(int_type __c)
229 {
return std::putwc(__c, _M_file); }
236 const int_type __eof = traits_type::eof();
239 int_type __c = this->syncgetc();
240 if (traits_type::eq_int_type(__c, __eof))
242 __s[__ret] = traits_type::to_char_type(__c);
247 _M_unget_buf = traits_type::to_int_type(__s[__ret - 1]);
249 _M_unget_buf = traits_type::eof();
255 stdio_sync_filebuf<wchar_t>::xsputn(
const wchar_t* __s,
259 const int_type __eof = traits_type::eof();
262 if (traits_type::eq_int_type(this->syncputc(*__s++), __eof))
270 #if _GLIBCXX_EXTERN_TEMPLATE
271 extern template class stdio_sync_filebuf<char>;
272 #ifdef _GLIBCXX_USE_WCHAR_T
273 extern template class stdio_sync_filebuf<wchar_t>;
277 _GLIBCXX_END_NAMESPACE
static const openmode in
Open for input. Default for ifstream and fstream.
ISO C++ entities toplevel namespace is std.
long long streamoff
Type used by fpos, char_traits, and char_traits.
static const seekdir beg
Request a seek relative to the beginning of the stream.
std::__c_file *const file()
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
GNU extensions for public use.
class stdio_sync_filebuf.
fpos< mbstate_t > streampos
File position for char streams.
Class representing stream positions.
static const seekdir cur
Request a seek relative to the current position within the sequence.
static const openmode out
Open for output. Default for ofstream and fstream.