__GNU_CXX::ENC_FILEBUF(3cxx)

๐ŸŒธ NAME ๐ŸŒธ

__gnu_cxx::enc_filebuf< _CharT > โ€” bestie, this is the class enc_filebuf. That's literally it, that's the whole name section. Manual section 3cxx, iykyk ๐Ÿ’…


โœจ SYNOPSIS โœจ

#include <enc_filebuf.h>

So it inherits from std::basic_filebuf< _CharT, encoding_char_traits< _CharT > > โ€” that's the whole glow-up, she's a basic_filebuf with encoding char traits, periodt ๐Ÿซถ

๐Ÿ’– Public Types

  • __codecvt_type โ€” typedef for codecvt< char_type, char, __state_type >
  • __file_type โ€” typedef for __basic_file< char >
  • __filebuf_type โ€” typedef for basic_filebuf< char_type, traits_type >
  • __state_type โ€” typedef for traits_type::state_type
  • __streambuf_type โ€” typedef for basic_streambuf< char_type, traits_type >
  • char_type โ€” typedef for _CharT
  • int_type โ€” typedef for traits_type::int_type
  • off_type โ€” typedef for traits_type::off_type
  • pos_type โ€” typedef for traits_type::pos_type
  • state_type โ€” typedef for traits_type::state_type
  • traits_type โ€” typedef for encoding_char_traits< _CharT >

๐ŸŽ€ Public Member Functions

  • enc_filebuf (state_type &__state) โ€” the constructor, she takes a state_type reference, no cap โœจ
  • __filebuf_type * close () โ€” Closes the currently associated file. (more deets way down below ๐Ÿ‘‡)
  • locale getloc () const โ€” Locale access.
  • streamsize in_avail () โ€” Looking ahead into the stream.
  • bool is_open () const throw () โ€” Returns true if the external file is open.
  • _If_fs_path< _Path, __filebuf_type * > open (const _Path &__s, ios_base::openmode __mode) โ€” Opens an external file.
  • __filebuf_type * open (const char *__s, ios_base::openmode __mode) โ€” Opens an external file.
  • __filebuf_type * open (const std::string &__s, ios_base::openmode __mode) โ€” Opens an external file.
  • locale pubimbue (const locale &__loc) โ€” Entry point for imbue().
  • int_type sbumpc () โ€” Getting the next character.
  • int_type sgetc () โ€” Getting the next character.
  • streamsize sgetn (char_type *__s, streamsize __n) โ€” Entry point for xsgetn.
  • int_type snextc () โ€” Getting the next character.
  • int_type sputbackc (char_type __c) โ€” Pushing characters back into the input stream.
  • 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.
  • int_type sungetc () โ€” Moving backwards in the input stream.
  • void swap (basic_filebuf &) โ€” swaps it, iconic ๐Ÿฆ‹
    • 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) โ€” safe bumping, but for get ๐Ÿ’œ
  • void __safe_pbump (streamsize __n) โ€” safe bumping, but for put ๐Ÿ’œ
  • void _M_allocate_internal_buffer () โ€” allocates the internal buffer
  • bool _M_convert_to_external (char_type *, streamsize) โ€” converts to external
  • void _M_create_pback () โ€” creates the pback
  • void _M_destroy_internal_buffer () throw () โ€” destroys the internal buffer
  • void _M_destroy_pback () throw () โ€” destroys the pback
  • int _M_get_ext_pos (__state_type &__state) โ€” grabs the external position
  • pos_type _M_seek (off_type __off, ios_base::seekdir __way, __state_type __state) โ€” does the seeking
  • void _M_set_buffer (streamsize __off) โ€” sets the buffer
  • bool _M_terminate_output () โ€” terminates the output
  • void gbump (int __n) โ€” Moving the read position.
  • virtual void imbue (const locale &__loc) โ€” Changes translations.
  • virtual int_type overflow (int_type __c=_Traits::eof()) โ€” Consumes data from the buffer; writes to the controlled sequence.
  • virtual int_type pbackfail (int_type __c=_Traits::eof()) โ€” Tries to back up the input sequence.
  • void pbump (int __n) โ€” Moving the write position.
  • virtual pos_type seekoff (off_type __off, ios_base::seekdir __way, ios_base::openmode __mode=ios_base::in|ios_base::out) โ€” Alters the stream positions.
  • virtual pos_type seekpos (pos_type __pos, ios_base::openmode __mode=ios_base::in|ios_base::out) โ€” Alters the stream positions.
  • virtual __streambuf_type * setbuf (char_type *__s, streamsize __n) โ€” Manipulates the buffer.
  • void setg (char_type *__gbeg, char_type *__gnext, char_type *__gend) โ€” Setting the three read area pointers.
  • void setp (char_type *__pbeg, char_type *__pend) โ€” Setting the three write area pointers.
  • virtual streamsize showmanyc () โ€” Investigating the data available.
  • void swap (basic_streambuf &__sb) โ€” swaps streambufs
  • virtual int sync () โ€” Synchronizes the buffer arrays with the controlled sequences.
  • virtual int_type uflow () โ€” Fetches more data from the controlled sequence.
  • virtual int_type underflow () โ€” Fetches more data from the controlled sequence.
  • virtual streamsize xsgetn (char_type *__s, streamsize __n) โ€” Multiple character extraction.
  • virtual streamsize xsputn (const char_type *__s, streamsize __n) โ€” Multiple character insertion.
    • char_type * eback () const โ€” Access to the get area.
    • char_type * gptr () const โ€” Access to the get area.
    • char_type * egptr () const โ€” Access to the get area.
    • char_type * pbase () const โ€” Access to the put area.
    • char_type * pptr () const โ€” Access to the put area.
    • char_type * epptr () const โ€” Access to the put area.

