33 #ifndef _GLIBXX_STREAMBUF 34 #define _GLIBXX_STREAMBUF 1 36 #pragma GCC system_header 45 namespace std _GLIBCXX_VISIBILITY(default)
47 _GLIBCXX_BEGIN_NAMESPACE_VERSION
49 template<
typename _CharT,
typename _Traits>
51 __copy_streambufs_eof(basic_streambuf<_CharT, _Traits>*,
52 basic_streambuf<_CharT, _Traits>*,
bool&);
119 template<
typename _CharT,
typename _Traits>
120 class basic_streambuf
141 friend class basic_ios<char_type, traits_type>;
150 template<
bool _IsMove,
typename _CharT2>
151 friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
156 template<
typename _CharT2>
157 friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
162 template<
typename _CharT2,
typename _Traits2>
166 template<
typename _CharT2,
typename _Traits2,
typename _Alloc>
171 template<
typename _CharT2,
typename _Traits2,
typename _Alloc>
213 _M_buf_locale = __loc;
240 {
return this->
setbuf(__s, __n); }
253 {
return this->
seekoff(__off, __way, __mode); }
265 {
return this->
seekpos(__sp, __mode); }
287 return __ret ? __ret : this->
showmanyc();
300 int_type __ret = traits_type::eof();
301 if (__builtin_expect(!traits_type::eq_int_type(this->
sbumpc(),
303 __ret = this->
sgetc();
319 if (__builtin_expect(this->
gptr() < this->
egptr(),
true))
321 __ret = traits_type::to_int_type(*this->
gptr());
325 __ret = this->
uflow();
341 if (__builtin_expect(this->
gptr() < this->
egptr(),
true))
342 __ret = traits_type::to_int_type(*this->
gptr());
358 {
return this->
xsgetn(__s, __n); }
375 const bool __testpos = this->
eback() < this->
gptr();
376 if (__builtin_expect(!__testpos ||
377 !traits_type::eq(__c, this->
gptr()[-1]),
false))
378 __ret = this->
pbackfail(traits_type::to_int_type(__c));
382 __ret = traits_type::to_int_type(*this->
gptr());
400 if (__builtin_expect(this->
eback() < this->
gptr(),
true))
403 __ret = traits_type::to_int_type(*this->
gptr());
427 if (__builtin_expect(this->
pptr() < this->
epptr(),
true))
431 __ret = traits_type::to_int_type(__c);
434 __ret = this->
overflow(traits_type::to_int_type(__c));
451 {
return this->
xsputn(__s, __n); }
464 : _M_in_beg(0), _M_in_cur(0), _M_in_end(0),
465 _M_out_beg(0), _M_out_cur(0), _M_out_end(0),
498 gbump(
int __n) { _M_in_cur += __n; }
509 setg(char_type* __gbeg, char_type* __gnext, char_type* __gend)
545 pbump(
int __n) { _M_out_cur += __n; }
555 setp(char_type* __pbeg, char_type* __pend)
557 _M_out_beg = _M_out_cur = __pbeg;
688 {
return traits_type::eof(); }
702 int_type __ret = traits_type::eof();
703 const bool __testeof = traits_type::eq_int_type(this->
underflow(),
707 __ret = traits_type::to_int_type(*this->
gptr());
725 {
return traits_type::eof(); }
769 {
return traits_type::eof(); }
771 #if _GLIBCXX_USE_DEPRECATED 794 __safe_gbump(
streamsize __n) { _M_in_cur += __n; }
797 __safe_pbump(
streamsize __n) { _M_out_cur += __n; }
799 #if __cplusplus < 201103L 807 operator=(
const basic_streambuf&);
809 #if __cplusplus >= 201103L 811 swap(basic_streambuf& __sb)
813 std::swap(_M_in_beg, __sb._M_in_beg);
814 std::swap(_M_in_cur, __sb._M_in_cur);
815 std::swap(_M_in_end, __sb._M_in_end);
816 std::swap(_M_out_beg, __sb._M_out_beg);
817 std::swap(_M_out_cur, __sb._M_out_cur);
818 std::swap(_M_out_end, __sb._M_out_end);
819 std::swap(_M_buf_locale, __sb._M_buf_locale);
824 #if __cplusplus >= 201103L 825 template<
typename _CharT,
typename _Traits>
829 template<
typename _CharT,
typename _Traits>
832 operator=(
const basic_streambuf&) =
default;
840 #ifdef _GLIBCXX_USE_WCHAR_T 847 _GLIBCXX_END_NAMESPACE_VERSION
virtual int_type pbackfail(int_type __c=traits_type::eof())
Tries to back up the input sequence.
char_type * _M_out_cur
Current put area.
Template class basic_ios, virtual base class for all stream classes.
Provides input iterator semantics for streambufs.
int_type sbumpc()
Getting the next character.
char_type * epptr() const
Access to the put area.
void setp(char_type *__pbeg, char_type *__pend)
Setting the three write area pointers.
streamsize sgetn(char_type *__s, streamsize __n)
Entry point for xsgetn.
Template class basic_ostream.
virtual pos_type seekoff(off_type, ios_base::seekdir, ios_base::openmode=ios_base::in|ios_base::out)
Alters the stream positions.
char_type * pptr() const
Access to the put area.
pos_type pubseekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode=ios_base::in|ios_base::out)
Alters the stream position.
virtual basic_streambuf< char_type, _Traits > * setbuf(char_type *, streamsize)
Manipulates the buffer.
int pubsync()
Calls virtual sync function.
virtual pos_type seekpos(pos_type, ios_base::openmode=ios_base::in|ios_base::out)
Alters the stream positions.
traits_type::off_type off_type
traits_type::pos_type pos_type
void gbump(int __n)
Moving the read position.
Managing sequences of characters and character-like objects.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
void setg(char_type *__gbeg, char_type *__gnext, char_type *__gend)
Setting the three read area pointers.
virtual int_type uflow()
Fetches more data from the controlled sequence.
int_type sgetc()
Getting the next character.
virtual streamsize showmanyc()
Investigating the data available.
basic_streambuf()
Base constructor.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
char_type * gptr() const
Access to the get area.
basic_streambuf * pubsetbuf(char_type *__s, streamsize __n)
Entry points for derived buffer functions.
static const openmode out
Open for output. Default for ofstream and fstream.
static const openmode in
Open for input. Default for ifstream and fstream.
The actual work of input and output (interface).
streamsize sputn(const char_type *__s, streamsize __n)
Entry point for all single-character output functions.
streamsize in_avail()
Looking ahead into the stream.
virtual ~basic_streambuf()
Destructor deallocates no buffer space.
char_type * eback() const
Access to the get area.
char_type * _M_in_cur
Current read area.
char_type * _M_out_end
End of put area.
int_type sputbackc(char_type __c)
Pushing characters back into the input stream.
char_type * _M_out_beg
Start of put area.
int_type sungetc()
Moving backwards in the input stream.
locale getloc() const
Locale access.
int_type snextc()
Getting the next character.
int_type sputc(char_type __c)
Entry point for all single-character output functions.
locale pubimbue(const locale &__loc)
Entry point for imbue().
virtual streamsize xsgetn(char_type *__s, streamsize __n)
Multiple character extraction.
Template class basic_istream.
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
Read a line from stream into a string.
char_type * _M_in_end
End of get area.
virtual int_type overflow(int_type __c=traits_type::eof())
Consumes data from the buffer; writes to the controlled sequence.
Container class for localization functionality.The locale class is first a class wrapper for C librar...
pos_type pubseekpos(pos_type __sp, ios_base::openmode __mode=ios_base::in|ios_base::out)
Alters the stream position.
ISO C++ entities toplevel namespace is std.
void pbump(int __n)
Moving the write position.
virtual int sync()
Synchronizes the buffer arrays with the controlled sequences.
Provides output iterator semantics for streambufs.
basic_streambuf< char_type, traits_type > __streambuf_type
This is a non-standard type.
virtual int_type underflow()
Fetches more data from the controlled sequence.
virtual streamsize xsputn(const char_type *__s, streamsize __n)
Multiple character insertion.
locale _M_buf_locale
Current locale setting.
char_type * egptr() const
Access to the get area.
char_type * pbase() const
Access to the put area.
char_type * _M_in_beg
Start of get area.
virtual void imbue(const locale &__loc)
Changes translations.
traits_type::int_type int_type