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

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

Inheritance diagram for std::basic_stringbuf< _CharT, _Traits, _Alloc >:

std::basic_streambuf< _CharT, _Traits > List of all members.

Public Types

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

Public Member Functions

 basic_stringbuf (ios_base::openmode __mode=ios_base::in|ios_base::out)
 Starts with an empty string buffer.

 basic_stringbuf (const __string_type &__str, ios_base::openmode __mode=ios_base::in|ios_base::out)
 Starts with an existing string buffer.

__string_type str () const
 Copying out the string buffer.

void str (const __string_type &__s)
 Setting a new buffer.


Protected Member Functions

void _M_stringbuf_init (ios_base::openmode __mode)
virtual streamsize showmanyc ()
 Investigating the data available.

virtual int_type underflow ()
 Fetches more data from the controlled sequence.

virtual int_type pbackfail (int_type __c=traits_type::eof())
 Tries to back up the input sequence.

virtual int_type overflow (int_type __c=traits_type::eof())
 Consumes data from the buffer; writes to the controlled sequence.

virtual __streambuf_typesetbuf (char_type *__s, streamsize __n)
 Manipulates the buffer.

virtual pos_type seekoff (off_type __off, ios_base::seekdir __way, ios_base::openmode __mode=ios_base::in|ios_base::out)
 Alters the stream positions.

virtual pos_type seekpos (pos_type __sp, ios_base::openmode __mode=ios_base::in|ios_base::out)
 Alters the stream positions.

void _M_sync (char_type *__base, __size_type __i, __size_type __o)
void _M_update_egptr ()

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).

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 63 of file sstream.


Member Typedef Documentation

template<typename _CharT, typename _Traits, typename _Alloc>
typedef __string_type::size_type std::basic_stringbuf< _CharT, _Traits, _Alloc >::__size_type
 

Definition at line 84 of file sstream.

Referenced by std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_stringbuf_init(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_sync(), and std::basic_stringbuf< _CharT, _Traits, _Alloc >::overflow().

template<typename _CharT, typename _Traits, typename _Alloc>
typedef basic_streambuf<char_type, traits_type> std::basic_stringbuf< _CharT, _Traits, _Alloc >::__streambuf_type
 

Reimplemented from std::basic_streambuf< _CharT, _Traits >.

Definition at line 82 of file sstream.

template<typename _CharT, typename _Traits, typename _Alloc>
typedef basic_string<char_type, _Traits, _Alloc> std::basic_stringbuf< _CharT, _Traits, _Alloc >::__string_type
 

Definition at line 83 of file sstream.

Referenced by std::basic_stringbuf< _CharT, _Traits, _Alloc >::setbuf(), and std::basic_stringbuf< _CharT, _Traits, _Alloc >::str().

template<typename _CharT, typename _Traits, typename _Alloc>
typedef _Alloc std::basic_stringbuf< _CharT, _Traits, _Alloc >::allocator_type
 

Definition at line 71 of file sstream.

template<typename _CharT, typename _Traits, typename _Alloc>
typedef _CharT std::basic_stringbuf< _CharT, _Traits, _Alloc >::char_type
 

These are standard types. They permit a standardized way of referring to names of (or names dependant on) the template parameters, which are specific to the implementation.

Reimplemented from std::basic_streambuf< _CharT, _Traits >.

Definition at line 67 of file sstream.

template<typename _CharT, typename _Traits, typename _Alloc>
typedef traits_type::int_type std::basic_stringbuf< _CharT, _Traits, _Alloc >::int_type
 

Reimplemented from std::basic_streambuf< _CharT, _Traits >.

Definition at line 72 of file sstream.

template<typename _CharT, typename _Traits, typename _Alloc>
typedef traits_type::off_type std::basic_stringbuf< _CharT, _Traits, _Alloc >::off_type
 

Reimplemented from std::basic_streambuf< _CharT, _Traits >.

Definition at line 74 of file sstream.

Referenced by std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekoff(), and std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekpos().

template<typename _CharT, typename _Traits, typename _Alloc>
typedef traits_type::pos_type std::basic_stringbuf< _CharT, _Traits, _Alloc >::pos_type
 

Reimplemented from std::basic_streambuf< _CharT, _Traits >.

Definition at line 73 of file sstream.

Referenced by std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekoff(), and std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekpos().

template<typename _CharT, typename _Traits, typename _Alloc>
typedef _Traits std::basic_stringbuf< _CharT, _Traits, _Alloc >::traits_type
 

Reimplemented from std::basic_streambuf< _CharT, _Traits >.

Definition at line 68 of file sstream.


Constructor & Destructor Documentation

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 113 of file sstream.

References std::ios_base::openmode.

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 126 of file sstream.

References std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_stringbuf_init(), and std::ios_base::openmode.


Member Function Documentation

template<typename _CharT, typename _Traits, typename _Alloc>
void std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_stringbuf_init ios_base::openmode  __mode  )  [inline, protected]
 

