29 #ifndef _STDIO_SYNC_FILEBUF_H 30 #define _STDIO_SYNC_FILEBUF_H 1 32 #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;
71 std::__c_file* _M_file;
75 int_type _M_unget_buf;
80 : _M_file(__f), _M_unget_buf(traits_type::eof())
83 #if __cplusplus >= 201103L 85 : __streambuf_type(std::move(__fb)),
86 _M_file(__fb._M_file), _M_unget_buf(__fb._M_unget_buf)
88 __fb._M_file =
nullptr;
89 __fb._M_unget_buf = traits_type::eof();
95 __streambuf_type::operator=(__fb);
96 _M_file = std::__exchange(__fb._M_file,
nullptr);
97 _M_unget_buf = std::__exchange(__fb._M_unget_buf, traits_type::eof());
104 __streambuf_type::swap(__fb);
105 std::swap(_M_file, __fb._M_file);
106 std::swap(_M_unget_buf, __fb._M_unget_buf);
118 file() {
return this->_M_file; }
125 syncungetc(int_type __c);
128 syncputc(int_type __c);
133 int_type __c = this->syncgetc();
134 return this->syncungetc(__c);
141 _M_unget_buf = this->syncgetc();
146 pbackfail(int_type __c = traits_type::eof())
149 const int_type __eof = traits_type::eof();
152 if (traits_type::eq_int_type(__c, __eof))
154 if (!traits_type::eq_int_type(_M_unget_buf, __eof))
155 __ret = this->syncungetc(_M_unget_buf);
160 __ret = this->syncungetc(__c);
163 _M_unget_buf = __eof;
171 overflow(int_type __c = traits_type::eof())
174 if (traits_type::eq_int_type(__c, traits_type::eof()))
176 if (std::fflush(_M_file))
177 __ret = traits_type::eof();
179 __ret = traits_type::not_eof(__c);
182 __ret = this->syncputc(__c);
191 {
return std::fflush(_M_file); }
205 #ifdef _GLIBCXX_USE_LFS 206 if (!fseeko64(_M_file, __off, __whence))
209 if (!fseek(_M_file, __off, __whence))
217 std::ios_base::openmode __mode =
223 inline stdio_sync_filebuf<char>::int_type
225 {
return std::getc(_M_file); }
228 inline stdio_sync_filebuf<char>::int_type
230 {
return std::ungetc(__c, _M_file); }
233 inline stdio_sync_filebuf<char>::int_type
235 {
return std::putc(__c, _M_file); }
243 _M_unget_buf = traits_type::to_int_type(__s[__ret - 1]);
245 _M_unget_buf = traits_type::eof();
252 {
return std::fwrite(__s, 1, __n, _M_file); }
254 #ifdef _GLIBCXX_USE_WCHAR_T 256 inline stdio_sync_filebuf<wchar_t>::int_type
258 {
return std::getwc(_M_file); }
261 inline stdio_sync_filebuf<wchar_t>::int_type
263 {
return std::ungetwc(__c, _M_file); }
266 inline stdio_sync_filebuf<wchar_t>::int_type
268 {
return std::putwc(__c, _M_file); }
275 const int_type __eof = traits_type::eof();
279 if (traits_type::eq_int_type(__c, __eof))
281 __s[__ret] = traits_type::to_char_type(__c);
286 _M_unget_buf = traits_type::to_int_type(__s[__ret - 1]);
288 _M_unget_buf = traits_type::eof();
298 const int_type __eof = traits_type::eof();
301 if (traits_type::eq_int_type(this->syncputc(*__s++), __eof))
309 #if _GLIBCXX_EXTERN_TEMPLATE 311 #ifdef _GLIBCXX_USE_WCHAR_T 316 _GLIBCXX_END_NAMESPACE_VERSION
Provides a layer of compatibility for C.This GNU extension provides extensions for working with stand...
static const openmode out
Open for output. Default for ofstream and fstream.
static const openmode in
Open for input. Default for ifstream and fstream.
traits_type::off_type off_type
virtual int sync()
Synchronizes the buffer arrays with the controlled sequences.
virtual int_type underflow()
Fetches more data from the controlled sequence.
The actual work of input and output (interface).
static const seekdir beg
Request a seek relative to the beginning of the stream.
GNU extensions for public use.
traits_type::int_type int_type
virtual int_type uflow()
Fetches more data from the controlled sequence.
static const seekdir cur
Request a seek relative to the current position within the sequence.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
traits_type::pos_type pos_type
fpos< mbstate_t > streampos
File position for char streams.
long long streamoff
Type used by fpos, char_traits<char>, and char_traits<wchar_t>.
Class representing stream positions.