STD::WBUFFER_CONVERT(3)

✨ NAME ✨

hey bestie πŸ’– welcome to the std::wbuffer_convert< _Codecvt, _Elem, _Tr >(3) page from the Library Functions Manual β€” and it's literally all about Buffer conversions. no cap.

std::wbuffer_convert< _Codecvt, _Elem, _Tr > β€” Buffer conversions.


πŸ“š SYNOPSIS πŸ“š

okay so first thing, you gotta include this:

#include <locale>

and the inheritance tea is:

Inherits std::basic_streambuf< _CharT, _Traits >.

🌸 Public Types 🌸

  • typedef _Codecvt::state_type state_type β€” the state type from your codecvt, periodt.
  • typedef _CharT char_type β€” char type, iconic.
  • typedef _Traits traits_type β€” traits type, slay.
  • typedef traits_type::int_type int_type β€” int type from traits.
  • typedef traits_type::pos_type pos_type β€” pos type from traits.
  • typedef traits_type::off_type off_type β€” off type from traits.
  • typedef basic_streambuf< char_type, traits_type > __streambuf_type β€” This is a non-standard type. 🫢

πŸ‘‘ Public Member Functions πŸ‘‘

  • wbuffer_convert () β€” Default constructor. πŸ’…
  • wbuffer_convert (const wbuffer_convert &)=delete β€” deleted copy constructor, not today satan πŸ’€
  • wbuffer_convert (streambuf *__bytebuf, _Codecvt *__pcvt=new _Codecvt, state_type __state=state_type()) β€” constructor.
  • locale getloc () const β€” Locale access.
  • streamsize in_avail () β€” Looking ahead into the stream.
  • wbuffer_convert & operator= (const wbuffer_convert &)=delete β€” deleted assignment operator.
  • locale pubimbue (const locale &__loc) β€” Entry point for imbue().
  • streambuf * rdbuf () const noexcept β€” no description, just vibes.
  • streambuf * rdbuf (streambuf *__bytebuf) noexcept β€” no description, just vibes.
  • 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.
  • 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.
  • state_type state () const noexcept β€” The conversion state following the last conversion.
  • int_type sungetc () β€” Moving backwards in the input stream.
  • 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) β€” no description.
  • void __safe_pbump (streamsize __n) β€” no description.
  • void gbump (int __n) β€” Moving the read position.
  • virtual void imbue (const locale &__loc) β€” Changes translations.
  • _Wide_streambuf::int_type overflow (typename _Wide_streambuf::int_type __out) β€” Consumes data from the buffer; writes to the controlled sequence.
  • virtual int_type pbackfail (int_type __c=traits_type::eof()) β€” Tries to back up the input sequence.
  • void pbump (int __n) β€” Moving the write position.
  • virtual pos_type seekoff (off_type, ios_base::seekdir, ios_base::openmode=ios_base::in|ios_base::out) β€” Alters the stream positions.
  • virtual pos_type seekpos (pos_type, ios_base::openmode=ios_base::in|ios_base::out) β€” Alters the stream positions.
  • virtual basic_streambuf< char_type, _Traits > * setbuf (char_type *, streamsize) β€” 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.
  • void swap (basic_streambuf &__sb) β€” no description.
  • int sync () β€” Synchronizes the buffer arrays with the controlled sequences.
  • virtual int_type uflow () β€” Fetches more data from the controlled sequence.
  • _Wide_streambuf::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.
  • streamsize xsputn (const typename _Wide_streambuf::char_type *__s, streamsize __n) β€” no description.
  • 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.
  • 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.

πŸ“– Detailed Description πŸ“–

okay so the template situation is:

template<typename _Codecvt, typename _Elem = wchar_t, typename _Tr =
    char_traits<_Elem>>
class std::wbuffer_convert< _Codecvt, _Elem, _Tr >"Buffer conversions.

yep, that's the whole vibe. _Elem defaults to wchar_t, and _Tr defaults to char_traits<_Elem>. πŸ’–


🧬 Member Typedef Documentation 🧬

__streambuf_type [inherited]

template<typename _CharT, typename _Traits> typedef
    basic_streambuf<char_type, traits_type> std::basic_streambuf< _CharT,
    _Traits >::__streambuf_type [inherited]

This is a non-standard type. 🫢

char_type [inherited]

template<typename _CharT, typename _Traits> typedef _CharT
    std::basic_streambuf< _CharT, _Traits >::char_type [inherited]

