Namespaces
Variants
Actions

std::strstreambuf

From cppreference.com
< cpp‎ | io
 
 
 
 
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, which may be constant (e.g. a string literal), modifiable but not dynamic (e.g. a stack-allocated array), or 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.

Contents

[edit] 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.

strstreambuf has been deprecated since C++98 and removed since C++26. The recommended replacement is std::spanbuf(since C++23).

[edit] Member functions

Public member functions

constructs a strstreambuf object
(public member function) [edit]
[virtual]
destructs a strstreambuf object, optionally deallocating the character array
(virtual public member function) [edit]
sets/clears the frozen state of the buffer
(public member function) [edit]
marks the buffer frozen and returns the beginning pointer of the input sequence
(public member function) [edit]
returns the next pointer minus the beginning pointer in the output sequence: the number of characters written
(public member function) [edit]

Protected member functions

[virtual]
reads a character from the input sequence without advancing the next pointer
(virtual protected member function) [edit]
[virtual]
backs out the input sequence to unget a character
(virtual protected member function) [edit]
[virtual]
appends a character to the output sequence, may reallocate or initially allocate the buffer if dynamic and not frozen
(virtual protected member function) [edit]
[virtual]
attempts to replace the controlled character sequence with an array
(virtual protected member function) [edit]
[virtual]
repositions the next pointer in the input sequence, output sequence, or both, using relative addressing
(virtual protected member function)