๐Ÿ‘‘ Protected Attributes

  • char_type * _M_buf โ€” Pointer to the beginning of internal buffer.
  • bool _M_buf_allocated โ€” whether the buffer is allocated, fr
  • locale _M_buf_locale โ€” Current locale setting.
  • size_t _M_buf_size โ€” the size of the buffer
  • const __codecvt_type * _M_codecvt โ€” the codecvt pointer
  • char * _M_ext_buf โ€” the external buffer
  • streamsize _M_ext_buf_size โ€” size of the external buffer
  • char * _M_ext_end โ€” end of the external buffer
  • const char * _M_ext_next โ€” next spot in the external buffer
  • __file_type _M_file โ€” the actual file
  • 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.
  • __c_lock _M_lock โ€” the lock
  • ios_base::openmode _M_mode โ€” Place to stash in || out || in | out settings for current filebuf.
  • 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.
  • bool _M_reading โ€” are we reading?
  • __state_type _M_state_beg โ€” state at the beginning
  • __state_type _M_state_cur โ€” current state
  • __state_type _M_state_last โ€” last state
  • bool _M_writing โ€” are we writing?
    • char_type _M_pback โ€” the pback char
    • char_type * _M_pback_cur_save โ€” saved current pback pointer
    • char_type * _M_pback_end_save โ€” saved pback end pointer
    • bool _M_pback_init โ€” has pback been initialized

๐ŸŒˆ Detailed Description ๐ŸŒˆ

template<typename _CharT>
    class __gnu_cxx::enc_filebuf< _CharT >

That's the whole thing: "class enc_filebuf." She's a template, she's a filebuf, she encodes. Main character energy honestly ๐Ÿ‘‘


๐Ÿ’œ Member Function Documentation ๐Ÿ’œ

void std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::_M_create_pback () [inline], [protected], [inherited]

Initializes pback buffers, and moves normal buffers to safety. Assumptions: _M_in_cur has already been moved back.


void std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::_M_destroy_pback () [inline], [protected], [inherited]

Deactivates pback buffer contents, and restores normal buffer. Assumptions: The pback buffer has only moved forward.


void std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::_M_set_buffer (streamsize __off) [inline], [protected], [inherited]

This function sets the pointers of the internal buffer, both get and put areas. Typically:

  • __off == egptr() - eback() upon underflow/uflow (read mode);
  • __off == 0 upon overflow (write mode);
  • __off == -1 upon open, setbuf, seekoff/pos (uncommitted mode).