These are standard types. They permit a standardized way of referring to names of (or names dependent on) the template parameters, which are specific to the implementation. ✨

int_type [inherited]

template<typename _CharT, typename _Traits> typedef traits_type::int_type
    std::basic_streambuf< _CharT, _Traits >::int_type [inherited]

Same standard-types spiel: they let you refer to template parameter names (or names dependent on them) in a standardized way, even though the implementation specifics are different. πŸ’…

off_type [inherited]

template<typename _CharT, typename _Traits> typedef traits_type::off_type
    std::basic_streambuf< _CharT, _Traits >::off_type [inherited]

Again, standard types, same standardized naming deal, implementation-specific details. 🌸

pos_type [inherited]

template<typename _CharT, typename _Traits> typedef traits_type::pos_type
    std::basic_streambuf< _CharT, _Traits >::pos_type [inherited]

Standard types, standardized way of referring to names, etc. You know the drill. πŸ‘‘

traits_type [inherited]

template<typename _CharT, typename _Traits> typedef _Traits
    std::basic_streambuf< _CharT, _Traits >::traits_type [inherited]

Yep, standard types, same spiel. periodt. πŸŽ€


πŸ—οΈ Constructor & Destructor Documentation πŸ—οΈ

wbuffer_convert () [inline]

template<typename _Codecvt, typename _Elem = wchar_t, typename _Tr =
    char_traits<_Elem>> std::wbuffer_convert< _Codecvt, _Elem, _Tr
    >::wbuffer_convert () [inline]

Default constructor. πŸ’–

References wbuffer_convert().

Referenced by wbuffer_convert().

wbuffer_convert (streambuf * __bytebuf, _Codecvt * __pcvt = new _Codecvt, state_type __state = state_type()) [inline], [explicit]

template<typename _Codecvt, typename _Elem = wchar_t, typename _Tr =
    char_traits<_Elem>> std::wbuffer_convert< _Codecvt, _Elem, _Tr
    >::wbuffer_convert (streambuf * __bytebuf, _Codecvt * __pcvt = new
    _Codecvt, state_type __state = state_type()) [inline],  [explicit]

Constructor. πŸ› οΈ

Parameters:

  • __bytebuf β€” The underlying byte stream buffer.
  • __pcvt β€” The facet to use for conversions.
  • __state β€” Initial conversion state.

Takes ownership of __pcvt and will delete it in the destructor. πŸ—‘οΈ

References std::basic_streambuf< _CharT, _Traits >::setg(), and std::basic_streambuf< _CharT, _Traits >::setp().


πŸ“ Member Function Documentation πŸ“

eback () const [inline], [protected], [inherited]

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. πŸ”’

  • 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

