29 #ifndef _STDIO_SYNC_FILEBUF_H 30 #define _STDIO_SYNC_FILEBUF_H 1 32 #ifdef _GLIBCXX_SYSHDR 33 #pragma GCC system_header 43 #ifdef _GLIBCXX_USE_WCHAR_T 47 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
49 _GLIBCXX_BEGIN_NAMESPACE_VERSION
59 template<
typename _CharT,
typename _Traits = std::
char_traits<_CharT> >
66 typedef typename traits_type::int_type
int_type;
67 typedef typename traits_type::pos_type
pos_type;
68 typedef typename traits_type::off_type
off_type;
74 std::__c_file* _M_file;
78 int_type _M_unget_buf;
83 : _M_file(__f), _M_unget_buf(traits_type::eof())
86 #if __cplusplus >= 201103L 89 _M_file(__fb._M_file), _M_unget_buf(__fb._M_unget_buf)
91 __fb._M_file =
nullptr;
92 __fb._M_unget_buf = traits_type::eof();
98 __streambuf_type::operator=(__fb);
99 _M_file = std::__exchange(__fb._M_file,
nullptr);
100 _M_unget_buf = std::__exchange(__fb._M_unget_buf, traits_type::eof());
107 __streambuf_type::swap(__fb);
108 std::swap(_M_file, __fb._M_file);
109 std::swap(_M_unget_buf, __fb._M_unget_buf);
121 file() {
return this->_M_file; }
128 syncungetc(int_type __c);
131 syncputc(int_type __c);
136 int_type __c = this->syncgetc();
137 return this->syncungetc(__c);
144 _M_unget_buf = this->syncgetc();
152 const int_type __eof = traits_type::eof();
155 if (traits_type::eq_int_type(__c, __eof))
157 if (!traits_type::eq_int_type(_M_unget_buf, __eof))
158 __ret = this->syncungetc(_M_unget_buf);
163 __ret = this->syncungetc(__c);
166 _M_unget_buf = __eof;
177 if (traits_type::eq_int_type(__c, traits_type::eof()))
179 if (std::fflush(_M_file))
180 __ret = traits_type::eof();
182 __ret = traits_type::not_eof(__c);
185 __ret = this->syncputc(__c);
194 {
return std::fflush(_M_file); }
208 #ifdef _GLIBCXX_USE_LFS 209 if (!fseeko64(_M_file, __off, __whence))
212 if (!fseek(_M_file, __off, __whence))
220 std::ios_base::openmode __mode =
226 inline stdio_sync_filebuf<char>::int_type
228 {
return std::getc(_M_file); }
231 inline stdio_sync_filebuf<char>::int_type
233 {
return std::ungetc(__c, _M_file); }
236 inline stdio_sync_filebuf<char>::int_type
238 {
return std::putc(__c, _M_file); }
246 _M_unget_buf = traits_type::to_int_type(__s[__ret - 1]);
248 _M_unget_buf = traits_type::eof();
255 {
return std::fwrite(__s, 1, __n, _M_file); }
257 #ifdef _GLIBCXX_USE_WCHAR_T 259 inline stdio_sync_filebuf<wchar_t>::int_type
261 {
return std::getwc(_M_file); }
264 inline stdio_sync_filebuf<wchar_t>::int_type
266 {
return std::ungetwc(__c, _M_file); }
269 inline stdio_sync_filebuf<wchar_t>::int_type
271 {
return std::putwc(__c, _M_file); }
278 const int_type __eof = traits_type::eof();
281 int_type __c = this->syncgetc();
282 if (traits_type::eq_int_type(__c, __eof))
284 __s[__ret] = traits_type::to_char_type(__c);
289 _M_unget_buf = traits_type::to_int_type(__s[__ret - 1]);
291 _M_unget_buf = traits_type::eof();
301 const int_type __eof = traits_type::eof();
304 if (traits_type::eq_int_type(this->syncputc(*__s++), __eof))
312 #if _GLIBCXX_EXTERN_TEMPLATE 313 #pragma GCC diagnostic push 314 #pragma GCC diagnostic ignored "-Wc++11-extensions" 316 #ifdef _GLIBCXX_USE_WCHAR_T 319 #pragma GCC diagnostic pop 322 _GLIBCXX_END_NAMESPACE_VERSION
virtual int_type pbackfail(int_type __c=traits_type::eof())
Tries to back up the input sequence.
virtual int sync()
Synchronizes the buffer arrays with the controlled sequences.
static const openmode in
Open for input. Default for ifstream and fstream.
virtual int_type underflow()
Fetches more data from the controlled sequence.
static const openmode out
Open for output. Default for ofstream and fstream.
fpos< mbstate_t > streampos
File position for char streams.
Provides a layer of compatibility for C.This GNU extension provides extensions for working with stand...
GNU extensions for public use.
traits_type::off_type off_type
static const seekdir cur
Request a seek relative to the current position within the sequence.
traits_type::int_type int_type
traits_type::pos_type pos_type
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
virtual int_type uflow()
Fetches more data from the controlled sequence.
long long streamoff
Type used by fpos, char_traits<char>, and char_traits<wchar_t>.
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.
Class representing stream positions.
virtual int_type overflow(int_type __c=traits_type::eof())
Consumes data from the buffer; writes to the controlled sequence.
The actual work of input and output (interface).