STD::STRINGBUF(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_type
  • typedef basic_streambuf< char_type, traits_type > __streambuf_type
  • typedef basic_string< char_type, _Traits, _Alloc > __string_type
  • typedef _Alloc allocator_type
  • typedef _CharT char_type
  • typedef traits_type::int_type int_type
  • typedef traits_type::off_type off_type
  • typedef traits_type::pos_type pos_type
  • typedef _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 for imbue().
  • int_type sbumpc () β€” getting the next character.
  • int_type sgetc () β€” getting the next character.
  • streamsize sgetn (char_type *__s, streamsize __n) β€” entry point for xsgetn.
  • 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 virtual sync function.

πŸ“ 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 sequence
  • gptr() returns the next pointer for the input sequence
  • egptr() 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 sequence
  • gptr() returns the next pointer for the input sequence
  • egptr() 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 sequence
  • pptr() returns the next pointer for the output sequence
  • epptr() 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 sequence
  • gptr() β€” returns the next pointer for the input sequence
  • egptr() β€” 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 sequence
  • pptr() β€” returns the next pointer for the output sequence
  • epptr() β€” 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 sequence
  • pptr() β€” returns the next pointer for the output sequence
  • epptr() β€” 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 for ios_base::seekdir.
  • __mode β€” Value for ios_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 for ios_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 [to underflow or uflow] will not return eof() but that they will return immediately.
Note: The standard adds that the morphemes of showmanyc are es-how-many-see, not show-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 by std::basic_filebuf< _CharT, _Traits >::basic_filebuf(), std::basic_streambuf< _CharT, _Traits >::getloc(), and std::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 by std::basic_streambuf< _CharT, _Traits >::eback(), and std::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 by std::basic_streambuf< _CharT, _Traits >::gbump(), std::basic_streambuf< _CharT, _Traits >::gptr(), and std::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 by std::basic_streambuf< _CharT, _Traits >::egptr(), and std::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 stash in || out || in | out settings for current stringbuf. Referenced by std::basic_stringbuf< _CharT, _Traits, _Alloc >::showmanyc(), and std::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 by std::basic_streambuf< _CharT, _Traits >::pbase(), and std::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 by std::basic_streambuf< _CharT, _Traits >::pbump(), std::basic_streambuf< _CharT, _Traits >::pptr(), and std::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 by std::basic_streambuf< _CharT, _Traits >::epptr(), and std::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