Definition at line 178 of file sstream.

References std::basic_stringbuf< _CharT, _Traits, _Alloc >::__size_type, std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_sync(), and std::ios_base::openmode.

Referenced by std::basic_stringbuf< _CharT, _Traits, _Alloc >::basic_stringbuf(), and std::basic_stringbuf< _CharT, _Traits, _Alloc >::str().

template<typename _CharT, typename _Traits, typename _Alloc>
void std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_sync char_type __base,
__size_type  __i,
__size_type  __o
[inline, protected]
 

Definition at line 264 of file sstream.

References std::basic_stringbuf< _CharT, _Traits, _Alloc >::__size_type, std::basic_streambuf< _CharT, _Traits >::pbump(), std::basic_streambuf< _CharT, _Traits >::setg(), and std::basic_streambuf< _CharT, _Traits >::setp().

Referenced by std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_stringbuf_init(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::overflow(), and std::basic_stringbuf< _CharT, _Traits, _Alloc >::setbuf().

template<typename _CharT, typename _Traits, typename _Alloc>
void std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_update_egptr  )  [inline, protected]
 

Definition at line 288 of file sstream.

References std::basic_streambuf< _CharT, _Traits >::egptr(), std::basic_streambuf< _CharT, _Traits >::gptr(), std::basic_streambuf< _CharT, _Traits >::pptr(), and std::basic_streambuf< _CharT, _Traits >::setg().

Referenced by std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekoff(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekpos(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::showmanyc(), and std::basic_stringbuf< _CharT, _Traits, _Alloc >::underflow().

template<class _CharT, class _Traits, class _Alloc>
basic_stringbuf< _CharT, _Traits, _Alloc >::int_type std::basic_stringbuf< _CharT, _Traits, _Alloc >::overflow int_type  __c = traits_type::eof()  )  [protected, virtual]
 

Consumes data from the buffer; writes to the controlled sequence.

Parameters:
c An additional character to consume.
Returns:
eof() to indicate failure, something else (usually c, or not_eof())
Informally, this function is called when the output buffer is full (or does not exist, as buffering need not actually be done). If a buffer exists, it is "consumed", with "some effect" on the controlled sequence. (Typically, the buffer is written out to the sequence verbatim.) In either case, the character c is also written out, if c is not eof().

For a formal definiton of this function, see a good text such as Langer & Kreft, or [27.5.2.4.5]/3-7.

A functioning output streambuf can be created by overriding only this function (no buffer area will be used).

Note:
Base class version does nothing, returns eof().

Reimplemented from std::basic_streambuf< _CharT, _Traits >.

Definition at line 76 of file sstream.tcc.

References std::basic_stringbuf< _CharT, _Traits, _Alloc >::__size_type, std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_sync(), std::basic_streambuf< _CharT, _Traits >::eback(), std::basic_streambuf< _CharT, _Traits >::epptr(), std::basic_streambuf< _CharT, _Traits >::gptr(), std::max(), std::min(), std::basic_streambuf< _CharT, _Traits >::pbase(), std::basic_streambuf< _CharT, _Traits >::pptr(), and std::basic_streambuf< _CharT, _Traits >::sputc().

template<class _CharT, class _Traits, class _Alloc>
basic_stringbuf< _CharT, _Traits, _Alloc >::int_type std::basic_stringbuf< _CharT, _Traits, _Alloc >::pbackfail int_type  __c = traits_type::eof()  )  [protected, virtual]
 

Tries to back up the input sequence.

Parameters:
c The character to be inserted back into the sequence.
Returns:
eof() on failure, "some other value" on success
Postcondition:
The constraints of gptr(), eback(), and pptr() are the same as for underflow().
Note:
Base class version does nothing, returns eof().

Reimplemented from std::basic_streambuf< _CharT, _Traits >.

Definition at line 47 of file sstream.tcc.

References std::basic_streambuf< _CharT, _Traits >::eback(), std::basic_streambuf< _CharT, _Traits >::gbump(), and std::basic_streambuf< _CharT, _Traits >::gptr().

template<class _CharT, class _Traits, class _Alloc>
basic_stringbuf< _CharT, _Traits, _Alloc >::pos_type std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekoff off_type  __off,
ios_base::seekdir  __way,
ios_base::openmode  __mode = ios_base::in | ios_base::out
[protected, virtual]
 

Alters the stream positions.

Each derived class provides its own appropriate behavior.

Note:
Base class version does nothing, returns a pos_type that represents an invalid stream position.

Reimplemented from std::basic_streambuf< _CharT, _Traits >.

Definition at line 136 of file sstream.tcc.

