std::basic_stringbuf< _CharT, _Traits, _Alloc > Class Template Reference
I/O

## Public Types

typedef __string_type::size_type | __size_type
typedef basic_streambuf< char_type, traits_type > | __streambuf_type
typedef basic_string< char_type, _Traits, _Alloc > | __string_type
typedef _Alloc | allocator_type
typedef _CharT | char_type
typedef traits_type::int_type | int_type
typedef traits_type::off_type | off_type
typedef traits_type::pos_type | pos_type
typedef _Traits | traits_type

## Public Member Functions

| basic_stringbuf (basic_stringbuf &&__rhs)
| basic_stringbuf (const __string_type &__str, ios_base::openmode __mode=ios_base::in|ios_base::out)
| basic_stringbuf (const basic_stringbuf &)=delete
| basic_stringbuf (ios_base::openmode __mode=ios_base::in|ios_base::out)
basic_stringbuf & | operator= (basic_stringbuf &&__rhs)
basic_stringbuf & | operator= (const basic_stringbuf &)=delete
__string_type | str () const
void | str (const __string_type &__s)
void | swap (basic_stringbuf &__rhs)

## Protected Member Functions

void | _M_pbump (char_type *__pbeg, char_type *__pend, off_type __off)
void | _M_stringbuf_init (ios_base::openmode __mode)
void | _M_sync (char_type *__base, __size_type __i, __size_type __o)
void | _M_update_egptr ()
virtual int_type | overflow (int_type __c=traits_type::eof())
virtual int_type | pbackfail (int_type __c=traits_type::eof())
virtual pos_type | seekoff (off_type __off, ios_base::seekdir __way, ios_base::openmode __mode=ios_base::in|ios_base::out)
virtual pos_type | seekpos (pos_type __sp, ios_base::openmode __mode=ios_base::in|ios_base::out)
virtual __streambuf_type * | setbuf (char_type *__s, streamsize __n)
virtual streamsize | showmanyc ()
virtual int_type | underflow ()

## Protected Attributes

ios_base::openmode | _M_mode
__string_type | _M_string

## Detailed Description

### template<typename _CharT, typename _Traits, typename _Alloc>
class std::basic_stringbuf< _CharT, _Traits, _Alloc >

The actual work of input and output (for std::string).

Template Parameters

  _CharT | Type of character stream.
  _Traits | Traits for character type, defaults to char_traits<_CharT>.
  _Alloc | Allocator type, defaults to allocator<_CharT>.

This class associates either or both of its input and output sequences with a sequence of characters, which can be initialized from, or made available as, a `std::basic_string`. (Paraphrased from [27.7.1]/1.)

For this class, open modes (of type `ios_base::openmode`) have `in` set if the input sequence can be read, and `out` set if the output sequence can be written.

Definition at line 96 of file iosfwd.

## Constructor & Destructor Documentation

## basic_stringbuf() [1/2]

template<typename _CharT , typename _Traits , typename _Alloc >

std::basic_stringbuf< _CharT, _Traits, _Alloc >::basic_stringbuf | ( | ios_base::openmode | __mode = `ios_base::in | ios_base::out` | ) |

inline explicit

Starts with an empty string buffer.

Parameters

  __mode | Whether the buffer can read, or write, or both.

The default constructor initializes the parent class using its own default ctor.

Definition at line 100 of file sstream.

## basic_stringbuf() [2/2]

template<typename _CharT , typename _Traits , typename _Alloc >

std::basic_stringbuf< _CharT, _Traits, _Alloc >::basic_stringbuf | ( | const __string_type & | __str,
|  | ios_base::openmode | __mode = `ios_base::in | ios_base::out`
| ) |  |

inline explicit

Starts with an existing string buffer.

Parameters

  __str | A string to copy as a starting buffer.
  __mode | Whether the buffer can read, or write, or both.

This constructor initializes the parent class using its own default ctor.

Definition at line 113 of file sstream.

## Member Function Documentation

## setbuf()

template<typename _CharT , typename _Traits , typename _Alloc >

virtual __streambuf_type* std::basic_stringbuf< _CharT, _Traits, _Alloc >::setbuf | ( | char_type * | __s,
|  | streamsize | __n
| ) |  |

inline protected virtual

Manipulates the buffer.

Parameters

  __s | Pointer to a buffer area.
  __n | Size of __s.

Returns
  `this`

If no buffer has already been created, and both __s and __n are non-zero, then `__s` is used as a buffer; see https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html#io.streambuf.buffering for more.

Definition at line 244 of file sstream.

## str() [1/2]

template<typename _CharT , typename _Traits , typename _Alloc >

__string_type std::basic_stringbuf< _CharT, _Traits, _Alloc >::str | ( |  | ) | const

inline

Copying out the string buffer.

Returns
  A copy of one of the underlying sequences.

If the buffer is only created in input mode, the underlying character sequence is equal to the input sequence; otherwise, it is equal to the output sequence. [27.7.1.2]/1

Definition at line 167 of file sstream.

## str() [2/2]

template<typename _CharT , typename _Traits , typename _Alloc >

void std::basic_stringbuf< _CharT, _Traits, _Alloc >::str | ( | const __string_type & | __s | ) |

inline

Setting a new buffer.

Parameters

  __s | The string to use as a new sequence.

Deallocates any previous stored sequence, then copies s to use as a new one.

Definition at line 191 of file sstream.

## Member Data Documentation

## _M_mode

template<typename _CharT , typename _Traits , typename _Alloc >

ios_base::openmode std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_mode

protected

Place to stash in || out || in | out settings for current stringbuf.

Definition at line 85 of file sstream.

The documentation for this class was generated from the following files:

- iosfwd
- sstream
- sstream.tcc