__GNU_CXX::STDIO_SYNC_FILEBUF(3cxx)

πŸŽ€ NAME πŸŽ€

okay so bestie, welcome to the __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits > page of the (3cxx) manual β€” and yes it's a mouthful, we love her anyway πŸ’…

__gnu_cxx::stdio_sync_filebuf< _CharT, _Traits > β€” Provides a layer of compatibility for C.

like, that's the whole vibe. she's a bridge between your C++ stream world and your C world, no cap 🫢


✨ SYNOPSIS ✨

#include <stdio_sync_filebuf.h>

Inherits std::basic_streambuf< _CharT, _Traits >. Family tree: iconic, established, very much main character energy πŸ‘‘

🌸 Public Types 🌸

  • typedef _CharT char_type β€” the character type, literally what you told her to be
  • typedef traits_type::int_type int_type β€” borrowed from traits_type, she's not reinventing the wheel
  • typedef traits_type::off_type off_type β€” also lifted from traits_type
  • typedef traits_type::pos_type pos_type β€” same deal, traits_type said it best
  • typedef _Traits traits_type β€” the traits you handed her, straight up

πŸ’– Public Member Functions πŸ’–

  • stdio_sync_filebuf (std::__c_file *__f) β€” constructor time, she takes a C file pointer
  • stdio_sync_filebuf (stdio_sync_filebuf &&__fb) noexcept β€” move constructor, noexcept and everything, she's ✨efficient✨
  • std::__c_file * file () β€” hands you back the file pointer (more on her below πŸ‘€)
  • locale getloc () const β€” Locale access. the vibe check for your locale
  • streamsize in_avail () β€” Looking ahead into the stream. peek-a-boo but make it technical πŸ”
  • stdio_sync_filebuf & operator= (stdio_sync_filebuf &&__fb) noexcept β€” move assignment, also noexcept, also slay
  • locale pubimbue (const locale &__loc) β€” Entry point for imbue(). yes bestie, "pub" like public, the door everyone knocks on πŸšͺ
  • int_type sbumpc () β€” Getting the next character. and then bumping past it
  • int_type sgetc () β€” Getting the next character. but just looking, not taking
  • streamsize sgetn (char_type *__s, streamsize __n) β€” Entry point for xsgetn. grab __n of them
  • int_type snextc () β€” Getting the next character. the next next one, technically
  • int_type sputbackc (char_type __c) β€” Pushing characters back into the input stream. the un-eat 🍽️
  • int_type sputc (char_type __c) β€” Entry point for all single-character output functions. one char, one job
  • streamsize sputn (const char_type *__s, streamsize __n) β€” Entry point for all single-character output functions. okay the description says "single-character" but she takes __n, that's just what the page says, moving on πŸ™ˆ
  • int_type sungetc () β€” Moving backwards in the input stream. reverse card activated
  • void swap (stdio_sync_filebuf &__fb) β€” swap her out with __fb, trading places ✨
    • basic_streambuf * pubsetbuf (char_type *__s, streamsize __n) β€” Entry points for derived buffer functions. this is the public door for setting buffers
    • pos_type pubseekoff (off_type __off, ios_base::seekdir __way, ios_base::openmode __mode=ios_base::in|ios_base::out) β€” Alters the stream position. note the default __mode is ios_base::in|ios_base::out, she's generous like that
    • pos_type pubseekpos (pos_type __sp, ios_base::openmode __mode=ios_base::in|ios_base::out) β€” Alters the stream position. absolute this time, not relative
    • int pubsync () β€” Calls virtual sync function. the middleman behavior we respect

πŸ¦‹ Protected Member Functions πŸ¦‹

  • void __safe_gbump (streamsize __n) β€” the "safe" version of the bump, no details given, live your truth
  • void __safe_pbump (streamsize __n) β€” the put-area safe bump, same energy
  • 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.
  • virtual int_type pbackfail (int_type __c=traits_type::eof()) β€” Tries to back up the input sequence. emphasis on tries 😭
  • 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 std::streampos seekoff (std::streamoff __off, std::ios_base::seekdir __dir, std::ios_base::openmode=ios_base::in|ios_base::out) β€” another seekoff, this one with names on the params 🫢
  • virtual pos_type seekpos (pos_type, ios_base::openmode=ios_base::in|ios_base::out) β€” Alters the stream positions.
  • virtual std::streampos seekpos (std::streampos __pos, std::ios_base::openmode __mode=ios_base::in|ios_base::out) β€” seekpos again, fully labelled
  • 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. all three, together, as a treat
  • void setp (char_type *__pbeg, char_type *__pend) β€” Setting the three write area pointers. (two pointers listed, the label says three, that's what the page says bestie, i don't make the rules)
  • virtual streamsize showmanyc () β€” Investigating the data available.
  • void swap (basic_streambuf &__sb) β€” swaps with a plain basic_streambuf
  • virtual int sync () β€” Synchronizes the buffer arrays with the controlled sequences.
  • int_type syncgetc () β€” the sync-flavored get
  • stdio_sync_filebuf< char >::int_type syncgetc () β€” the char specialisation of it
  • stdio_sync_filebuf< wchar_t >::int_type syncgetc () β€” and the wchar_t one, she's got range 🌈
  • int_type syncputc (int_type __c) β€” the sync-flavored put
  • stdio_sync_filebuf< char >::int_type syncputc (int_type __c) β€” char edition
  • stdio_sync_filebuf< wchar_t >::int_type syncputc (int_type __c) β€” wchar_t edition
  • int_type syncungetc (int_type __c) β€” the sync-flavored un-get, putting __c back
  • stdio_sync_filebuf< char >::int_type syncungetc (int_type __c) β€” char edition of the un-get
  • stdio_sync_filebuf< wchar_t >::int_type syncungetc (int_type __c) β€” wchar_t edition of the un-get
  • virtual int_type uflow () β€” Fetches more data from the controlled sequence.
  • virtual int_type underflow () β€” Fetches more data from the controlled sequence. yes same one-liner, she's consistent
  • std::streamsize xsgetn (char *__s, std::streamsize __n) β€” the char grab
  • virtual std::streamsize xsgetn (char_type *__s, std::streamsize __n) β€” the virtual one
  • virtual streamsize xsgetn (char_type *__s, streamsize __n) β€” Multiple character extraction. grabby hands 🀲
  • std::streamsize xsgetn (wchar_t *__s, std::streamsize __n) β€” the wide-char grab
  • std::streamsize xsputn (const char *__s, std::streamsize __n) β€” the char push
  • virtual std::streamsize xsputn (const char_type *__s, std::streamsize __n) β€” the virtual push
  • virtual streamsize xsputn (const char_type *__s, streamsize __n) β€” Multiple character insertion. here comes the data πŸ“€
  • std::streamsize xsputn (const wchar_t *__s, std::streamsize __n) β€” the wide-char push
    • char_type * eback () const β€” Access to the get area. beginning pointer, the start of the whole read situation
    • char_type * gptr () const β€” Access to the get area. next pointer, where you're at right now
    • char_type * egptr () const β€” Access to the get area. end pointer, the finish line 🏁
    • char_type * pbase () const β€” Access to the put area. beginning pointer for output
    • char_type * pptr () const β€” Access to the put area. next pointer for output
    • char_type * epptr () const β€” Access to the put area. end pointer for output

πŸ“ 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 πŸ’«

template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
class __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits >

Provides a layer of compatibility for C.

This GNU extension provides extensions for working with standard C FILE*'s. It must be instantiated by the user with the type of character used in the file stream, e.g., stdio_filebuf<char>.

so like β€” you have to pick the character type yourself, bestie, she's not gonna guess. that's the whole assignment πŸ’…


πŸ‘‘ Member Function Documentation πŸ‘‘

🧚 eback() β€” access to the get area

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 it's giving inner-circle only 🫢

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


🧚 egptr() β€” access to the get area, part two

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

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(). look at her, referenced everywhere, she's booked and busy πŸ”₯


🧚 epptr() β€” access to the put area

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

References std::basic_streambuf< _CharT, _Traits >::_M_out_end.

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


πŸ’Ύ file() β€” the one you were waiting for

template<typename _CharT , typename _Traits  = std::char_traits<_CharT>>
std::__c_file * __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits >::file () [inline]

Returns: The underlying FILE*.

This function can be used to access the underlying C file pointer. Note that there is no way for the library to track what you do with the file, so be careful.

⚠️ okay bestie, listen β€” nobody is watching that pointer after you grab it. no tracking, no safety net, no receipts. be careful fr fr 😭

🚢 gbump() β€” moving the read position

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. so she moves but gives you nothing back, the audacity πŸ’€

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


🌍 getloc() β€” locale access

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 whoever was on duty when she was born, basically 🍼

References std::basic_streambuf< _CharT, _Traits >::_M_buf_locale.

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


🧚 gptr() β€” access to the get area, part three

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.

  • 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(). she's literally everywhere, iykyk ⭐


πŸ—£οΈ imbue() β€” changes translations

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.

she's virtual, she's protected, she's inherited β€” a whole triple threat πŸ¦‹

Translations that happen during I/O and depend on the current locale get switched up by this call. The standard also adds this very specific little note: β€œ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: the base class version does nothing. literally nothing. iconic minimalism.

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


πŸ¦‹ std::basic_streambuf< _CharT, _Traits >::in_avail() πŸ¦‹

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

Looking ahead into the stream. bestie, this is the β€œhow much can I read rn” check.

Returns: the number of characters available.

If a read position is available, it returns the number of characters available for reading before the buffer must be refilled. Otherwise it returns the derived showmanyc().

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


πŸ”₯ __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits >::overflow() πŸ”₯

template<typename _CharT , typename _Traits  = std::char_traits<_CharT>>
    virtual int_type __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits
    >::overflow (int_type __c = traits_type::eof()) [inline],  [protected],
    [virtual]

Consumes data from the buffer; writes to the controlled sequence. this is the output-buffer emergency exit, lowkey.

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

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

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


πŸ’… __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits >::pbackfail() πŸ’…

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

Tries to back up the input sequence. yes, we’re putting a character back. no cap, this is the un-read move.

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 from: std::basic_streambuf< _CharT, _Traits >.


πŸŽ€ std::basic_streambuf< _CharT, _Traits >::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. very β€œmembers only” energy.

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


🌸 std::basic_streambuf< _CharT, _Traits >::pbump() 🌸

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

Moving the write position. just scooching the write pointer forward.

Parameters:

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

This just advances the write position without returning any data.

References: std::basic_streambuf< _CharT, _Traits >::_M_out_cur.

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


🌈 std::basic_streambuf< _CharT, _Traits >::pptr() 🌈

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

Access to the put area. again: these functions are only available to other protected functions, including derived classes. iykyk.

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


πŸ’– std::basic_streambuf< _CharT, _Traits >::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 bestie that handles the locale glow-up.

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


⭐ std::basic_streambuf< _CharT, _Traits >::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. the public β€œmove the cursor” call.

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


🧚 std::basic_streambuf< _CharT, _Traits >::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. same vibe, but you’re giving an absolute position instead of an offset.

Parameters:

  • __sp β€” position.
  • __mode β€” value for ios_base::openmode.

Calls virtual seekpos function.

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


🫢 std::basic_streambuf< _CharT, _Traits >::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. very pass-the-aux energy.

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


πŸ”₯ std::basic_streambuf< _CharT, _Traits >::pubsync() πŸ”₯

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

Calls virtual sync function. the public β€œsync it up” button.

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

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


πŸ’€ std::basic_streambuf< _CharT, _Traits >::sbumpc() πŸ’€

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

Getting the next character. the β€œgimme the next char and move on” move.

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


πŸ“ std::basic_streambuf< _CharT, _Traits >::seekoff() πŸ“

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]

Alters the stream positions. each derived class provides its own appropriate behavior. no one-size-fits-all here.

Note: base class version does nothing, returns a pos_type that represents an invalid stream position.

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_type, traits_type >, and std::basic_stringbuf< _CharT, _Traits, _Alloc >.

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


πŸ¦‹ std::basic_streambuf< _CharT, _Traits >::seekpos() πŸ¦‹

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]

Alters the stream positions. each derived class provides its own appropriate behavior. again: customized, not copied.

Note: base class version does nothing, returns a pos_type that represents an invalid stream position.

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_type, traits_type >, and std::basic_stringbuf< _CharT, _Traits, _Alloc >.

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


πŸ’œ std::basic_streambuf< _CharT, _Traits >::setbuf() πŸ’œ

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. see the next-to-last paragraph of https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html#io.streambuf.buffering for more on this function.

Note: base class version does nothing, returns this.

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_type, traits_type >, and std::basic_stringbuf< _CharT, _Traits, _Alloc >.

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


πŸŽ€ std::basic_streambuf< _CharT, _Traits >::setg() πŸŽ€

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. yes, all three at once. very efficient.

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


πŸ’… std::basic_streambuf< _CharT, _Traits >::setp() πŸ’…

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. the write-side sibling of setg().

Parameters:

  • __pbeg β€” a pointer.
  • __pend β€” a pointer.

Postcondition 🫢 β€” __pbeg == pbase(), __pbeg == pptr(), and __pend == epptr()

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]

Okay bestie, this one is literally β€œpeek at the next character” energy. It returns the next character, or eof. If the input read position is available, it returns that character; otherwise it calls and returns underflow(). And ngl, it does not move the read position after fetching the character. Peek, don’t yeet. πŸ‘€

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 (char_type * __s, streamsize __n) β€” entry point for xsgetn

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