References std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_update_egptr(), std::basic_streambuf< _CharT, _Traits >::eback(), std::basic_streambuf< _CharT, _Traits >::egptr(), std::basic_streambuf< _CharT, _Traits >::gbump(), std::basic_streambuf< _CharT, _Traits >::gptr(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::off_type, std::ios_base::openmode, std::basic_streambuf< _CharT, _Traits >::pbase(), std::basic_streambuf< _CharT, _Traits >::pbump(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::pos_type, std::basic_streambuf< _CharT, _Traits >::pptr(), and std::ios_base::seekdir.

template<class _CharT, class _Traits, class _Alloc>
basic_stringbuf< _CharT, _Traits, _Alloc >::pos_type std::basic_stringbuf< _CharT, _Traits, _Alloc >::seekpos pos_type  __sp,
ios_base::openmode  __mode = ios_base::in | ios_base::out
[protected, virtual]
 

Alters the stream positions.

Each derived class provides its own appropriate behavior.

Note:
Base class version does nothing, returns a pos_type that represents an invalid stream position.

Reimplemented from std::basic_streambuf< _CharT, _Traits >.

Definition at line 183 of file sstream.tcc.

References std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_update_egptr(), std::basic_streambuf< _CharT, _Traits >::eback(), std::basic_streambuf< _CharT, _Traits >::egptr(), std::basic_streambuf< _CharT, _Traits >::gbump(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::off_type, std::ios_base::openmode, std::basic_streambuf< _CharT, _Traits >::pbase(), std::basic_streambuf< _CharT, _Traits >::pbump(), and std::basic_stringbuf< _CharT, _Traits, _Alloc >::pos_type.

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 http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#2 for more.

Reimplemented from std::basic_streambuf< _CharT, _Traits >.

Definition at line 224 of file sstream.

References std::basic_stringbuf< _CharT, _Traits, _Alloc >::__string_type, std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_sync(), and std::streamsize.

template<typename _CharT, typename _Traits, typename _Alloc>
virtual streamsize std::basic_stringbuf< _CharT, _Traits, _Alloc >::showmanyc  )  [inline, protected, virtual]
 

Investigating the data available.

Returns:
An estimate of the number of characters available in the input sequence, or -1.
"If it returns a positive value, then successive calls to underflow() will not return traits::eof() until at least that number of characters have been supplied. If showmanyc() returns -1, then calls to underflow() or uflow() will fail." [27.5.2.4.3]/1

Note:
Base class version does nothing, returns zero.

The standard adds that "the intention is not only that the calls [to underflow or uflow] will not return eof() but that they will return "immediately".

The standard adds that "the morphemes of showmanyc are "es-how-many-see", not "show-manic".

Reimplemented from std::basic_streambuf< _CharT, _Traits >.

Definition at line 189 of file sstream.

References std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_update_egptr(), std::basic_streambuf< _CharT, _Traits >::egptr(), std::basic_streambuf< _CharT, _Traits >::gptr(), and std::streamsize.

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 163 of file sstream.

References std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_stringbuf_init().

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 141 of file sstream.

References std::basic_stringbuf< _CharT, _Traits, _Alloc >::__string_type, std::basic_streambuf< _CharT, _Traits >::egptr(), and std::basic_streambuf< _CharT, _Traits >::pptr().

Referenced by std::basic_istringstream< _CharT, _Traits, _Alloc >::str().

template<class _CharT, class _Traits, class _Alloc>
basic_stringbuf< _CharT, _Traits, _Alloc >::int_type std::basic_stringbuf< _CharT, _Traits, _Alloc >::underflow  )  [protected, virtual]
 

Fetches more data from the controlled sequence.

Returns:
The first character from the pending sequence.
Informally, this function is called when the input buffer is exhausted (or does not exist, as buffering need not actually be done). If a buffer exists, it is "refilled". In either case, the next available character is returned, or traits::eof() to indicate a null pending sequence.

For a formal definiton of the pending sequence, see a good text such as Langer & Kreft, or [27.5.2.4.3]/7-14.

A functioning input streambuf can be created by overriding only this function (no buffer area will be used). For an example, see http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#6

Note:
Base class version does nothing, returns eof().

Reimplemented from std::basic_streambuf< _CharT, _Traits >.

Definition at line 118 of file sstream.tcc.

References std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_update_egptr(), std::basic_streambuf< _CharT, _Traits >::egptr(), and std::basic_streambuf< _CharT, _Traits >::gptr().


Member Data Documentation

template<typename _CharT, typename _Traits, typename _Alloc>
ios_base::openmode std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_mode [protected]
 

Definition at line 93 of file sstream.

template<typename _CharT, typename _Traits, typename _Alloc>
__string_type std::basic_stringbuf< _CharT, _Traits, _Alloc >::_M_string [protected]
 

Definition at line 101 of file sstream.


The documentation for this class was generated from the following files:
Generated on Tue Jan 30 17:32:18 2007 for GNU C++ STL by doxygen 1.3.6