__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 forcodecvt< char_type, char, __state_type >__file_typeโ typedef for__basic_file< char >__filebuf_typeโ typedef forbasic_filebuf< char_type, traits_type >__state_typeโ typedef fortraits_type::state_type__streambuf_typeโ typedef forbasic_streambuf< char_type, traits_type >char_typeโ typedef for_CharTint_typeโ typedef fortraits_type::int_typeoff_typeโ typedef fortraits_type::off_typepos_typeโ typedef fortraits_type::pos_typestate_typeโ typedef fortraits_type::state_typetraits_typeโ typedef forencoding_char_traits< _CharT >
๐ Public Member Functions
enc_filebuf (state_type &__state)โ the constructor, she takes astate_typereference, 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 ()โ Returnstrueif 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 forimbue().int_type sbumpc ()โ Getting the next character.int_type sgetc ()โ Getting the next character.streamsize sgetn (char_type *__s, streamsize __n)โ Entry point forxsgetn.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 virtualsyncfunction.
๐ฆ 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 bufferbool _M_convert_to_external (char_type *, streamsize)โ converts to externalvoid _M_create_pback ()โ creates the pbackvoid _M_destroy_internal_buffer () throw ()โ destroys the internal buffervoid _M_destroy_pback () throw ()โ destroys the pbackint _M_get_ext_pos (__state_type &__state)โ grabs the external positionpos_type _M_seek (off_type __off, ios_base::seekdir __way, __state_type __state)โ does the seekingvoid _M_set_buffer (streamsize __off)โ sets the bufferbool _M_terminate_output ()โ terminates the outputvoid 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 streambufsvirtual 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, frlocale _M_buf_localeโ Current locale setting.size_t _M_buf_sizeโ the size of the bufferconst __codecvt_type * _M_codecvtโ the codecvt pointerchar * _M_ext_bufโ the external bufferstreamsize _M_ext_buf_sizeโ size of the external bufferchar * _M_ext_endโ end of the external bufferconst char * _M_ext_nextโ next spot in the external buffer__file_type _M_fileโ the actual filechar_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 lockios_base::openmode _M_modeโ Place to stashin || out || in | outsettings 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 statebool _M_writingโ are we writing?char_type _M_pbackโ the pback charchar_type * _M_pback_cur_saveโ saved current pback pointerchar_type * _M_pback_end_saveโ saved pback end pointerbool _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()uponunderflow/uflow(read mode);__off == 0uponoverflow(write mode);__off == -1uponopen,setbuf,seekoff/pos(uncommitted mode).
NB:epptr() - pbase() == _M_buf_size - 1, since_M_buf_sizereflects 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 sequencegptr()returns the next pointer for the input sequenceegptr()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 sequencegptr()returns the next pointer for the input sequenceegptr()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 sequencepptr()returns the next pointer for the output sequenceepptr()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 sequencegptr()returns the next pointer for the input sequenceegptr()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 afilesystem::path.__modeโ the open mode flags.
Returns
thison success,NULLon 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
thison success,NULLon 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
thison success,NULLon 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, 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.
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 sequencepptr()returns the next pointer for the output sequenceepptr()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 sequencepptr()returns the next pointer for the output sequenceepptr()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 forios_base::seekdir.__modeโ value forios_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 forios_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 [tounderfloworuflow] will not returneof()but that they will return immediately. The standard also adds โ and I'm not making this up โ that the morphemes ofshowmanycare 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 == falsefor uncommitted mode_M_reading == truefor read mode_M_writing == truefor 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
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms