libstdc++
std::basic_stringstream< _CharT, _Traits, _Alloc > Class Template Reference

Public Types

typedef basic_iostream< char_type, traits_type > __iostream_type
 
typedef basic_string< _CharT, _Traits, _Alloc > __string_type
 
typedef basic_stringbuf< _CharT, _Traits, _Alloc > __stringbuf_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_stringstream ()
 
 basic_stringstream (basic_stringstream &&__rhs)
 
 basic_stringstream (const __string_type &__str, ios_base::openmode __m=ios_base::out|ios_base::in)
 
 basic_stringstream (const basic_stringstream &)=delete
 
 basic_stringstream (ios_base::openmode __m)
 
 ~basic_stringstream ()
 
basic_stringstreamoperator= (basic_stringstream &&__rhs)
 
basic_stringstreamoperator= (const basic_stringstream &)=delete
 
__stringbuf_type * rdbuf () const
 
__string_type str () const
 
void str (const __string_type &__s)
 
void swap (basic_stringstream &__rhs)
 

Detailed Description

template<typename _CharT, typename _Traits, typename _Alloc>
class std::basic_stringstream< _CharT, _Traits, _Alloc >

Controlling input and output for std::string.

Template Parameters
_CharTType of character stream.
_TraitsTraits for character type, defaults to char_traits<_CharT>.
_AllocAllocator type, defaults to allocator<_CharT>.

This class supports reading from and writing to objects of type std::basic_string, using the inherited functions from std::basic_iostream. To control the associated sequence, an instance of std::basic_stringbuf is used, which this page refers to as sb.

Definition at line 108 of file iosfwd.

Constructor & Destructor Documentation

◆ basic_stringstream() [1/3]

template<typename _CharT , typename _Traits , typename _Alloc >
std::basic_stringstream< _CharT, _Traits, _Alloc >::basic_stringstream ( )
inline

Default constructor starts with an empty string buffer.

Initializes sb using the mode in|out, and passes &sb to the base class initializer. Does not allocate any buffer.

That's a lie. We initialize the base class with NULL, because the string class does its own memory management.

Definition at line 741 of file sstream.

◆ basic_stringstream() [2/3]

template<typename _CharT , typename _Traits , typename _Alloc >
std::basic_stringstream< _CharT, _Traits, _Alloc >::basic_stringstream ( ios_base::openmode  __m)
inlineexplicit

Starts with an empty string buffer.

Parameters
__mWhether the buffer can read, or write, or both.

Initializes sb using the mode from __m, and passes &sb to the base class initializer. Does not allocate any buffer.

That's a lie. We initialize the base class with NULL, because the string class does its own memory management.

Definition at line 756 of file sstream.

◆ basic_stringstream() [3/3]

template<typename _CharT , typename _Traits , typename _Alloc >
std::basic_stringstream< _CharT, _Traits, _Alloc >::basic_stringstream ( const __string_type __str,
ios_base::openmode  __m = ios_base::out | ios_base::in 
)
inlineexplicit

Starts with an existing string buffer.

Parameters
__strA string to copy as a starting buffer.
__mWhether the buffer can read, or write, or both.

Initializes sb using __str and __m, and passes &sb to the base class initializer.

That's a lie. We initialize the base class with NULL, because the string class does its own memory management.

Definition at line 772 of file sstream.

◆ ~basic_stringstream()

template<typename _CharT , typename _Traits , typename _Alloc >
std::basic_stringstream< _CharT, _Traits, _Alloc >::~basic_stringstream ( )
inline

The destructor does nothing.

The buffer is deallocated by the stringbuf object, not the formatting stream.

Definition at line 783 of file sstream.

Member Function Documentation

◆ rdbuf()

template<typename _CharT , typename _Traits , typename _Alloc >
__stringbuf_type* std::basic_stringstream< _CharT, _Traits, _Alloc >::rdbuf ( ) const
inline

Accessing the underlying buffer.

Returns
The current basic_stringbuf buffer.

This hides both signatures of std::basic_ios::rdbuf().

Definition at line 823 of file sstream.

◆ str() [1/2]

template<typename _CharT , typename _Traits , typename _Alloc >
__string_type std::basic_stringstream< _CharT, _Traits, _Alloc >::str ( ) const
inline

Copying out the string buffer.

Returns
rdbuf()->str()

Definition at line 831 of file sstream.

◆ str() [2/2]

template<typename _CharT , typename _Traits , typename _Alloc >
void std::basic_stringstream< _CharT, _Traits, _Alloc >::str ( const __string_type __s)
inline

Setting a new buffer.

Parameters
__sThe string to use as a new sequence.

Calls rdbuf()->str(s).

Definition at line 841 of file sstream.


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