std::stringbuf (3) - Linux Manuals
std::stringbuf: std::basic_stringbuf
NAME
std::basic_stringbuf - std::basic_stringbuf
Synopsis
Defined in header <sstream>
template<
class CharT,
class Traits = std::char_traits<CharT>,
class Allocator = std::allocator<CharT>
> class basic_stringbuf : public std::basic_streambuf<CharT, Traits>
std::basic_stringbuf is a std::basic_streambuf whose associated character sequence is a memory-resident sequence of arbitrary characters, which can be initialized from or made available as an instance of std::basic_string.
Typical implementations of std::basic_stringbuf hold an object of type std::basic_string or equivalent resizeable sequence container directly as a data member and use it as both the controlled character sequence (the array where the six pointers of std::basic_streambuf are pointing to) and as the associated character sequence (the source of characters for all input operations and the target for the output).
In addition, a typical implementation holds a data member of type std::ios_base::openmode to indicate the status of the stream (input-only, output-only, input/output, at-end, etc).
if over-allocation strategy is used by overflow(), an additional high-watermark pointer may be stored to track the last initialized character (since C++11)
Two specializations for common character types are also defined:
Defined in header <sstream>
Type Definition
stringbuf basic_stringbuf<char>
wstringbuf basic_stringbuf<wchar_t>
Member types
Member type Definition
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
allocator_type Allocator (since C++11)
Member functions
Public member functions
constructor (public member function)
operator= assigns a basic_stringbuf object
(C++11)
swap swaps two basic_stringbuf objects
(C++11)
destructor destructs a basic_stringbuf object and the string it holds
[virtual] (implicitly declared)
str (public member function)
Protected member functions
underflow returns the next character available in the input sequence
[virtual]
pbackfail puts a character back into the input sequence
[virtual]
overflow appends a character to the output sequence