Referenced by std::basic_filebuf< char_type, traits_type >::_M_destroy_pback(), std::basic_filebuf< _CharT, _Traits >::imbue(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::overflow(), std::basic_filebuf< _CharT, _Traits >::pbackfail(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::pbackfail(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekoff(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekpos(), std::basic_streambuf< char_type, traits_type >::sputbackc(), std::basic_streambuf< char_type, traits_type >::sungetc(), std::basic_filebuf< _CharT, _Traits >::underflow(), and std::basic_filebuf< _CharT, _Traits >::xsgetn().

egptr () const [inline], [protected], [inherited]

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. πŸ”’

  • 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

Referenced by std::basic_filebuf< char_type, traits_type >::_M_create_pback(), std::basic_streambuf< char_type, traits_type >::in_avail(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::overflow(), std::basic_streambuf< char_type, traits_type >::sbumpc(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekoff(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekpos(), std::basic_streambuf< char_type, traits_type >::sgetc(), std::basic_filebuf< _CharT, _Traits >::showmanyc(), std::basic_stringbuf< char >::showmanyc(), std::basic_filebuf< _CharT, _Traits >::underflow(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::underflow(), std::wbuffer_convert< _Codecvt, _Elem, _Tr >::underflow(), std::basic_filebuf< _CharT, _Traits >::xsgetn(), and xsgetn().

epptr () const [inline], [protected], [inherited]

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. πŸ”’

  • 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

okay so this one is also getting name-dropped by std::basic_stringbuf< _CharT, _Traits, _Alloc >::overflow(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekoff(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekpos(), std::basic_streambuf< char_type, traits_type >::sputc(), std::basic_filebuf< _CharT, _Traits >::xsputn(), and xsputn() β€” literally the whole friend group shows up for it 🫢


gbump πŸ’…

template<typename _CharT, typename _Traits> void std::basic_streambuf< _CharT, _Traits >::gbump (int __n) [inline],  [protected],  [inherited]

Moving the read position. That's it. That's the whole job.

Parameters

  • __n β€” The delta by which to move.

This just advances the read position without returning any data. no thoughts, head empty, just vibes and a pointer scooting forward ✨

Referenced by std::basic_filebuf< _CharT, _Traits >::pbackfail(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::pbackfail(), std::basic_streambuf< char_type, traits_type >::sbumpc(), std::basic_streambuf< char_type, traits_type >::sputbackc(), std::basic_streambuf< char_type, traits_type >::sungetc(), std::basic_streambuf< char_type, traits_type >::uflow(), and std::basic_filebuf< _CharT, _Traits >::xsgetn().


getloc 🌸

template<typename _CharT, typename _Traits> locale std::basic_streambuf< _CharT, _Traits >::getloc () const [inline],  [inherited]

Locale access. bestie wants to know what locale we're living in rn.

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 basically: if you told it, it remembers. if you didn't, it's running on the global default it was born with. main character energy, honestly πŸ’œ

Referenced by std::basic_streambuf< char_type, traits_type >::pubimbue().


gptr πŸŽ€

template<typename _CharT, typename _Traits> char_type * std::basic_streambuf< _CharT, _Traits >::gptr () const [inline],  [protected],  [inherited]

Access to the get area. These functions are only available to other protected functions, including derived classes. so like… it's giving VIP section, iykyk πŸ”₯

  • 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

Referenced by std::basic_filebuf< char_type, traits_type >::_M_create_pback(), std::basic_filebuf< char_type, traits_type >::_M_destroy_pback(), std::basic_filebuf< _CharT, _Traits >::imbue(), std::basic_streambuf< char_type, traits_type >::in_avail(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::overflow(), std::basic_filebuf< _CharT, _Traits >::pbackfail(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::pbackfail(), std::basic_streambuf< char_type, traits_type >::sbumpc(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekoff(), std::basic_streambuf< char_type, traits_type >::sgetc(), std::basic_filebuf< _CharT, _Traits >::showmanyc(), std::basic_stringbuf< char >::showmanyc(), std::basic_streambuf< char_type, traits_type >::sputbackc(), std::basic_streambuf< char_type, traits_type >::sungetc(), std::basic_streambuf< char_type, traits_type >::uflow(), std::basic_filebuf< _CharT, _Traits >::underflow(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::underflow(), std::wbuffer_convert< _Codecvt, _Elem, _Tr >::underflow(), std::basic_filebuf< _CharT, _Traits >::xsgetn(), and xsgetn().


imbue πŸ¦‹

template<typename _CharT, typename _Traits> virtual void std::basic_streambuf< _CharT, _Traits >::imbue (const locale & __loc) [inline],  [protected],  [virtual],  [inherited]

Changes translations. glow-up for your locale-dependent I/O ✨

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."

Note: Base class version does nothing. literally just standing there, existing, doing absolutely nothing. we love a passive icon πŸ’€

Reimplemented in std::basic_filebuf< _CharT, _Traits >, std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >, std::basic_filebuf< _CharT, std::char_traits< _CharT > >, std::basic_filebuf< char >, std::basic_filebuf< char_type, traits_type >, and std::basic_filebuf< wchar_t >.

Referenced by std::basic_streambuf< char_type, traits_type >::pubimbue().


in_avail 🌈

template<typename _CharT, typename _Traits> streamsize std::basic_streambuf< _CharT, _Traits >::in_avail () [inline],  [inherited]

Looking ahead into the stream. peeking. respectfully. πŸ‘€

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(). so either you get a real number, or you get whatever the derived class's showmanyc() has to say. no cap.


overflow πŸ’œ

template<typename _Codecvt, typename _Elem = wchar_t, typename _Tr = char_traits<_Elem>> _Wide_streambuf::int_type std::wbuffer_convert< _Codecvt, _Elem, _Tr >::overflow (typename _Wide_streambuf::int_type __c) [inline],  [protected],  [virtual]

Consumes data from the buffer; writes to the controlled sequence. this is THE function of this page btw, the one the whole manpage is named after, so pay attention bestie 🫢

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. go read the textbook, I'm not doing your homework for you πŸ’…

A functioning output streambuf can be created by overriding only this function (no buffer area will be used). one (1) override and you're a whole output streambuf. iconic.

Note: Base class version does nothing, returns eof().

Reimplemented from std::basic_streambuf< _CharT, _Traits >.

References std::basic_streambuf< _CharT, _Traits >::sputc().


pbackfail πŸ™ˆ

template<typename _CharT, typename _Traits> virtual int_type std::basic_streambuf< _CharT, _Traits >::pbackfail (int_type __c = traits_type::eof()) [inline],  [protected],  [virtual],  [inherited]

Tries to back up the input sequence. "tries" is doing a LOT of heavy lifting in that sentence, and yes that's on purpose 😭

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().

Reimplemented in __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits >, std::basic_filebuf< _CharT, _Traits >, std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >, std::basic_filebuf< char >, std::basic_filebuf< char_type, traits_type >, std::basic_filebuf< wchar_t >, std::basic_stringbuf< _CharT, _Traits, _Alloc >, std::basic_stringbuf< char >, and std::basic_stringbuf< wchar_t >.

Referenced by std::basic_streambuf< char_type, traits_type >::sputbackc(), and std::basic_streambuf< char_type, traits_type >::sungetc().


pbase ⭐

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. again: protected-only, so if you're not in the family, no entry πŸŽ€

  • 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

Referenced by std::basic_filebuf< _CharT, _Traits >::overflow(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::overflow(), std::basic_filebuf< _CharT, _Traits >::seekoff(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekoff(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekpos(), std::basic_stringbuf< char >::str(), std::basic_filebuf< _CharT, _Traits >::sync(), and std::basic_filebuf< _CharT, _Traits >::xsputn().


pbump ✨

template<typename _CharT, typename _Traits> void std::basic_streambuf< _CharT, _Traits >::pbump (int __n) [inline],  [protected],  [inherited]

Moving the write position. the write-side twin of gbump, and honestly they ate πŸ’…

Parameters

  • __n β€” The delta by which to move.

This just advances the write position without returning any data. no data, no drama, just movement.

Referenced by std::basic_filebuf< _CharT, _Traits >::overflow(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::overflow(), and std::basic_streambuf< char_type, traits_type >::sputc().


pptr 🌟

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. same VIP list as pbase(), don't @ me

  • 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

Referenced by std::basic_filebuf< _CharT, _Traits >::overflow(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::overflow(), std::basic_filebuf< _CharT, _Traits >::seekoff(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekoff(), std::basic_streambuf< char_type, traits_type >::sputc(), std::basic_filebuf< _CharT, _Traits >::sync(), std::basic_filebuf< _CharT, _Traits >::xsputn(), and xsputn().


pubimbue 🌸

template<typename _CharT, typename _Traits> locale std::basic_streambuf< _CharT, _Traits >::pubimbue (const locale & __loc) [inline],  [inherited]

Entry point for imbue(). the public-facing door to the protected function behind it πŸšͺ✨

Parameters

  • __loc β€” The new locale.

Returns

  • The previous locale.

Calls the derived imbue(__loc). so you hand it a locale, it hands you back the old one like a little exchange program 🫢


pubseekoff 🌈

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. note the default for __mode is ios_base::in | ios_base::out, so if you don't say anything it assumes both. periodt.


pubseekpos πŸŽ€

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. yes, again. it's a whole theme ✨

Parameters

  • __sp β€” Position
  • __mode β€” Value for ios_base::openmode.

Calls virtual seekpos function. same default energy: ios_base::in | ios_base::out πŸ’œ


pubsetbuf πŸ¦‹

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.

okay so the naming pattern is the whole lore here: pubfoo is the public bouncer, foo is the protected function inside the club, and the bouncer just passes your args through and hands you back whatever comes out, untouched. no edits, no notes πŸ’…


pubsync ⭐

template<typename _CharT, typename _Traits> int std::basic_streambuf< _CharT, _Traits >::pubsync () [inline],  [inherited]

Calls virtual sync function. short king. does one thing and does it well πŸ‘‘

Referenced by std::basic_istream< _CharT, _Traits >::sync().


sbumpc πŸ‘‘

template<typename _CharT, typename _Traits> int_type std::basic_streambuf< _CharT, _Traits >::sbumpc () [inline],  [inherited]

Getting the next character. the moment you've all been waiting for 🎀

Returns

  • The next character, or eof.

that's it, that's the function β€” it bumps the pointer and gives you the char. or it gives you eof if there's nothing left to give 😭

okay so if the read position is actually available, it hands you that character and slides the read pointer forward β€” otherwise it calls uflow() and returns whatever that gives back. either way you're getting a char πŸ’–

Referenced by std::basic_istream< _CharT, _Traits >::ignore(), std::basic_streambuf< char_type, traits_type >::snextc(), and std::basic_istream< _CharT, char_traits< _CharT > >::unget().


πŸ”€ seekoff β€” the "move the stream" one

template<typename _CharT, typename _Traits> virtual pos_type
    std::basic_streambuf< _CharT, _Traits >::seekoff (off_type ,
    ios_base::seekdir , ios_base::openmode  = ios_base::in | ios_base::out)
    [inline],  [protected],  [virtual],  [inherited]

This one alters the stream positions. Every derived class brings its own behaviour to the function, so what actually happens depends on who you're talking to. πŸ¦‹

Note πŸ’€ the base class version does nothing and returns a pos_type that represents an invalid stream position. so if you're calling this on a plain base basic_streambuf and expecting movement... bestie, no. πŸ™ˆ

Reimplemented in std::basic_filebuf< _CharT, _Traits >, std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >, std::basic_filebuf< char >, std::basic_filebuf< char_type, traits_type >, std::basic_filebuf< wchar_t >, std::basic_stringbuf< _CharT, _Traits, _Alloc >, std::basic_stringbuf< char >, and std::basic_stringbuf< wchar_t >.

Referenced by std::basic_streambuf< char_type, traits_type >::pubseekoff().


πŸ”€ seekpos β€” the other "move the stream" one

template<typename _CharT, typename _Traits> virtual pos_type
    std::basic_streambuf< _CharT, _Traits >::seekpos (pos_type ,
    ios_base::openmode  = ios_base::in | ios_base::out) [inline],
    [protected],  [virtual],  [inherited]

Also alters the stream positions, and again, each derived class provides its own appropriate behavior. it's giving choose-your-own-adventure but for streams ✨

Note πŸ’€ base class version does nothing, returns a pos_type that represents an invalid stream position. same energy as seekoff, same disappointment.

Reimplemented in std::basic_filebuf< _CharT, _Traits >, std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >, std::basic_filebuf< char >, std::basic_filebuf< char_type, traits_type >, std::basic_filebuf< wchar_t >, std::basic_stringbuf< _CharT, _Traits, _Alloc >, std::basic_stringbuf< char >, and std::basic_stringbuf< wchar_t >.

Referenced by std::basic_streambuf< char_type, traits_type >::pubseekpos().


🧺 setbuf β€” buffer manipulation hours

template<typename _CharT, typename _Traits> virtual basic_streambuf<
    char_type, _Traits > * std::basic_streambuf< _CharT, _Traits >::setbuf
    (char_type * , streamsize ) [inline],  [protected],  [virtual],
    [inherited]

Manipulates the buffer. Each derived class provides its own appropriate behavior, as always. If you want the deep lore on this function, the original points you at the next-to-last paragraph of https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html#io.streambuf.buffering β€” go read it, it's right there. πŸ“–

Note πŸ’€ base class version does nothing and returns this. iconic levels of "I'm just here".

Reimplemented in std::basic_filebuf< _CharT, _Traits >, std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >, std::basic_filebuf< _CharT, std::char_traits< _CharT > >, std::basic_filebuf< char >, std::basic_filebuf< char_type, traits_type >, std::basic_stringbuf< _CharT, _Traits, _Alloc >, and std::basic_stringbuf< char >.

Referenced by std::basic_streambuf< char_type, traits_type >::pubsetbuf().


πŸ“ setg β€” point the read area at stuff

template<typename _CharT, typename _Traits> void std::basic_streambuf<
    _CharT, _Traits >::setg (char_type * __gbeg, char_type * __gnext,
    char_type * __gend) [inline],  [protected],  [inherited]

Setting the three read area pointers. that's the whole job, and it does it flawlessly πŸ’…

Parameters

  • __gbeg β€” A pointer.
  • __gnext β€” A pointer.
  • __gend β€” A pointer.
Postcondition __gbeg == eback(), __gnext == gptr(), and __gend == egptr()

Referenced by std::wbuffer_convert< _Codecvt, _Elem, _Tr >::wbuffer_convert(), std::basic_filebuf< char_type, traits_type >::_M_create_pback(), std::basic_filebuf< char_type, traits_type >::_M_destroy_pback(), std::basic_filebuf< char_type, traits_type >::_M_set_buffer(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::overflow(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekoff(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekpos(), and std::basic_filebuf< _CharT, _Traits >::xsgetn().


πŸ“ setp β€” point the write area at stuff

template<typename _CharT, typename _Traits> void std::basic_streambuf<
    _CharT, _Traits >::setp (char_type * __pbeg, char_type * __pend)
    [inline],  [protected],  [inherited]

Setting the three write area pointers. yes bestie, "three" β€” that's what it says. two args, three pointers, we don't question the ancestors 🫢

Parameters

  • __pbeg β€” A pointer.
  • __pend β€” A pointer.
Postcondition __pbeg == pbase(), __pbeg == pptr(), and __pend == epptr()

Referenced by std::wbuffer_convert< _Codecvt, _Elem, _Tr >::wbuffer_convert(), and std::basic_filebuf< char_type, traits_type >::_M_set_buffer().


πŸ‘€ sgetc β€” peeking at the next char

template<typename _CharT, typename _Traits> int_type std::basic_streambuf<
    _CharT, _Traits >::sgetc () [inline],  [inherited]

Getting the next character.

Returns the next character, or eof.

If the input read position is available, it returns that character. otherwise it calls and returns underflow(). and here's the important bit β€” it does not move the read position after fetching the character. pure look, no touch. πŸ‘‘βœ¨

Referenced by std::basic_istream< _CharT, _Traits >::get(), std::basic_istream< _CharT, _Traits >::get(), std::basic_istream< _CharT, _Traits >::ignore(), std::basic_istream< _CharT, char_traits< _CharT > >::readsome(), and std::basic_streambuf< char_type, traits_type >::snextc().


πŸ“₯ sgetn β€” bulk input, the entry point

template<typename _CharT, typename _Traits> streamsize std::basic_streambuf<
    _CharT, _Traits >::sgetn (char_type * __s, streamsize __n) [inline],
    [inherited]

Entry point for xsgetn.

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. filling the whole array, no cap 🌸


πŸ” showmanyc β€” the "how much is left" detective

template<typename _CharT, typename _Traits> virtual streamsize
    std::basic_streambuf< _CharT, _Traits >::showmanyc () [inline],
    [protected],  [virtual],  [inherited]

Investigating the data available.

Returns an estimate of the number of characters available in the input sequence, or -1.

okay so the rules: 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. and if showmanyc() returns -1, then calls to underflow() or uflow() will fail. that's [27.5.2.4.3]/1, quoting the standard directly, periodt. πŸ’…

Note base class version does nothing, returns zero. 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. The standard adds that the morphemes of showmanyc are es-how-many-see, not show-manic. yes really. that's in the standard. we're all just living in its world 🫠

Reimplemented in std::basic_filebuf< _CharT, _Traits >, std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >, std::basic_filebuf< _CharT, std::char_traits< _CharT > >, std::basic_filebuf< char >, std::basic_filebuf< char_type, traits_type >, std::basic_filebuf< wchar_t >, std::basic_stringbuf< _CharT, _Traits, _Alloc >, std::basic_stringbuf< char >, and std::basic_stringbuf< wchar_t >.

Referenced by std::basic_streambuf< char_type, traits_type >::in_avail().


⏭️ snextc β€” skipping ahead one

template<typename _CharT, typename _Traits> int_type std::basic_streambuf<
    _CharT, _Traits >::snextc () [inline],  [inherited]

Getting the next character. (again, yes β€” the docs repeat themselves, and honestly? relatable.)

Returns the next character, or eof.

the mechanics: it calls sbumpc(), and if that function returns traits::eof(), so does this function. otherwise, sgetc(). so it's a bump-then-peek combo meal πŸ“

Referenced by std::basic_istream< _CharT, char_traits< _CharT > >::get(), std::basic_iostream< char_type, traits_type >::ignore(), and std::basic_istream< _CharT, char_traits< _CharT > >::readsome().


↩️ sputbackc β€” pushing a char back in

template<typename _CharT, typename _Traits> int_type std::basic_streambuf<
    _CharT, _Traits >::sputbackc (char_type __c) [inline],  [inherited]

Pushing characters back into the input stream.

Parameters

  • __c β€” The character to push back.

Returns the previous character, if possible.

Similar to sungetc(), but here __c gets pushed onto the stream instead of the previous character. If it's successful, the next character fetched from the input stream will be __c. so you literally get to rewrite the future of the stream, lowkey iconic ✨

Referenced by std::basic_istream< _CharT, _Traits >::putback().


✍️ sputc β€” one char out, please

template<typename _CharT, typename _Traits> int_type std::basic_streambuf<
    _CharT, _Traits >::sputc (char_type __c) [inline],  [inherited]

Entry point for all single-character output functions.

Parameters

  • __c β€” A character to output.

Returns __c, if possible.

One of two public output functions.

the flow: 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). and if a write position is not available? it returns overflow(__c). no drama, just delegation πŸ’…

Referenced by std::wbuffer_convert< _Codecvt, _Elem, _Tr >::overflow().


πŸ“€ sputn β€” bulk output

template<typename _CharT, typename _Traits> streamsize std::basic_streambuf<
    _CharT, _Traits >::sputn (const char_type * __s, streamsize __n)
    [inline],  [inherited]

Entry point for all single-character output functions. (yes, it says that here too. the docs said what they said and I respect 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. dump the whole buffer, no crumbs left behind πŸŽ€


πŸŒ€ state β€” the codecvt state check

template<typename _Codecvt, typename _Elem = wchar_t, typename _Tr =
    char_traits<_Elem>> state_type std::wbuffer_convert< _Codecvt, _Elem,
    _Tr >::state () const [inline],  [noexcept]

The conversion state following the last conversion. that's it, that's the whole function β€” it hands you the state_type from whatever conversion happened most recently. short and sweet, and it's noexcept so it will not be the thing that ruins your day πŸ¦‹


βͺ sungetc β€” moving backwards

template<typename _CharT, typename _Traits> int_type std::basic_streambuf<
    _CharT, _Traits >::sungetc () [inline],  [inherited]

Moving backwards in the input stream.

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. undo button energy, but only one step deep πŸ’œ

Referenced by std::basic_istream< _CharT, _Traits >::unget().


πŸ”„ sync β€” syncing it all up

template<typename _Codecvt, typename _Elem = wchar_t, typename _Tr =
    char_traits<_Elem>> int std::wbuffer_convert< _Codecvt, _Elem, _Tr
    >::sync () [inline],  [protected],  [virtual]

Synchronizes the buffer arrays with the controlled sequences.

Returns -1 on failure.

Each derived class provides its own appropriate behavior, including the definition of failure. yes β€” the class itself gets to decide what "failure" even means here. main character energy, honestly πŸ‘‘

Note πŸ’€ base class version does nothing, returns zero.

Reimplemented from std::basic_streambuf< _CharT, _Traits >.


🎣 uflow β€” fetch more, and move forward

template<typename _CharT, typename _Traits> virtual int_type
    std::basic_streambuf< _CharT, _Traits >::uflow () [inline],
    [protected],  [virtual],  [inherited]

Fetches more data from the controlled sequence.

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 β€” and this is the whole point β€” this function also moves the read position forward by one. so it's underflow() plus a little forward momentum ✨πŸ”₯

Reimplemented in __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits >.

  • Referenced by std::basic_streambuf< char_type, traits_type >::sbumpc(), and xsgetn().

🌊 underflow()

template<typename _Codecvt, typename _Elem = wchar_t, typename _Tr = char_traits<_Elem>>
_Wide_streambuf::int_type std::wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
  [inline], [protected], [virtual]

bestie it FETCHES more data from the controlled sequence πŸ’– that's literally its whole job.

Returns: the first character from the pending sequence. 🫢

Okay so informally? This function gets called when the input buffer is exhausted β€” or when it straight up doesn't exist, because buffering need not actually be done (iconic, low-effort, love that for it). If a buffer does exist, it gets refilled. Either way, the next available character gets returned, or traits::eof() shows up to say "the pending sequence is null, nothing here bestie" πŸ’€

Wanna know the formal definition of the pending sequence? Go read a good text like Langer & Kreft, or [27.5.2.4.3]/7-14. no cap, that's where the lore lives πŸ“š

Here's the cute part: you can make a fully functioning input streambuf by overriding only this one function β€” no buffer area will be used at all. periodt. For an example, see https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html ✨

Note: base class version does nothing, returns eof(). it's giving minimal effort πŸ™ˆ

Reimplemented from std::basic_streambuf< _CharT, _Traits >.

References std::basic_streambuf< _CharT, _Traits >::egptr(), and std::basic_streambuf< _CharT, _Traits >::gptr().


πŸ“₯ xsgetn()

template<typename _CharT, typename _Traits>
streamsize std::basic_streambuf< _CharT, _Traits >::xsgetn(char_type * __s, streamsize __n)
  [protected], [virtual], [inherited]

Multiple character extraction β€” she's doing the MOST, not just one at a time πŸ’…

Parameters

  • __s β€” a buffer area. πŸŽ€
  • __n β€” maximum number of characters to assign.

Returns: the number of characters assigned. 🌸

So what happens: it fills __s[0] through __s[__n-1] with characters from the input sequence, as if by sbumpc(). And it stops the second 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. like, do better than the base, okay? πŸ”₯

Reimplemented in std::basic_filebuf< _CharT, _Traits >, std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >, std::basic_filebuf< _CharT, std::char_traits< _CharT > >, std::basic_filebuf< char >, and std::basic_filebuf< char_type, traits_type >. she got remixed everywhere bestie 🌈

References egptr(), gptr(), std::min(), and uflow().

Referenced by std::basic_streambuf< char_type, traits_type >::sgetn().


πŸ“€ xsputn()

template<typename _CharT, typename _Traits>
streamsize std::basic_streambuf< _CharT, _Traits >::xsputn(const char_type * __s, streamsize __n)
  [protected], [virtual], [inherited]

Multiple character insertion β€” the output-side twin, obsessed with her honestly 😭

Parameters

  • __s β€” a buffer area. πŸŽ€
  • __n β€” maximum number of characters to write.

Returns: the number of characters written. ✨

She writes __s[0] through __s[__n-1] to the output sequence, as if by sputc(). And she stops when either n characters have been copied, or when sputc() would return traits::eof(). πŸ›‘

Again, it is expected that derived classes provide a more efficient implementation by overriding this definition. the bar is on the floor, and yet πŸ‘‘

Reimplemented in std::basic_filebuf< _CharT, _Traits >, std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >, std::basic_filebuf< _CharT, std::char_traits< _CharT > >, std::basic_filebuf< char >, and std::basic_filebuf< char_type, traits_type >.

References epptr(), std::min(), overflow(), and pptr().

Referenced by std::basic_streambuf< char_type, traits_type >::sputn().


πŸ‘‘ MEMBER DATA DOCUMENTATION πŸ‘‘

πŸ”’ _M_buf_locale

template<typename _CharT, typename _Traits>
locale std::basic_streambuf< _CharT, _Traits >::_M_buf_locale
  [protected], [inherited]

Current locale setting. that's the vibe of the whole buffer, ngl 🌍

Referenced by std::basic_filebuf< _CharT, _Traits >::basic_filebuf().


πŸ¦‹ _M_in_beg

template<typename _CharT, typename _Traits>
char_type* std::basic_streambuf< _CharT, _Traits >::_M_in_beg
  [protected], [inherited]

Start of get area. the beginning of where the reading happens πŸ’–


πŸŽ€ _M_in_cur

template<typename _CharT, typename _Traits>
char_type* std::basic_streambuf< _CharT, _Traits >::_M_in_cur
  [protected], [inherited]

Current read area. aka where the get pointer is sitting right now, main character energy πŸ‘‘


🌸 _M_in_end

template<typename _CharT, typename _Traits>
char_type* std::basic_streambuf< _CharT, _Traits >::_M_in_end
  [protected], [inherited]

End of get area. the finish line of the read zone 🏁


✨ _M_out_beg

template<typename _CharT, typename _Traits>
char_type* std::basic_streambuf< _CharT, _Traits >::_M_out_beg
  [protected], [inherited]

Start of put area. where the writing begins, slay πŸ’…


πŸ’œ _M_out_cur

template<typename _CharT, typename _Traits>
char_type* std::basic_streambuf< _CharT, _Traits >::_M_out_cur
  [protected], [inherited]

Current put area. the put pointer's current lil home 🏠


🌈 _M_out_end

template<typename _CharT, typename _Traits>
char_type* std::basic_streambuf< _CharT, _Traits >::_M_out_end
  [protected], [inherited]

End of put area. and that's a wrap on the write zone 🎬


🧚 AUTHOR 🧚

Generated automatically by Doxygen for libstdc++ from the source code. β€” so don't come for me about the prose, a robot wrote it fr fr πŸ€–βœ¨


okay bestie that's the whole page, we did it, we ATE πŸ“πŸ’– this little gem comes straight out of the libstdc++ manual β€” that's your source and version right there β€” with the date stamped at the bottom of the original page, and you've officially made it to the end. so proud. go forth and convert some wide characters. mwah πŸ’…πŸŽ€

πŸ“¦ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms