STD::WSTRINGBUF(3cxx)
π
β¨ std::basic_stringbuf< _CharT, _Traits, _Alloc > β the (3cxx) page, bestie β¨π
πΈ NAME πΈ
std::basic_stringbuf< _CharT, _Traits, _Alloc > β the actual work of input and output (for std::string). Like, that's literally her job description, no cap. π
π SYNOPSIS π
#include <sstream>
Inherits std::basic_streambuf< _CharT, _Traits >. Periodt. π
π¦ Public Types π¦
typedef __string_type::size_type __size_typetypedef basic_streambuf< char_type, traits_type > __streambuf_typetypedef basic_string< char_type, _Traits, _Alloc > __string_typetypedef _Alloc allocator_typetypedef _CharT char_typetypedef traits_type::int_type int_typetypedef traits_type::off_type off_typetypedef traits_type::pos_type pos_typetypedef _Traits traits_type
π§ Public Member Functions π§
basic_stringbuf ()β starts with an empty string buffer. Blank-slate main character energy. β¨basic_stringbuf (basic_stringbuf &&__rhs)β the move constructor, she's taking what's yours and making it hers, respectfully. π«Άbasic_stringbuf (const __string_type &__str, ios_base::openmode __mode=ios_base::in|ios_base::out)β starts with an existing string buffer. Glow-up from a string you already had. πbasic_stringbuf (const basic_stringbuf &)=deleteβ copy ctor? deleted. Not invited to the party, sorry bestie. πbasic_stringbuf (ios_base::openmode __mode)β starts with an empty string buffer.locale getloc () constβ locale access. It's giving "what language are we speaking rn". πstreamsize in_avail ()β looking ahead into the stream. Peeking without committing, iykyk. πbasic_stringbuf & operator= (basic_stringbuf &&__rhs)β move assignment, she's claiming her spot. πbasic_stringbuf & operator= (const basic_stringbuf &)=deleteβ copy assignment? also deleted. Blocked. πlocale pubimbue (const locale &__loc)β entry point forimbue().int_type sbumpc ()β getting the next character.int_type sgetc ()β getting the next character.streamsize sgetn (char_type *__s, streamsize __n)β entry point forxsgetn.int_type snextc ()β getting the next character.int_type sputbackc (char_type __c)β pushing characters back into the input stream. Rewind vibes. βͺint_type sputc (char_type __c)β entry point for all single-character output functions.streamsize sputn (const char_type *__s, streamsize __n)β entry point for all single-character output functions.__string_type str () constβ copying out the string buffer. Snatch the contents, bestie. πvoid str (const __string_type &__s)β setting a new buffer.int_type sungetc ()β moving backwards in the input stream.void swap (basic_stringbuf &__rhs) noexcept(_Noexcept_swap::value)β trading places, but make it noexcept.basic_string_view< char_type, traits_type > view () const noexceptβ get a view of the goods, no copy involved. β¨basic_streambuf * pubsetbuf (char_type *__s, streamsize __n)β entry points for derived buffer functions.pos_type pubseekoff (off_type __off, ios_base::seekdir __way, ios_base::openmode __mode=ios_base::in|ios_base::out)β alters the stream position.pos_type pubseekpos (pos_type __sp, ios_base::openmode __mode=ios_base::in|ios_base::out)β alters the stream position.int pubsync ()β calls virtualsyncfunction.
π Protected Member Functions π
void __safe_gbump (streamsize __n)β the careful version, extra cautious, π§ certified.void __safe_pbump (streamsize __n)β same energy but for the put side.void _M_pbump (char_type *__pbeg, char_type *__pend, off_type __off)β internal plumbing, don't @ me.void _M_stringbuf_init (ios_base::openmode __mode)β gets the stringbuf set up.void _M_sync (char_type *__base, __size_type __i, __size_type __o)β syncing the internals.void _M_update_egptr ()β updates that end pointer, slay.void gbump (int __n)β moving the read position.virtual void imbue (const locale &__loc)β changes translations.virtual int_type overflow (int_type __c=traits_type::eof())β consumes data from the buffer; writes to the controlled sequence. Lowkey the workhorse. π₯virtual int_type pbackfail (int_type __c=traits_type::eof())β tries to back up the input sequence. It's giving "attempted rewind, results may vary". πvoid pbump (int __n)β moving the write position.virtual pos_type seekoff (off_type __off, ios_base::seekdir __way, ios_base::openmode __mode=ios_base::in|ios_base::out)β alters the stream positions.virtual pos_type seekpos (pos_type __sp, ios_base::openmode __mode=ios_base::in|ios_base::out)β alters the stream positions.virtual __streambuf_type * setbuf (char_type *__s, streamsize __n)β manipulates the buffer.void setg (char_type *__gbeg, char_type *__gnext, char_type *__gend)β setting the three read area pointers.void setp (char_type *__pbeg, char_type *__pend)β setting the three write area pointers.virtual streamsize showmanyc ()β investigating the data available. Detective era. πvoid swap (basic_streambuf &__sb)β the base-class swap.virtual int sync ()β synchronizes the buffer arrays with the controlled sequences.virtual int_type uflow ()β fetches more data from the controlled sequence.virtual int_type underflow ()β fetches more data from the controlled sequence.virtual streamsize xsgetn (char_type *__s, streamsize __n)β multiple character extraction.virtual streamsize xsputn (const char_type *__s, streamsize __n)β multiple character insertion.char_type * eback () constβ access to the get area.char_type * gptr () constβ access to the get area.char_type * egptr () constβ access to the get area.char_type * pbase () constβ access to the put area.char_type * pptr () constβ access to the put area.char_type * epptr () constβ access to the put area.
π Protected Attributes π
locale _M_buf_localeβ current locale setting. π₯°char_type * _M_in_begβ start of get area.char_type * _M_in_curβ current read area.char_type * _M_in_endβ end of get area.ios_base::openmode _M_modeβ place to stash in || out || in | out settings for current stringbuf.char_type * _M_out_begβ start of put area.char_type * _M_out_curβ current put area.char_type * _M_out_endβ end of put area.__string_type _M_stringβ the string itself, obviously. π
π Detailed Description π
template<typename _CharT, typename _Traits, typename _Alloc>
class std::basic_stringbuf< _CharT, _Traits, _Alloc >
"The actual work of input and output (for std::string)." β yes that's the class, and yes she said what she said. π€
β¨ Template Parameters β¨
- _CharT β type of character stream.
- _Traits β traits for character type, defaults to
char_traits<_CharT>. - _Alloc β allocator type, defaults to
allocator<_CharT>.
This class associates either or both of its input and output sequences with a sequence of characters, which can be initialized from, or made available as, a std::basic_string. (Paraphrased from [27.7.1]/1.) So she's basically the bridge between your string and your stream, and she's booked and busy. π
For this class, open modes (of type ios_base::openmode) have in set if the input sequence can be read, and out set if the output sequence can be written. Easy way to remember: in = can read, out = can write. That's the whole vibe check. β
π Constructor & Destructor Documentation π
πΈ template<typename _CharT , typename _Traits , typename _Alloc > std::basic_stringbuf< _CharT, _Traits, _Alloc >::basic_stringbuf () [inline]
Starts with an empty string buffer. The default constructor initializes the parent class using its own default ctor. Fresh start, empty canvas, main character energy. β¨
π¦ template<typename _CharT , typename _Traits , typename _Alloc > std::basic_stringbuf< _CharT, _Traits, _Alloc >::basic_stringbuf (ios_base::openmode __mode) [inline], [explicit]
Starts with an empty string buffer.
Parameters
__modeβ whether the buffer can read, or write, or both.
The default constructor initializes the parent class using its own default ctor.
π§ template<typename _CharT , typename _Traits , typename _Alloc > std::basic_stringbuf< _CharT, _Traits, _Alloc >::basic_stringbuf (const __string_type & __str, ios_base::openmode __mode = ios_base::in | ios_base::out) [inline], [explicit]
Starts with an existing string buffer. Glow-up from a string you already had, we love a head start. π
Parameters
__strβ a string to copy as a starting buffer.__modeβ whether the buffer can read, or write, or both.
This constructor initializes the parent class using its own default ctor.
π« Member Function Documentation π«
β template<typename _CharT , typename _Traits > char_type * std::basic_streambuf< _CharT, _Traits >::eback () const [inline], [protected], [inherited]
Access to the get area. These functions are only available to other protected functions, including derived classes. So like, protected-only access, very exclusive guest list. πͺβ¨
eback()returns the beginning pointer for the input sequencegptr()returns the next pointer for the input sequenceegptr()returns the end pointer for the input sequence
References std::basic_streambuf< _CharT, _Traits >::_M_in_beg.
Referenced by std::basic_streambuf< _CharT, _Traits >::sputbackc(), and std::basic_streambuf< _CharT, _Traits >::sungetc().
π template<typename _CharT , typename _Traits > char_type * std::basic_streambuf< _CharT, _Traits >::egptr () const [inline], [protected], [inherited]
Access to the get area. These functions are only available to other protected functions, including derived classes. Same exclusive list, different pointer. π
eback()returns the beginning pointer for the input sequencegptr()returns the next pointer for the input sequenceegptr()returns the end pointer for the input sequence
References std::basic_streambuf< _CharT, _Traits >::_M_in_end.
Referenced by std::basic_streambuf< _CharT, _Traits >::in_avail(), std::basic_streambuf< _CharT, _Traits >::sbumpc(), std::basic_streambuf< _CharT, _Traits >::sgetc(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::showmanyc(), and std::wbuffer_convert< _Codecvt, _Elem, _Tr >::underflow().
π₯ template<typename _CharT , typename _Traits > char_type * std::basic_streambuf< _CharT, _Traits >::epptr () const [inline], [protected], [inherited]
Access to the put area. These functions are only available to other protected functions, including derived classes. Put area edition, get area found irrelevant. π
pbase()returns the beginning pointer for the output sequencepptr()returns the next pointer for the output sequenceepptr()returns the end pointer for the output sequence
References std::basic_streambuf< _CharT, _Traits >::_M_out_end.
Referenced by std::basic_streambuf< _CharT, _Traits >::sputc().
π«Ά template<typename _CharT , typename _Traits > void std::basic_streambuf< _CharT, _Traits >::gbump (int __n) [inline], [protected], [inherited]
Moving the read position.
Parameters
__nβ the delta by which to move.
This just advances the read position without returning any data. She's just scooting forward, not handing you anything. πΆββοΈ
References std::basic_streambuf< _CharT, _Traits >::_M_in_cur.
Referenced by std::basic_streambuf< _CharT, _Traits >::sbumpc(), std::basic_streambuf< _CharT, _Traits >::sputbackc(), std::basic_streambuf< _CharT, _Traits >::sungetc(), and std::basic_streambuf< _CharT, _Traits >::uflow().
π template<typename _CharT , typename _Traits > locale std::basic_streambuf< _CharT, _Traits >::getloc () const [inline], [inherited]
Locale access.
Returns
The current locale in effect.
If pubimbue(loc) has been called, then the most recent loc is returned. Otherwise the global locale in effect at the time of construction is returned. So it's either the one you set or the one you were born with, no in-between. π
References std::basic_streambuf< _CharT, _Traits >::_M_buf_locale.
Referenced by std::basic_streambuf< _CharT, _Traits >::pubimbue().
template<typename _CharT , typename _Traits > char_type *
std::basic_streambuf< _CharT, _Traits >::gptr () const
[inline], [protected], [inherited]
okay so this is your β¨access to the get areaβ¨ moment. These functions are literally only available to other protected functions, including derived classes β so like, it's a members-only lounge, not a public party π«Ά
eback()β returns the beginning pointer for the input sequencegptr()β returns the next pointer for the input sequenceegptr()β returns the end pointer for the input sequence
References std::basic_streambuf< _CharT, _Traits >::_M_in_cur.
Referenced by std::basic_streambuf< _CharT, _Traits >::in_avail(), std::basic_streambuf< _CharT, _Traits >::sbumpc(), std::basic_streambuf< _CharT, _Traits >::sgetc(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::showmanyc(), std::basic_streambuf< _CharT, _Traits >::sputbackc(), std::basic_streambuf< _CharT, _Traits >::sungetc(), std::basic_streambuf< _CharT, _Traits >::uflow(), and std::wbuffer_convert< _Codecvt, _Elem, _Tr >::underflow().
template<typename _CharT , typename _Traits > virtual void
std::basic_streambuf< _CharT, _Traits >::imbue (const locale & __loc)
[inline], [protected], [virtual], [inherited]
π Changes translations.
Parameters
__locβ A new locale.
Translations done during I/O which depend on the current locale are changed by this call. The standard adds, Between invocations of this function a class derived from streambuf can safely cache results of calls to locale functions and to members of facets so obtained. (iykyk β the standard really said that π)
Note β Base class version does nothing. Like, literally nothing. Iconic in its laziness tbh.
Reimplemented in std::basic_filebuf< _CharT, _Traits >, std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >, std::basic_filebuf< _CharT, std::char_traits< _CharT > >, and std::basic_filebuf< char_type, traits_type >.
Referenced by std::basic_streambuf< _CharT, _Traits >::pubimbue().
template<typename _CharT , typename _Traits > streamsize
std::basic_streambuf< _CharT, _Traits >::in_avail ()
[inline], [inherited]
π Looking ahead into the stream.
Returns
The number of characters available.
If a read position is available, returns the number of characters available for reading before the buffer must be refilled. Otherwise returns the derived showmanyc().
References std::basic_streambuf< _CharT, _Traits >::egptr(), std::basic_streambuf< _CharT, _Traits >::gptr(), and std::basic_streambuf< _CharT, _Traits >::showmanyc().
template<class _CharT , class _Traits , class _Alloc > basic_stringbuf<
_CharT, _Traits, _Alloc >::int_type std::basic_stringbuf< _CharT,
_Traits, _Alloc >::overflow (int_type __c = traits_type::eof())
[protected], [virtual]
π₯ Consumes data from the buffer; writes to the controlled sequence. This is the main character of output buffering fr fr.
Parameters
__cβ An additional character to consume.
Returns
eof() to indicate failure, something else (usually __c, or not_eof())
Informally, this function is called when the output buffer is full (or does not exist, as buffering need not actually be done). If a buffer exists, it is consumed, with some effect on the controlled sequence. (Typically, the buffer is written out to the sequence verbatim.) In either case, the character c is also written out, if __c is not eof().
For a formal definition of this function, see a good text such as Langer & Kreft, or [27.5.2.4.5]/3-7.
A functioning output streambuf can be created by overriding only this function (no buffer area will be used) β that's the slay shortcut, bestie π
Note β Base class version does nothing, returns eof().
Reimplemented from std::basic_streambuf< _CharT, _Traits >.
References std::basic_string< _CharT, _Traits, _Alloc >::assign(), std::ios_base::in, std::max(), std::min(), std::ios_base::out, std::basic_string< _CharT, _Traits, _Alloc >::push_back(), and std::basic_string< _CharT, _Traits, _Alloc >::reserve().
template<class _CharT , class _Traits , class _Alloc > basic_stringbuf<
_CharT, _Traits, _Alloc >::int_type std::basic_stringbuf< _CharT,
_Traits, _Alloc >::pbackfail (int_type __c = traits_type::eof())
[protected], [virtual]
πΈ Tries to back up the input sequence. yes it's giving "undo" energy but for chars.
Parameters
__cβ The character to be inserted back into the sequence.
Returns
eof() on failure, some other value on success
Postcondition
The constraints of gptr(), eback(), and pptr() are the same as for underflow().
Note β Base class version does nothing, returns eof(). (again. king of doing nothing π)
Reimplemented from std::basic_streambuf< _CharT, _Traits >.
References std::ios_base::out.
template<typename _CharT , typename _Traits > char_type *
std::basic_streambuf< _CharT, _Traits >::pbase () const
[inline], [protected], [inherited]
β¨ Access to the put area. These functions are only available to other protected functions, including derived classes. same VIP situation as the get area π
pbase()β returns the beginning pointer for the output sequencepptr()β returns the next pointer for the output sequenceepptr()β returns the end pointer for the output sequence
References std::basic_streambuf< _CharT, _Traits >::_M_out_beg.
Referenced by std::basic_stringbuf< _CharT, _Traits, _Alloc >::str().
template<typename _CharT , typename _Traits > void std::basic_streambuf<
_CharT, _Traits >::pbump (int __n)
[inline], [protected], [inherited]
π Moving the write position.
Parameters
__nβ The delta by which to move.
This just advances the write position without returning any data. lowkey just vibes forward and gives you nothing back π
References std::basic_streambuf< _CharT, _Traits >::_M_out_cur.
Referenced by std::basic_streambuf< _CharT, _Traits >::sputc().
template<typename _CharT , typename _Traits > char_type *
std::basic_streambuf< _CharT, _Traits >::pptr () const
[inline], [protected], [inherited]
β¨ Access to the put area. These functions are only available to other protected functions, including derived classes.
pbase()β returns the beginning pointer for the output sequencepptr()β returns the next pointer for the output sequenceepptr()β returns the end pointer for the output sequence
References std::basic_streambuf< _CharT, _Traits >::_M_out_cur.
Referenced by std::basic_streambuf< _CharT, _Traits >::sputc().
template<typename _CharT , typename _Traits > locale std::basic_streambuf<
_CharT, _Traits >::pubimbue (const locale & __loc)
[inline], [inherited]
π¦ Entry point for imbue().
Parameters
__locβ The new locale.
Returns
The previous locale.
Calls the derived imbue(__loc).
References std::basic_streambuf< _CharT, _Traits >::_M_buf_locale, std::basic_streambuf< _CharT, _Traits >::getloc(), and std::basic_streambuf< _CharT, _Traits >::imbue().
template<typename _CharT , typename _Traits > pos_type std::basic_streambuf<
_CharT, _Traits >::pubseekoff (off_type __off, ios_base::seekdir __way,
ios_base::openmode __mode = ios_base::in | ios_base::out)
[inline], [inherited]
π Alters the stream position.
Parameters
__offβ Offset.__wayβ Value forios_base::seekdir.__modeβ Value forios_base::openmode.
Calls virtual seekoff function.
References std::basic_streambuf< _CharT, _Traits >::seekoff().
template<typename _CharT , typename _Traits > pos_type std::basic_streambuf<
_CharT, _Traits >::pubseekpos (pos_type __sp, ios_base::openmode __mode
= ios_base::in | ios_base::out)
[inline], [inherited]
π Alters the stream position.
Parameters
__spβ Position__modeβ Value forios_base::openmode.
Calls virtual seekpos function.
References std::basic_streambuf< _CharT, _Traits >::seekpos().
template<typename _CharT , typename _Traits > basic_streambuf *
std::basic_streambuf< _CharT, _Traits >::pubsetbuf (char_type * __s,
streamsize __n)
[inline], [inherited]
π Entry points for derived buffer functions. The public versions of pubfoo dispatch to the protected derived foo member functions, passing the arguments (if any) and returning the result unchanged. it's giving receptionist energy β takes your message, hands it off, returns the answer untouched π
References std::basic_streambuf< _CharT, _Traits >::setbuf().
template<typename _CharT , typename _Traits > int std::basic_streambuf<
_CharT, _Traits >::pubsync ()
[inline], [inherited]
Calls virtual sync function.
References std::basic_streambuf< _CharT, _Traits >::sync().
Referenced by std::basic_istream< _CharT, _Traits >::sync().
template<typename _CharT , typename _Traits > int_type std::basic_streambuf<
_CharT, _Traits >::sbumpc ()
[inline], [inherited]
π Getting the next character.
Returns
The next character, or eof.
If the input read position is available, returns that character and increments the read pointer, otherwise calls and returns uflow().
References std::basic_streambuf< _CharT, _Traits >::egptr(), std::basic_streambuf< _CharT, _Traits >::gbump(), std::basic_streambuf< _CharT, _Traits >::gptr(), and std::basic_streambuf< _CharT, _Traits >::uflow().
Referenced by std::basic_istream< char >::get(), std::basic_istream< _CharT, _Traits >::ignore(), std::basic_streambuf< _CharT, _Traits >::snextc(), and std::basic_istream< char >::sync().
template<class _CharT , class _Traits , class _Alloc > basic_stringbuf<
_CharT, _Traits, _Alloc >::pos_type std::basic_stringbuf< _CharT,
_Traits, _Alloc >::seekoff (off_type, ios_base::seekdir,
ios_base::openmode = ios_base::in | ios_base::out)
[protected], [virtual]
π Alters the stream positions. Each derived class provides its own appropriate behavior.
Note β Base class version does nothing, returns a pos_type that represents an invalid stream position. so like, if you forget to override this, you get β¨nothingβ¨ and an invalid position. no cap.
Reimplemented from std::basic_streambuf< _CharT, _Traits >.
References std::ios_base::cur, std::ios_base::end, std::ios_base::in, and std::ios_base::out.
template<class _CharT , class _Traits , class _Alloc > basic_stringbuf<
_CharT, _Traits, _Alloc >::pos_type std::basic_stringbuf< _CharT,
_Traits, _Alloc >::seekpos (pos_type, ios_base::openmode = ios_base::in
| ios_base::out)
[protected], [virtual]
π Alters the stream positions. Each derived class provides its own appropriate behavior.
Note β Base class version does nothing, returns a pos_type that represents an invalid stream position.
Reimplemented from std::basic_streambuf< _CharT, _Traits >.
References std::ios_base::in, and std::ios_base::out.
template<typename _CharT , typename _Traits , typename _Alloc > virtual
__streambuf_type * std::basic_stringbuf< _CharT, _Traits, _Alloc
>::setbuf (char_type * __s, streamsize __n)
[inline], [protected], [virtual]
π Manipulates the buffer.
Parameters
__sβ Pointer to a buffer area.__nβ Size of__s.
Returns
this
If no buffer has already been created, and both __s and __n are non-zero, then __s is used as a buffer; see https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html#io.streambuf.buffering for more.
Reimplemented from std::basic_streambuf< _CharT, _Traits >.
Quick leftover reference from the last function: it references std::basic_string< _CharT, _Traits, _Alloc >::clear().
π«Ά setg β setting the three read area pointers
template<typename _CharT , typename _Traits > void std::basic_streambuf< _CharT, _Traits >::setg (char_type * __gbeg, char_type * __gnext, char_type * __gend) [inline], [protected], [inherited]
Bestie, this is the βset the read squadβ function. Itβs tagged [inline], [protected], and [inherited].
Parameters:
__gbegβ A pointer.__gnextβ A pointer.__gendβ A pointer.
Postcondition: __gbeg == eback(), __gnext == gptr(), and __gend == egptr().
References: std::basic_streambuf< _CharT, _Traits >::_M_in_beg, std::basic_streambuf< _CharT, _Traits >::_M_in_cur, and std::basic_streambuf< _CharT, _Traits >::_M_in_end.
Referenced by: std::wbuffer_convert< _Codecvt, _Elem, _Tr >::wbuffer_convert().
π
setp β setting the three write area pointers
template<typename _CharT , typename _Traits > void std::basic_streambuf< _CharT, _Traits >::setp (char_type * __pbeg, char_type * __pend) [inline], [protected], [inherited]
This is the write-side twin. Qualifiers: [inline], [protected], [inherited].
Parameters:
__pbegβ A pointer.__pendβ A pointer.
Postcondition: __pbeg == pbase(), __pbeg == pptr(), and __pend == epptr(). Yep, the page literally says __pbeg twice β Iβm keeping it exactly as written π«Ά.
References: std::basic_streambuf< _CharT, _Traits >::_M_out_beg, std::basic_streambuf< _CharT, _Traits >::_M_out_cur, and std::basic_streambuf< _CharT, _Traits >::_M_out_end.
Referenced by: std::wbuffer_convert< _Codecvt, _Elem, _Tr >::wbuffer_convert().
πΈ sgetc β getting the next character
template<typename _CharT , typename _Traits > int_type std::basic_streambuf< _CharT, _Traits >::sgetc () [inline], [inherited]
Returns: The next character, or eof.
The vibe: if the input read position is available, it returns that character. Otherwise it calls and returns underflow(). It does not move the read position after fetching the character. Iconic behavior, no notes.
References: std::basic_streambuf< _CharT, _Traits >::egptr(), std::basic_streambuf< _CharT, _Traits >::gptr(), and std::basic_streambuf< _CharT, _Traits >::underflow().
Referenced by: std::basic_istream< char >::get(), std::basic_istream< _CharT, _Traits >::get(), std::basic_istream< _CharT, _Traits >::ignore(), std::basic_istream< char >::readsome(), and std::basic_streambuf< _CharT, _Traits >::snextc().
π¦ sgetn β entry point for xsgetn
template<typename _CharT , typename _Traits > streamsize std::basic_streambuf< _CharT, _Traits >::sgetn (char_type * __s, streamsize __n) [inline], [inherited]
Parameters:
__sβ A buffer area.__nβ A count.
Returns: xsgetn(__s,__n). The effect is to fill __s[0] through __s[__n-1] with characters from the input sequence, if possible.
References: std::basic_streambuf< _CharT, _Traits >::xsgetn().
β¨ showmanyc β investigating the data available
template<typename _CharT , typename _Traits , typename _Alloc > virtual streamsize std::basic_stringbuf< _CharT, _Traits, _Alloc >::showmanyc () [inline], [protected], [virtual]
Returns: An estimate of the number of characters available in the input sequence, or -1.
If it returns a positive value, then successive calls to underflow() will not return traits::eof() until at least that number of characters have been supplied. If showmanyc() returns -1, then calls to underflow() or uflow() will fail. [27.5.2.4.3]/1
Note: Base class version does nothing, returns zero.
Note: The standard adds that the intention is not only that the calls [tounderfloworuflow] will not returneof()but that they will return immediately.
Note: The standard adds that the morphemes ofshowmanycarees-how-many-see, notshow-manic. Not me making this up, bestie π.
Reimplemented from: std::basic_streambuf< _CharT, _Traits >.
References: std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_mode, std::basic_streambuf< _CharT, _Traits >::egptr(), std::basic_streambuf< _CharT, _Traits >::gptr(), and std::ios_base::in.
π snextc β getting the next character
template<typename _CharT , typename _Traits > int_type std::basic_streambuf< _CharT, _Traits >::snextc () [inline], [inherited]
Returns: The next character, or eof.
It calls sbumpc(), and if that function returns traits::eof(), so does this function. Otherwise, it calls sgetc().
References: std::basic_streambuf< _CharT, _Traits >::sbumpc() and std::basic_streambuf< _CharT, _Traits >::sgetc().
Referenced by: std::basic_istream< char >::get(), std::basic_istream< char >::ignore(), std::basic_istream< char >::operator>>(), and std::basic_istream< char >::putback().
π sputbackc β pushing characters back into the input stream
template<typename _CharT , typename _Traits > int_type std::basic_streambuf< _CharT, _Traits >::sputbackc (char_type __c) [inline], [inherited]
Parameters:
__cβ The character to push back.
Returns: The previous character, if possible.
Similar to sungetc(), but __c is pushed onto the stream instead of the previous character. If successful, the next character fetched from the input stream will be __c.
References: std::basic_streambuf< _CharT, _Traits >::eback(), std::basic_streambuf< _CharT, _Traits >::gbump(), std::basic_streambuf< _CharT, _Traits >::gptr(), and std::basic_streambuf< _CharT, _Traits >::pbackfail().
Referenced by: std::basic_istream< _CharT, _Traits >::putback().
π₯ sputc β entry point for all single-character output functions
template<typename _CharT , typename _Traits > int_type std::basic_streambuf< _CharT, _Traits >::sputc (char_type __c) [inline], [inherited]
Parameters:
__cβ A character to output.
Returns: __c, if possible.
One of two public output functions.
If a write position is available for the output sequence (i.e., the buffer is not full), it stores __c in that position, increments the position, and returns traits::to_int_type(__c). If a write position is not available, it returns overflow(__c).
References: std::basic_streambuf< _CharT, _Traits >::epptr(), std::basic_streambuf< _CharT, _Traits >::overflow(), std::basic_streambuf< _CharT, _Traits >::pbump(), and std::basic_streambuf< _CharT, _Traits >::pptr().
Referenced by: std::wbuffer_convert< _Codecvt, _Elem, _Tr >::overflow().
π sputn β entry point for all single-character output functions
template<typename _CharT , typename _Traits > streamsize std::basic_streambuf< _CharT, _Traits >::sputn (const char_type * __s, streamsize __n) [inline], [inherited]
The page literally says βEntry point for all single-character output functionsβ here too β Iβm not fixing it, just preserving it π.
Parameters:
__sβ A buffer read area.__nβ A count.
One of two public output functions.
Returns: xsputn(__s,__n). The effect is to write __s[0] through __s[__n-1] to the output sequence, if possible.
References: std::basic_streambuf< _CharT, _Traits >::xsputn().
π str β copying out the string buffer
template<typename _CharT , typename _Traits , typename _Alloc > __string_type std::basic_stringbuf< _CharT, _Traits, _Alloc >::str () const [inline]
Returns: A copy of one of the underlying sequences.
If the buffer is only created in input mode, the underlying character sequence is equal to the input sequence; otherwise, it is equal to the output sequence. [27.7.1.2]/1
References: std::basic_string< _CharT, _Traits, _Alloc >::assign(), std::basic_string< _CharT, _Traits, _Alloc >::get_allocator(), and std::basic_streambuf< _CharT, _Traits >::pbase().
π str β setting a new buffer
template<typename _CharT , typename _Traits , typename _Alloc > void std::basic_stringbuf< _CharT, _Traits, _Alloc >::str (const __string_type & __s) [inline]
Parameters:
__sβ The string to use as a new sequence.
Deallocates any previous stored sequence, then copies s to use as a new one.
References: std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_mode, std::basic_string< _CharT, _Traits, _Alloc >::assign(), std::basic_string< _CharT, _Traits, _Alloc >::data(), and std::basic_string< _CharT, _Traits, _Alloc >::size().
π§ sungetc β moving backwards in the input stream
template<typename _CharT , typename _Traits > int_type std::basic_streambuf< _CharT, _Traits >::sungetc () [inline], [inherited]
Returns: The previous character, if possible.
If a putback position is available, this function decrements the input pointer and returns that character. Otherwise, it calls and returns pbackfail(). The effect is to unget the last character gotten.
References: std::basic_streambuf< _CharT, _Traits >::eback(), std::basic_streambuf< _CharT, _Traits >::gbump(), std::basic_streambuf< _CharT, _Traits >::gptr(), and std::basic_streambuf< _CharT, _Traits >::pbackfail().
π©΅ sync β synchronizes the buffer arrays with the controlled sequences
template<typename _CharT , typename _Traits > virtual int std::basic_streambuf< _CharT, _Traits >::sync () [inline], [protected], [virtual], [inherited]
Returns: -1 on failure.
Each derived class provides its own appropriate behavior, including the definition of failure.
Note: Base class version does nothing, returns zero.
Reimplemented in: std::wbuffer_convert< _Codecvt, _Elem, _Tr >, __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits >, std::basic_filebuf< _CharT, _Traits >, std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >, std::basic_filebuf< _CharT, std::char_traits< _CharT > >, and std::basic_filebuf< char_type, traits_type >.
Referenced by: std::basic_streambuf< _CharT, _Traits >::pubsync().
π« uflow β fetches more data from the controlled sequence
template<typename _CharT , typename _Traits > virtual int_type std::basic_streambuf< _CharT, _Traits >::uflow () [inline], [protected], [virtual], [inherited]
Returns: The first character from the pending sequence.
Informally, this function does the same thing as underflow(), and in fact is required to call that function. It also returns the new character, like underflow() does. However, this function also moves the read position forward by one.
Reimplemented in: __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits >.
References: std::basic_streambuf< _CharT, _Traits >::gbump(), std::basic_streambuf< _CharT, _Traits >::gptr(), and std::basic_streambuf< _CharT, _Traits >::underflow().
Referenced by: std::basic_streambuf< _CharT, _Traits >::sbumpc().
π underflow β fetches more data from the controlled sequence
template<class _CharT , class _Traits , class _Alloc > basic_stringbuf< _CharT, _Traits, _Alloc >::int_type std::basic_stringbuf< _CharT, _Traits, _Alloc >::underflow () [protected], [virtual]
Returns: The first character from the pending sequence.
Informally, this function is called when the input buffer is exhausted (or does not exist, as buffering need not actually be done). If a buffer exists, it is refilled. In either case, the next available character is returned, or traits::eof() to indicate a null pending sequence.
For a formal definition of the pending sequence, see a good text such as Langer & Kreft, or [27.5.2.4.3]/7-14.
Okay so a fully functioning input streambuf can be created by overriding, like, only this function β no buffer area will be used at all. For an example, see https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html. π
Note: the base class version does nothing and returns eof(). That's it. That's the whole vibe. π
Reimplemented from std::basic_streambuf< _CharT, _Traits >.
References std::ios_base::in.
π xsgetn() β multiple character extraction π
template<typename _CharT , typename _Traits > streamsize
std::basic_streambuf< _CharT, _Traits >::xsgetn (char_type * __s,
streamsize __n) [protected], [virtual], [inherited]
Parameters
__sβ a buffer area, bestie.__nβ the maximum number of characters to assign.
Returns: the number of characters assigned. β¨
Fills __s[0] through __s[__n-1] with characters from the input sequence, as if by sbumpc(). Stops when either __n characters have been copied, or when traits::eof() would be copied.
It is expected that derived classes provide a more efficient implementation by overriding this definition.
Reimplemented in std::basic_filebuf< _CharT, _Traits >, std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >, std::basic_filebuf< _CharT, std::char_traits< _CharT > >, and std::basic_filebuf< char_type, traits_type >.
References std::min().
Referenced by std::basic_streambuf< _CharT, _Traits >::sgetn().
π¦ xsputn() β multiple character insertion π¦
template<typename _CharT , typename _Traits > streamsize
std::basic_streambuf< _CharT, _Traits >::xsputn (const char_type * __s,
streamsize __n) [protected], [virtual], [inherited]
Parameters
__sβ a buffer area, bestie.__nβ the maximum number of characters to write.
Returns: the number of characters written. π
Writes __s[0] through __s[__n-1] to the output sequence, as if by sputc(). Stops when either n characters have been copied, or when sputc() would return traits::eof().
It is expected that derived classes provide a more efficient implementation by overriding this definition.
Reimplemented in std::basic_filebuf< _CharT, _Traits >, std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >, std::basic_filebuf< _CharT, std::char_traits< _CharT > >, and std::basic_filebuf< char_type, traits_type >.
References std::min().
Referenced by std::basic_streambuf< _CharT, _Traits >::sputn().
π§Ί Member Data Documentation π§Ί
These are the protected little data drawers, okay? Very backstage, very behind-the-scenes. π
_M_buf_localeβtemplate<typename _CharT , typename _Traits > locale std::basic_streambuf< _CharT, _Traits >::_M_buf_locale [protected], [inherited]. Current locale setting. Referenced bystd::basic_filebuf< _CharT, _Traits >::basic_filebuf(),std::basic_streambuf< _CharT, _Traits >::getloc(), andstd::basic_streambuf< _CharT, _Traits >::pubimbue()._M_in_begβtemplate<typename _CharT , typename _Traits > char_type* std::basic_streambuf< _CharT, _Traits >::_M_in_beg [protected], [inherited]. Start of get area. Referenced bystd::basic_streambuf< _CharT, _Traits >::eback(), andstd::basic_streambuf< _CharT, _Traits >::setg()._M_in_curβtemplate<typename _CharT , typename _Traits > char_type* std::basic_streambuf< _CharT, _Traits >::_M_in_cur [protected], [inherited]. Current read area. Referenced bystd::basic_streambuf< _CharT, _Traits >::gbump(),std::basic_streambuf< _CharT, _Traits >::gptr(), andstd::basic_streambuf< _CharT, _Traits >::setg()._M_in_endβtemplate<typename _CharT , typename _Traits > char_type* std::basic_streambuf< _CharT, _Traits >::_M_in_end [protected], [inherited]. End of get area. Referenced bystd::basic_streambuf< _CharT, _Traits >::egptr(), andstd::basic_streambuf< _CharT, _Traits >::setg()._M_modeβtemplate<typename _CharT , typename _Traits , typename _Alloc > ios_base::openmode std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_mode [protected]. Place to stashin || out || in | outsettings for current stringbuf. Referenced bystd::basic_stringbuf< _CharT, _Traits, _Alloc >::showmanyc(), andstd::basic_stringbuf< _CharT, _Traits, _Alloc >::str()._M_out_begβtemplate<typename _CharT , typename _Traits > char_type* std::basic_streambuf< _CharT, _Traits >::_M_out_beg [protected], [inherited]. Start of put area. Referenced bystd::basic_streambuf< _CharT, _Traits >::pbase(), andstd::basic_streambuf< _CharT, _Traits >::setp()._M_out_curβtemplate<typename _CharT , typename _Traits > char_type* std::basic_streambuf< _CharT, _Traits >::_M_out_cur [protected], [inherited]. Current put area. Referenced bystd::basic_streambuf< _CharT, _Traits >::pbump(),std::basic_streambuf< _CharT, _Traits >::pptr(), andstd::basic_streambuf< _CharT, _Traits >::setp()._M_out_endβtemplate<typename _CharT , typename _Traits > char_type* std::basic_streambuf< _CharT, _Traits >::_M_out_end [protected], [inherited]. End of put area. Referenced bystd::basic_streambuf< _CharT, _Traits >::epptr(), andstd::basic_streambuf< _CharT, _Traits >::setp().
πΈ Author πΈ
Generated automatically by Doxygen for libstdc++ from the source code.
Bestie, that's the whole page π β the footerβs source/version/date tag is libstdstd::basic_str...raits, _Alloc >(3cxx). Byeee, mwah! π«Άβ¨
π¦ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms