30 #ifndef _STDIO_SYNC_FILEBUF_H
31 #define _STDIO_SYNC_FILEBUF_H 1
33 #pragma GCC system_header
40 #ifdef _GLIBCXX_USE_WCHAR_T
44 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
46 _GLIBCXX_BEGIN_NAMESPACE_VERSION
56 template<
typename _CharT,
typename _Traits = std::
char_traits<_CharT> >
63 typedef typename traits_type::int_type
int_type;
64 typedef typename traits_type::pos_type
pos_type;
65 typedef typename traits_type::off_type
off_type;
69 std::__c_file*
const _M_file;
78 : _M_file(__f), _M_unget_buf(traits_type::eof())
89 file() {
return this->_M_file; }
96 syncungetc(int_type __c);
99 syncputc(int_type __c);
105 return this->syncungetc(__c);
112 _M_unget_buf = this->syncgetc();
120 const int_type __eof = traits_type::eof();
123 if (traits_type::eq_int_type(__c, __eof))
125 if (!traits_type::eq_int_type(_M_unget_buf, __eof))
126 __ret = this->syncungetc(_M_unget_buf);
131 __ret = this->syncungetc(__c);
134 _M_unget_buf = __eof;
145 if (traits_type::eq_int_type(__c, traits_type::eof()))
147 if (std::fflush(_M_file))
148 __ret = traits_type::eof();
150 __ret = traits_type::not_eof(__c);
153 __ret = this->syncputc(__c);
162 {
return std::fflush(_M_file); }
176 #ifdef _GLIBCXX_USE_LFS
177 if (!fseeko64(_M_file, __off, __whence))
180 if (!fseek(_M_file, __off, __whence))
188 std::ios_base::openmode __mode =
194 inline stdio_sync_filebuf<char>::int_type
195 stdio_sync_filebuf<char>::syncgetc()
196 {
return std::getc(_M_file); }
199 inline stdio_sync_filebuf<char>::int_type
200 stdio_sync_filebuf<char>::syncungetc(int_type __c)
201 {
return std::ungetc(__c, _M_file); }
204 inline stdio_sync_filebuf<char>::int_type
205 stdio_sync_filebuf<char>::syncputc(int_type __c)
206 {
return std::putc(__c, _M_file); }
214 _M_unget_buf = traits_type::to_int_type(__s[__ret - 1]);
216 _M_unget_buf = traits_type::eof();
223 {
return std::fwrite(__s, 1, __n, _M_file); }
225 #ifdef _GLIBCXX_USE_WCHAR_T
227 inline stdio_sync_filebuf<wchar_t>::int_type
228 stdio_sync_filebuf<wchar_t>::syncgetc()
229 {
return std::getwc(_M_file); }
232 inline stdio_sync_filebuf<wchar_t>::int_type
233 stdio_sync_filebuf<wchar_t>::syncungetc(int_type __c)
234 {
return std::ungetwc(__c, _M_file); }
237 inline stdio_sync_filebuf<wchar_t>::int_type
238 stdio_sync_filebuf<wchar_t>::syncputc(int_type __c)
239 {
return std::putwc(__c, _M_file); }
246 const int_type __eof = traits_type::eof();
249 int_type __c = this->syncgetc();
250 if (traits_type::eq_int_type(__c, __eof))
252 __s[__ret] = traits_type::to_char_type(__c);
257 _M_unget_buf = traits_type::to_int_type(__s[__ret - 1]);
259 _M_unget_buf = traits_type::eof();
265 stdio_sync_filebuf<wchar_t>::xsputn(
const wchar_t* __s,
269 const int_type __eof = traits_type::eof();
272 if (traits_type::eq_int_type(this->syncputc(*__s++), __eof))
280 #if _GLIBCXX_EXTERN_TEMPLATE
281 extern template class stdio_sync_filebuf<char>;
282 #ifdef _GLIBCXX_USE_WCHAR_T
283 extern template class stdio_sync_filebuf<wchar_t>;
287 _GLIBCXX_END_NAMESPACE_VERSION