std::strstreambuf(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– std::strstreambuf πŸ’–

okay bestie, welcome to the std::strstreambuf(3) page from the C++ Standard Library manual 🫢 this one is giving β€œvintage C++ buffer energy”: deprecated, removed, and still fully iconic in a chaotic way 😭✨


🌸 NAME 🌸

std::strstreambuf β€” std::strstreambuf


✨ Synopsis ✨

Defined in header <strstream>:

class strstreambuf : public std::basic_streambuf<char>
deprecated in C++98 😬 removed in C++26 πŸ’€

std::strstreambuf is a std::basic_streambuf whose associated character sequence is a character array. that array can be:

  • constant, like a string literal πŸ‘‘
  • modifiable but not dynamic, like a stack-allocated array 🧚
  • dynamic, in which case the std::strstreambuf may be allowed to reallocate the array as necessary to accommodate output, e.g. by calling delete[] and new[] or user-provided functions πŸ”₯

typical implementation of a std::strstreambuf holds four private data members:

  1. buffer state, a bitmask type which can represent any combination of the four values "allocated" (destructor will deallocate), "constant" (output not allowed), "dynamic" (output may reallocate), or "frozen" (deallocation and reallocation are not allowed) 🧊
  2. allocated buffer size (the beginning of the buffer does not need a special data member, it may be stored in the inherited pointer eback()) πŸ“
  3. pointer to user-provided allocation function πŸ› οΈ
  4. pointer to user-provided deallocation function 🧹

πŸ’… Notes πŸ’…

after any call to str() on a stream with a dynamic buffer, a call to freeze(false) is required to allow the strstreambuf destructor to deallocate the buffer when necessary 😭 this is the β€œdo not forget or the vibe check fails” part.

strstreambuf has been deprecated since C++98 and removed since C++26 πŸ’€ the recommended replacement is std::spanbuf (since C++23) ✨


πŸŽ€ Member functions πŸŽ€

Public member functions

  • constructor β€” constructs a strstreambuf object πŸ› οΈ (public member function)
  • destructor [virtual] β€” destructs a strstreambuf object, optionally deallocating the character array 😭 (virtual public member function)
  • freeze β€” sets/clears the frozen state of the buffer 🧊 (public member function)
  • str β€” marks the buffer frozen and returns the beginning pointer of the input sequence 🫢 (public member function)
  • pcount β€” returns the next pointer minus the beginning pointer in the output sequence: the number of characters written πŸ”’ (public member function)

Protected member functions

  • underflow [virtual] β€” reads a character from the input sequence without advancing the next pointer πŸ‘€ (virtual protected member function)
  • pbackfail [virtual] β€” backs out the input sequence to unget a character ↩️ (virtual protected member function)
  • overflow [virtual] β€” appends a character to the output sequence, may reallocate or initially allocate the buffer if dynamic and not frozen πŸ”₯ (virtual protected member function)
  • setbuf [virtual] β€” attempts to replace the controlled character sequence with an array 🧺 (virtual protected member function)
  • seekoff [virtual] β€” repositions the next pointer in the input sequence, output sequence, or both, using relative addressing 🧭 (virtual protected member function)
  • seekpos [virtual] β€” repositions the next pointer in the input sequence, output sequence, or both using absolute addressing 🎯 (virtual protected member function)

πŸ¦‹ Inherited from std::basic_streambuf πŸ¦‹

Member types

  • char_type β€” CharT
  • traits_type β€” Traits; the program is ill-formed if Traits::char_type is not CharT.
  • int_type β€” Traits::int_type
  • pos_type β€” Traits::pos_type
  • off_type β€” Traits::off_type

Member functions

  • destructor [virtual] β€” destructs the basic_streambuf object πŸ’€ (virtual public member function of std::basic_streambuf<CharT,Traits>)

Locales

  • pubimbue β€” invokes imbue() 🌍 (public member function of std::basic_streambuf<CharT,Traits>)
  • getloc β€” obtains a copy of the associated locale πŸ—ΊοΈ (public member function of std::basic_streambuf<CharT,Traits>)

Positioning

  • pubsetbuf β€” invokes setbuf() 🧺 (public member function of std::basic_streambuf<CharT,Traits>)
  • pubseekoff β€” invokes seekoff() 🧭 (public member function of std::basic_streambuf<CharT,Traits>)
  • pubseekpos β€” invokes seekpos() 🎯 (public member function of std::basic_streambuf<CharT,Traits>)
  • pubsync β€” invokes sync() πŸ”„ (public member function of std::basic_streambuf<CharT,Traits>)

Get area

  • in_avail β€” obtains the number of characters immediately available in the get area πŸ‘€ (public member function of std::basic_streambuf<CharT,Traits>)
  • snextc β€” advances the input sequence, then reads one character without advancing again ⏭️ (public member function of std::basic_streambuf<CharT,Traits>)
  • sbumpc β€” reads one character from the input sequence and advances the sequence 🚢 (public member function of std::basic_streambuf<CharT,Traits>)
  • stossc (removed in C++17) β€” reads one character from the input sequence and advances the sequence 😭 (public member function of std::basic_streambuf<CharT,Traits>)
  • sgetc β€” reads one character from the input sequence without advancing the sequence πŸ‘€ (public member function of std::basic_streambuf<CharT,Traits>)
  • sgetn β€” invokes xsgetn() πŸ“₯ (public member function of std::basic_streambuf<CharT,Traits>)

Put area

  • sputc β€” writes one character to the put area and advances the next pointer ✍️ (public member function of std::basic_streambuf<CharT,Traits>)
  • sputn β€” invokes xsputn() πŸ“€ (public member function of std::basic_streambuf<CharT,Traits>)

Putback

  • sputbackc β€” puts one character back in the input sequence ↩️ (public member function of std::basic_streambuf<CharT,Traits>)
  • sungetc β€” moves the next pointer in the input sequence back by one βͺ (public member function of std::basic_streambuf<CharT,Traits>)

Protected member functions

  • constructor β€” constructs a basic_streambuf object πŸ› οΈ (protected member function)
  • operator= (C++11) β€” replaces a basic_streambuf object πŸ” (protected member function)
  • swap (C++11) β€” swaps two basic_streambuf objects πŸ”„ (protected member function)

Locales

  • imbue [virtual] β€” changes the associated locale 🌍 (virtual protected member function of std::basic_streambuf<CharT,Traits>)

Positioning

  • setbuf [virtual] β€” replaces the buffer with user-defined array, if permitted 🧺 (virtual protected member function of std::basic_streambuf<CharT,Traits>)
  • seekoff [virtual] β€” repositions the next pointer in the input sequence, output sequence, or both, using relative addressing 🧭 (virtual protected member function of std::basic_streambuf<CharT,Traits>)
  • seekpos [virtual] β€” repositions the next pointer in the input sequence, output sequence, or both using absolute addressing 🎯 (virtual protected member function of std::basic_streambuf<CharT,Traits>)
  • sync [virtual] β€” synchronizes the buffers with the associated character sequence πŸ”„ (virtual protected member function of std::basic_streambuf<CharT,Traits>)

Get area

  • showmanyc [virtual] β€” obtains the number of characters available for input in the associated input sequence, if known πŸ”’ (virtual protected member function of std::basic_streambuf<CharT,Traits>)
  • underflow [virtual] β€” reads characters from the associated input sequence to the get area πŸ‘€ (virtual protected member function of std::basic_streambuf<CharT,Traits>)
  • uflow [virtual] β€” reads characters from the associated input sequence to the get area and advances the next pointer 🚢 (virtual protected member function of std::basic_streambuf<CharT,Traits>)
  • xsgetn [virtual] β€” reads multiple characters from the input sequence πŸ“₯ (virtual protected member function of std::basic_streambuf<CharT,Traits>)
  • eback, gptr, egptr β€” returns a pointer to the beginning, current character and the end of the get area 🧭 (protected member function)
  • gbump β€” advances the next pointer in the input sequence ⏭️ (protected member function)
  • setg β€” repositions the beginning, next, and end pointers of the input sequence 🎯 (protected member function)

Put area

  • xsputn [virtual] β€” writes multiple characters to the output sequence πŸ“€ (virtual protected member function of std::basic_streambuf<CharT,Traits>)
  • overflow [virtual] β€” writes characters to the associated output sequence from the put area πŸ”₯ (virtual protected member function of std::basic_streambuf<CharT,Traits>)
  • pbase, pptr, epptr β€” returns a pointer to the beginning, current character and the end of the put area 🧭 (protected member function)
  • pbump β€” advances the next pointer of the output sequence ⏭️ (protected member function)
  • setp β€” repositions the beginning, next, and end pointers of the output sequence 🎯 (protected member function)

Putback

  • pbackfail [virtual] β€” puts a character back into the input sequence, possibly modifying the input sequence ↩️ (virtual protected member function of std::basic_streambuf<CharT,Traits>)

mwah πŸ’‹ this page came from http://cppreference.com, dated 2024.06.10, and it’s the std::strstreambuf(3) page β€” bye bestie, go freeze your buffers responsibly πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from