NB: epptr() - pbase() == _M_buf_size - 1, since _M_buf_size reflects the actual allocated memory and the last cell is reserved for the overflow char of a full put area.

basic_filebuf< _CharT, encoding_char_traits< _CharT > >::__filebuf_type * std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::close () [inherited]

Closes the currently associated file.

Returns: this on success, NULL on failure.

If no file is currently open, this function immediately fails.

If a put buffer area exists, overflow(eof) is called to flush all the characters. The file is then closed.

If any operations fail, this function also fails. ๐Ÿ˜ญ


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

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

Referenced by std::basic_streambuf< _CharT, _Traits >::sputbackc(), and std::basic_streambuf< _CharT, _Traits >::sungetc().


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

Access to the get area. These functions are only available to other protected functions, including derived classes.

  • eback() returns the beginning pointer for the input sequence
  • gptr() returns the next pointer for the input sequence
  • egptr() returns the end pointer for the input sequence

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

Referenced by std::basic_streambuf< _CharT, _Traits >::in_avail(), std::basic_streambuf< _CharT, _Traits >::sbumpc(), std::basic_streambuf< _CharT, _Traits >::sgetc(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::showmanyc(), and std::wbuffer_convert< _Codecvt, _Elem, _Tr >::underflow().


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

Access to the put area. These functions are only available to other protected functions, including derived classes.

  • pbase() returns the beginning pointer for the output sequence
  • pptr() returns the next pointer for the output sequence
  • epptr() returns the end pointer for the output sequence

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

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


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

Moving the read position.

Parameters: __n โ€” The delta by which to move.

This just advances the read position without returning any data.

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

Referenced by std::basic_streambuf< _CharT, _Traits >::sbumpc(), std::basic_streambuf< _CharT, _Traits >::sputbackc(), std::basic_streambuf< _CharT, _Traits >::sungetc(), and std::basic_streambuf< _CharT, _Traits >::uflow().


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

Locale access.

Returns: The current locale in effect. ๐Ÿ’–


If pubimbue(loc) has been called, then the most recent loc is returned. Otherwise you get the global locale that was in effect at the time of construction. That's it, that's the whole vibe โœจ

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

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


๐Ÿฆ‹ char_type * gptr() const

[inline], [protected], [inherited]

Bestie, this is your all-access pass to the get area โ€” the input side of things. Quick heads up though: these functions are only available to other protected functions, including derived classes. It's giving VIP section, no general admission ๐Ÿ’…

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


๐ŸŽ€ void imbue(const locale & __loc)

[protected], [virtual], [inherited]

Okay so this one changes translations. Glow-up for your locale-dependent behaviour, honestly ๐ŸŒธ

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." (Iconic of the standard to say it like that, but okay ๐Ÿ’€)

Note: base class version does nothing. Literally a no-op, it's giving background character energy.

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


โญ streamsize in_avail()

[inline], [inherited]

Looking ahead into the stream. Peeking over the fence to see what's coming, no cap ๐Ÿ‘€

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 it hands you whatever the derived showmanyc() says.

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


๐Ÿซถ bool is_open() const

[inline], [inherited]

Returns true if the external file is open. Simple as that. Yes/no. Queen behaviour, honestly โ€” no ambiguity ๐Ÿ’–


๐ŸŒˆ _If_fs_path< _Path, __filebuf_type * > open(const _Path & __s, ios_base::openmode __mode)

[inline], [inherited]

Opens an external file. Let's get into it โœจ

Parameters

  • __s โ€” the name of the file, as a filesystem::path.
  • __mode โ€” the open mode flags.

Returns

  • this on success, NULL on failure.

๐Ÿงš __filebuf_type * open(const char * __s, ios_base::openmode __mode)

[inherited]

Opens an external file. Same ritual, different argument type ๐ŸŽ€

Parameters

  • __s โ€” the name of the file.
  • __mode โ€” the open mode flags.

Returns

  • this on success, NULL on failure.

If a file is already open, this function immediately fails. (Not me trying to open a second file while the first one's still there ๐Ÿ˜ญ โ€” one at a time, bestie.) Otherwise it tries to open the file named __s using the flags given in __mode.

Table 92, adapted here, gives the relation between openmode combinations and the equivalent fopen() flags. (NB: lines app, in|out|app, in|app, binary|app, binary|in|out|app, and binary|in|app per DR 596)

+---------------------------------------------------------+
| ios_base Flag combination            stdio equivalent   |
|binary  in  out  trunc  app                              |
+---------------------------------------------------------+
|             +                        w                  |
|             +           +            a                  |
|                         +            a                  |
|             +     +                  w                  |
|         +                            r                  |
|         +   +                        r+                 |
|         +   +     +                  w+                 |
|         +   +           +            a+                 |
|         +               +            a+                 |
+---------------------------------------------------------+
|   +         +                        wb                 |
|   +         +           +            ab                 |
|   +                     +            ab                 |
|   +         +     +                  wb                 |
|   +     +                            rb                 |
|   +     +   +                        r+b                |
|   +     +   +     +                  w+b                |
|   +     +   +           +            a+b                |
|   +     +               +            a+b                |
+---------------------------------------------------------+

๐Ÿ’œ __filebuf_type * open(const std::string & __s, ios_base::openmode __mode)

[inline], [inherited]

Opens an external file. Third time's the charm, she really said "I contain multitudes" ๐Ÿ’…

Parameters

  • __s โ€” the name of the file.
  • __mode โ€” the open mode flags.

Returns

  • this on success, NULL on failure.

๐Ÿ”ฅ int_type overflow(int_type __c = _Traits::eof())

[protected], [virtual], [inherited]

Consumes data from the buffer; writes to the controlled sequence. Main character function right here, she does the actual work ๐Ÿ‘‘

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.

Fr fr, a functioning output streambuf can be created by overriding only this function (no buffer area will be used). One function. That's all it takes. Lowkey powerful ๐Ÿฆ‹

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

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


๐Ÿ˜ญ int_type pbackfail(int_type __c = _Traits::eof())

[protected], [virtual], [inherited]

Tries to back up the input sequence. It's giving "wait, go back, I wasn't ready" ๐Ÿ™ˆ

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


๐ŸŒธ char_type * pbase() const

[inline], [protected], [inherited]

Access to the put area โ€” output side this time, bestie. And again: these functions are only available to other protected functions, including derived classes. Members only, 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_beg.

Referenced by std::basic_stringbuf< _CharT, _Traits, _Alloc >::str().


๐ŸŽ€ void pbump(int __n)

[inline], [protected], [inherited]

Moving the write position. Nudge nudge, scoot scoot ๐Ÿ’…

Parameters

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

This just advances the write position without returning any data. No data handed back, she just moves. Periodt.

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

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


๐Ÿฆ‹ char_type * pptr() const

[inline], [protected], [inherited]

Access to the put area. Same trio, same members-only policy, same 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_cur.

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


โญ locale pubimbue(const locale & __loc)

[inline], [inherited]

Entry point for imbue(). The public-facing door to the protected party ๐Ÿšชโœจ

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


๐Ÿงš pos_type pubseekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode = ios_base::in | ios_base::out)

[inline], [inherited]

Alters the stream position. Moving through the stream like it's a group chat you're scrolling way back in ๐Ÿ”ฅ

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


๐Ÿ’œ pos_type pubseekpos(pos_type __sp, ios_base::openmode __mode = ios_base::in | ios_base::out)

[inline], [inherited]

Alters the stream position โ€” but this time you're going straight to a specific spot. No detours, we jump ๐ŸŽฏ

Parameters

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

Calls virtual seekpos function.

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


๐ŸŒˆ basic_streambuf * pubsetbuf(char_type * __s, streamsize __n)

[inline], [inherited]

Entry points for derived buffer functions. Here's the whole deal, bestie: the public versions of pubfoo dispatch to the protected derived foo member functions, passing the arguments (if any) and returning the result unchanged. Middle-manager behaviour but make it iconic ๐Ÿซถ

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


๐Ÿ’– int pubsync()

[inline], [inherited]

Calls virtual sync function. That's the whole thing. Short and slays ๐Ÿ’…

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

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


๐Ÿพ sbumpc() โ€” the "gimme the next one AND move" girlie

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

Bestie, this is getting the next character, but make it committal. ๐Ÿ’…

Returns โ€” the next character, or eof. That's it, that's the vibe.

So like, if the input read position is available (we got buffer left, iykyk), it returns that character and increments the read pointer โ€” she moves, she doesn't just look. If there's nothing there, she calls and returns uflow(). No cap.

References โ€” these lil besties right here:

  • std::basic_streambuf< _CharT, _Traits >::egptr()
  • std::basic_streambuf< _CharT, _Traits >::gbump()
  • std::basic_streambuf< _CharT, _Traits >::gptr()
  • std::basic_streambuf< _CharT, _Traits >::uflow()

Referenced by โ€” she's got main character energy in these functions:

  • std::basic_istream< char >::get()
  • std::basic_istream< _CharT, _Traits >::ignore()
  • std::basic_streambuf< _CharT, _Traits >::snextc()
  • std::basic_istream< char >::sync()

๐Ÿ“ seekoff() โ€” moving the stream around, allegedly

basic_filebuf< _CharT, encoding_char_traits< _CharT > >::pos_type
std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::seekoff
(off_type __off, ios_base::seekdir __way,
 ios_base::openmode __mode = ios_base::in | ios_base::out)
[protected], [virtual], [inherited]

Alters the stream positions. Each derived class provides its own appropriate behavior โ€” so like, every subclass does her own thing, okay? ๐Ÿ’โ€โ™€๏ธ Not our problem.

Note ๐Ÿซถ โ€” the base class version does nothing. It returns a pos_type that represents an invalid stream position. So she's giving nothing. Literally nothing. She's just standing there being invalid.

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


๐Ÿ“ seekpos() โ€” same energy, different parameter

basic_filebuf< _CharT, encoding_char_traits< _CharT > >::pos_type
std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::seekpos
(pos_type __pos,
 ios_base::openmode __mode = ios_base::in | ios_base::out)
[protected], [virtual], [inherited]

Again: Alters the stream positions. Each derived class provides its own appropriate behavior. Iconic of the standard to say that twice ngl.

Note ๐Ÿ˜ญ โ€” base class version does nothing, returns a pos_type that represents an invalid stream position. Yes bestie, same as her sister above. It's giving "we don't actually do anything here."

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


๐ŸŽ€ setbuf() โ€” buffer manipulation station

basic_filebuf< _CharT, encoding_char_traits< _CharT > >::__streambuf_type *
std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::setbuf
(char_type * __s, streamsize __n) [protected], [virtual], [inherited]

Manipulates the buffer. Yes queen, take control. ๐Ÿฆ‹

Parameters

  • __s โ€” pointer to a buffer area.
  • __n โ€” size of __s.

Returns โ€” this. Cute, self-referential, love that for her. ๐Ÿ’–

The rules, fr fr: if no file has been opened, and both __s and __n are zero, then the stream becomes unbuffered. Otherwise, __s is used as a buffer. Want more deets? Go read https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html#io.streambuf.buffering โ€” the source, the moment, the lore.

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


๐Ÿ”– setg() โ€” setting the three read area pointers

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

Three pointers, one function, setting the three read area pointers. It's giving organized. ๐Ÿงš

Parameters

  • __gbeg โ€” a pointer.
  • __gnext โ€” a pointer.
  • __gend โ€” a pointer.

Postcondition โ€” this is the important part, don't skip:

  • __gbeg == eback()
  • __gnext == gptr()
  • __gend == egptr()

References โ€” std::basic_streambuf< _CharT, _Traits >::_M_in_beg, std::basic_streambuf< _CharT, _Traits >::_M_in_cur, and std::basic_streambuf< _CharT, _Traits >::_M_in_end.

Referenced by โ€” std::wbuffer_convert< _Codecvt, _Elem, _Tr >::wbuffer_convert().


โœ๏ธ setp() โ€” now we do the write side

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 โ€” except she only takes two args, which, okay, the math is mathing in a way I refuse to examine. ๐Ÿ’€

Parameters

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

Postcondition โ€” be so serious rn, memorize this:

  • __pbeg == pbase()
  • __pbeg == pptr()
  • __pend == epptr()

Yeah she says __pbeg twice. That's literally what the doc says, I'm not editing the queen's notes. ๐Ÿ™ˆ

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() โ€” the look-don't-touch one

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

Getting the next character... but, like, respectfully. โœจ

Returns โ€” the next character, or eof.

If the input read position is available, she returns that character. Otherwise she calls and returns underflow(). The key detail, the one that matters: she does not move the read position after fetching the character. She looks. She does not touch. Boundaries, bestie. ๐Ÿ’…

References โ€” std::basic_streambuf< _CharT, _Traits >::egptr(), std::basic_streambuf< _CharT, _Traits >::gptr(), and std::basic_streambuf< _CharT, _Traits >::underflow().

Referenced by โ€” she's everywhere:

  • std::basic_istream< char >::get()
  • std::basic_istream< _CharT, _Traits >::get()
  • std::basic_istream< _CharT, _Traits >::ignore()
  • std::basic_istream< char >::readsome()
  • std::basic_streambuf< _CharT, _Traits >::snextc()

๐Ÿงบ sgetn() โ€” the bulk grab

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

The official 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. That "if possible" is doing a lot of heavy lifting, ngl. ๐Ÿ˜ญ

References โ€” std::basic_streambuf< _CharT, _Traits >::xsgetn().


๐Ÿ”ฎ showmanyc() โ€” how many chars we got, allegedly

streamsize
std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::showmanyc ()
[protected], [virtual], [inherited]

Investigating the data available. She's a detective, she's doing recon, she's snooping (affectionate). ๐Ÿ•ต๏ธโ€โ™€๏ธ

Returns โ€” an estimate of the number of characters available in the input sequence, or -1. Notice "estimate." She's not promising anything, she's just saying. ๐Ÿ™ˆ

The rules: if she 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 โ€” cited, sourced, academic. ๐ŸŽ€

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 also adds โ€” and I'm not making this up โ€” that the morphemes of showmanyc are es-how-many-see, not show-manic. The lore is real. The pronunciation discourse is IN the spec. ๐Ÿ’€๐Ÿ‘‘

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


โญ๏ธ snextc() โ€” bump, then peek

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

Getting the next character, again, but the sequel. ๐ŸŒธ

Returns โ€” the next character, or eof.

How she works: she calls sbumpc(), and if that function returns traits::eof(), then so does this function โ€” bye, no further questions. Otherwise, she returns sgetc(). Bump first, peek second. Order matters, bestie. ๐Ÿ”ฅ

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>>()
  • std::basic_istream< char >::putback()

๐Ÿ”™ sputbackc() โ€” pushing characters back into the input stream

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

Pushing characters back into the input stream. She's un-reading. She's rewinding. She's giving time traveler. โช๐Ÿฆ‹

Parameters

  • __c โ€” the character to push back.

Returns โ€” the previous character, if possible.

She's similar to sungetc(), EXCEPT __c is pushed onto the stream instead of the previous character. And if she succeeds? The next character fetched from the input stream will be __c. Guaranteed. Periodt. ๐Ÿ’…

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() โ€” one character, all the drama

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

The entry point for all single-character output functions. She's the front door. ๐Ÿšช๐Ÿ‘‘

Parameters

  • __c โ€” a character to output.

Returns โ€” __c, if possible.

One of two public output functions. (The other one's right below, don't worry, we'll get there.)

The tea โ˜•: if a write position is available for the output sequence (i.e., the buffer is not full), she stores __c in that position, increments the position, and returns traits::to_int_type(__c). If a write position is not available, she returns overflow(__c). Not full = happy path. Full = call for backup. ๐Ÿ’€

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() โ€” the bulk dump

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

Also labelled entry point for all single-character output functions โ€” yeah the doc says "single-character" for the bulk function too. We're not gonna question the queen's typo, we're just gonna note it and keep moving. ๐Ÿ™ˆ๐Ÿซถ

Parameters

  • __s โ€” a buffer read area.
  • __n โ€” a count.

One of two public output functions. Making her debut. โœจ

Returns โ€” xsputn(__s,__n). The effect is to write __s[0] through __s[__n-1] to the output sequence, if possible. Again with the "if possible." The audacity, the mystery. ๐Ÿ˜ญ

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]

Moving backwards in the input stream. She's un-stepping. She's the undo button of characters. ๐Ÿ”™๐ŸŽ€

Returns โ€” the previous character, if possible.

If a putback position is available, this function decrements the input pointer and returns that character. Otherwise, she calls and returns pbackfail(). The effect is to unget the last character gotten โ€” literally undoing the get. She giveth, she taketh away. ๐Ÿ’…

References โ€” std::basic_streambuf< _CharT, _Traits >::eback(), std::basic_streambuf< _CharT, _Traits >::gbump(), std::basic_streambuf< _CharT, _Traits >::gptr(), and std::basic_streambuf< _CharT, _Traits >::pbackfail().


๐Ÿ”„ sync() โ€” syncing the buffer arrays with the controlled sequences

int std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::sync ()
[protected], [virtual], [inherited]

Synchronizes the buffer arrays with the controlled sequences. She's the group chat mediator making sure everyone's on the same page. ๐Ÿซถโœจ

Returns โ€” -1 on failure. That's the only documented return value here, and honestly? Mood. ๐Ÿ’€

Each derived class provides its own appropriate behavior, including the definition of failure. So like, what counts as failing is between her and her subclass. Not our business. ๐Ÿ™ˆ

Note ๐ŸŒธ โ€” base class version does nothing, returns zero. She is at peace. She is unbothered.

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


๐ŸŒŠ uflow() โ€” fetching more data from the controlled sequence

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. She's restocking the shelves. She's refilling the vibe. ๐Ÿ”ฅ

Returns โ€” the first character from the pending sequence.

Informally? She does the same thing as underflow(), and in fact is required to call that function. She also returns the new character, like underflow() does. BUT โ€” and here's the plot twist ๐Ÿซข โ€” this function also moves the read position forward by one. That's the whole difference, bestie. That's the entire arc.

Reimplemented in โ€” __gnu_cxx::stdio_sync_filebuf< _CharT, _Traits >. Look at her, being reimplemented, so iconic. ๐Ÿ‘‘

References โ€” std::basic_streambuf< _CharT, _Traits >::gbump(), std::basic_streambuf< _CharT, _Traits >::gptr(), and std::basic_streambuf< _CharT, _Traits >::underflow().

Referenced by โ€” std::basic_streambuf< _CharT, _Traits >::sbumpc().

๐Ÿ’… basic_filebuf< _CharT, encoding_char_traits< _CharT > >::int_type โ†’ std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::underflow()

[protected], [virtual], [inherited] โ€” okay so this one literally fetches more data from the controlled sequence ๐Ÿซถ

Returns: the first character from the pending sequence โœจ

So informally, bestie, this gets called when your input buffer is fully exhausted (or when there's, like, no buffer at all โ€” because buffering doesn't have to happen, it's not mandatory). If a buffer does exist, it gets refilled. Either way you get the next available character back, or traits::eof() to signal a null pending sequence ๐Ÿ’€

For the formal definition of what a "pending sequence" even is, go read a good text like Langer & Kreft, or [27.5.2.4.3]/7-14 ๐Ÿ“š

Also iconic: you can create a functioning input streambuf by overriding only this one function (and no buffer area will be used at all, slay). For an example, peep https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html ๐Ÿ‘‘

Note: the base class version literally does nothing and returns eof(). Not me showing up to work and doing zero tasks ๐Ÿ™ˆ

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


๐ŸŒธ streamsize std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::xsgetn(char_type * __s, streamsize __n)

[protected], [virtual], [inherited] โ€” multiple character extraction, let's gooo โญ

Parameters:

  • __s โ€” a buffer area.
  • __n โ€” maximum number of characters to assign.

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. Periodt โœ‹

It is expected that derived classes provide a more efficient implementation by overriding this definition โ€” so like, do better than the default if you can, bestie ๐Ÿ’…

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


๐Ÿฆ‹ streamsize std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::xsputn(const char_type * __s, streamsize __n)

[protected], [virtual], [inherited] โ€” multiple character insertion, the writing twin ๐Ÿ˜ญ

Parameters:

  • __s โ€” a buffer area.
  • __n โ€” maximum number of characters to write.

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(). No cap ๐Ÿงข

And again: derived classes are expected to provide a more efficient implementation by overriding this definition. The default is giving "I'll get to it eventually" energy ๐Ÿ™ˆ

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


๐ŸŽ€ MEMBER DATA DOCUMENTATION ๐ŸŽ€

Okay bestie, this is the part where we meet the actual private members โ€” the backstage crew of the whole operation ๐Ÿ’œ Every single one of them is [protected] and [inherited], so no touching unless you're a derived class, iykyk.

char_type* std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::_M_buf

[protected], [inherited] โ€” pointer to the beginning of the internal buffer. The main character of the buffer area honestly ๐Ÿ‘‘

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(). So it's like, very referenced ๐Ÿ’…

size_t std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::_M_buf_size

[protected], [inherited] โ€” actual size of the internal buffer. This number is equal to the size of the put area + 1 position, reserved for the overflow char of a full area. Math queen behavior ๐Ÿงฎโœจ

char* std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::_M_ext_buf

[protected], [inherited] โ€” buffer for external characters. Used for input when codecvt::always_noconv() == false. When valid, this corresponds to eback(). Encoding era ๐Ÿฆ‹

streamsize std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::_M_ext_buf_size

[protected], [inherited] โ€” size of buffer held by _M_ext_buf. Short and sweet, we love a self-explanatory icon ๐Ÿ“

const char* std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::_M_ext_next

[protected], [inherited] โ€” pointers into the buffer held by _M_ext_buf that delimit a subsequence of bytes that have been read but not yet converted. When valid, _M_ext_next corresponds to egptr(). The "read it but haven't processed it yet" vibe, lowkey relatable ๐Ÿ˜ญ

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

ios_base::openmode std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::_M_mode

[protected], [inherited] โ€” place to stash in || out || in | out settings for the current filebuf. It's giving "notes app screenshot of my personality" ๐Ÿซถ

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

char_type std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::_M_pback

[protected], [inherited] โ€” necessary bits for putback buffer management ๐ŸŽ€

Note: pbacks of over one character are not currently supported. One (1) character of putback and that's the whole menu, bestie ๐Ÿ˜ญ

char_type* std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::_M_pback_cur_save

[protected], [inherited] โ€” necessary bits for putback buffer management ๐Ÿงš

Note: pbacks of over one character are not currently supported. Same deal, don't push it ๐Ÿ’€

char_type* std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::_M_pback_end_save

[protected], [inherited] โ€” necessary bits for putback buffer management ๐Ÿฆ‹

Note: pbacks of over one character are not currently supported. The trio said the same thing three times and honestly? Consistency queen โœจ

bool std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::_M_pback_init

[protected], [inherited] โ€” necessary bits for putback buffer management ๐Ÿ“

Note: pbacks of over one character are not currently supported. Fourth time's the charm ๐Ÿ’…

bool std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::_M_reading

[protected], [inherited] โ€” the state machine, and it's detailed:

  • _M_reading == false && _M_writing == false for uncommitted mode
  • _M_reading == true for read mode
  • _M_writing == true for write mode

NB: _M_reading == true && _M_writing == true is unused. So like, don't even try it, that combo is not a thing ๐Ÿ‘‘๐Ÿ™ˆ


๐Ÿ‘‘ Author

Generated automatically by Doxygen for libstdc++ from the source code. No human author to thank โ€” the robots did this one, and honestly? They ate ๐Ÿค–๐Ÿ’–


And that's the whole page, bestie โ€” you made it to the very end ๐ŸŽ‰ This was the libstdc++ manual for __gnu_cxx::enc_filebuf< _CharT >, page (3cxx), and the footer carries the source/version info plus the date it was rendered. Go forth and buffer your encodings with main character energy ๐ŸŒˆ๐Ÿ’…

๐Ÿ“ฆ where this page comes from