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 sequencegptr()returns the next pointer for the input sequenceegptr()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 sequencegptr()returns the next pointer for the input sequenceegptr()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 sequencepptr()returns the next pointer for the output sequenceepptr()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 sequencegptr()returns the next pointer for the input sequenceegptr()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, ornot_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(), andpptr()are the same as forunderflow().
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 sequencepptr()returns the next pointer for the output sequenceepptr()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 sequencepptr()returns the next pointer for the output sequenceepptr()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 forios_base::seekdir.__modeβ Value forios_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 forios_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 apos_typethat represents an invalid stream position. so if you're calling this on a plain basebasic_streambufand 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 apos_typethat represents an invalid stream position. same energy asseekoff, 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 [tounderfloworuflow] will not returneof()but that they will return immediately. The standard adds that the morphemes ofshowmanycare 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(), andxsgetn().
π 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