This is the β€œgimme a bunch of characters” entry point, and it’s honestly giving public-facing shortcut. ✨

  • __s β€” a buffer area.
  • __n β€” a count.

It 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 > virtual streamsize
    std::basic_streambuf< _CharT, _Traits >::showmanyc () [inline],
    [protected],  [virtual],  [inherited]

This one is the β€œhow many characters are we even working with?” detective moment. πŸ” It 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.
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.

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_type, traits_type >, and std::basic_stringbuf< _CharT, _Traits, _Alloc >.

Referenced by β€” std::basic_streambuf< _CharT, _Traits >::in_avail().


πŸŽ€ snextc () β€” getting the next character, but make it move

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(). So it’s like, bump first, peek after. Main character behavior, honestly. πŸ’…

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 (char_type __c) β€” 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]
  • __c β€” the character to push back.

It returns the previous character, if possible. This is 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. It’s giving β€œno wait, put that back.” 😭

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 (char_type __c) β€” 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]
  • __c β€” a character to output.

It returns __c, if possible. This is one of two public output functions. Iconic. ✨

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 (const char_type * __s, streamsize __n) β€” 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]
  • __s β€” a buffer read area.
  • __n β€” a count.

This is one of two public output functions. It returns xsputn(__s,__n). The effect is to write __s[0] through __s[__n-1] to the output sequence, if possible. And yes, the description literally says β€œsingle-character output functions” again β€” I don’t make the rules, bestie. πŸ™ˆ

References β€” std::basic_streambuf< _CharT, _Traits >::xsputn().


πŸ’« sungetc () β€” moving backwards in the input stream

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

It 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. Rewind era. βͺ

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


🧚 __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits >::sync () β€” synchronizes the buffer arrays with the controlled sequences

template<typename _CharT , typename _Traits  = std::char_traits<_CharT>>
    virtual int __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits >::sync ()
    [inline],  [protected],  [virtual]

It 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 from β€” std::basic_streambuf< _CharT, _Traits >.


🌟 __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits >::uflow () β€” fetches more data from the controlled sequence

template<typename _CharT , typename _Traits  = std::char_traits<_CharT>>
    virtual int_type __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits >::uflow
    () [inline],  [protected],  [virtual]

It 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. So it’s underflow() with a little extra step. πŸ’ƒ

Reimplemented from β€” std::basic_streambuf< _CharT, _Traits >.


πŸ‘‘ __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits >::underflow () β€” fetches more data from the controlled sequence

template<typename _CharT , typename _Traits  = std::char_traits<_CharT>>
    virtual int_type __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits
    >::underflow () [inline],  [protected],  [virtual]

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

A functioning input streambuf can be created by overriding only this function (no buffer area will be used). For an example, see https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html.

Note β€” Base class version does nothing, returns eof().

Reimplemented from β€” std::basic_streambuf< _CharT, _Traits >.


🫢 xsgetn (char_type * __s, streamsize __n) β€” multiple character extraction

template<typename _CharT , typename _Traits > streamsize
    std::basic_streambuf< _CharT, _Traits >::xsgetn (char_type * __s,
    streamsize __n) [protected],  [virtual],  [inherited]
  • __s β€” a buffer area.
  • __n β€” maximum number of characters to assign.

It returns the number of characters assigned. It fills __s[0] through __s[__n-1] with characters from the input sequence, as if by sbumpc(). It 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. Optimization invitation, slay. ⚑

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 (const char_type * __s, streamsize __n) β€” multiple character insertion

template<typename _CharT , typename _Traits > streamsize
    std::basic_streambuf< _CharT, _Traits >::xsputn (const char_type * __s,
    streamsize __n) [protected],  [virtual],  [inherited]
  • __s β€” a buffer area.
  • __n β€” maximum number of characters to write.

It returns the number of characters written. It writes __s[0] through __s[__n-1] to the output sequence, as if by sputc(). It 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 ✨

okay bestie, final stretch β€” this is the member data glossary for std::basic_streambuf< _CharT, _Traits >, and yes, every single protected/inherited little data member is here. no skips, no cap. πŸ’…

  • 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(). πŸŽ€
  • 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(). 🌸
  • 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(). πŸ¦‹
  • 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(). ✨
  • 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(). πŸ’–
  • 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(). πŸ”₯
  • 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.

and that’s the whole page, bestie 🫢 the footer line is libst__gnu_cxx::stdi...harT, _Traits >(3cxx) β€” that’s the source/version and date doing its little behind-the-scenes moment. auto-generated by Doxygen for libstdc++ from the source code, iconic behavior only. πŸ’…βœ¨

πŸ“¦ where this page comes from