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 >:

Inheritance graph
[legend]
Collaboration diagram for std::basic_stringbuf< _CharT, _Traits, _Alloc >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef _CharT char_type
typedef _Traits traits_type
typedef traits_type::int_type int_type
typedef traits_type::pos_type pos_type
typedef traits_type::off_type off_type

Public Methods

 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 Methods

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_type * setbuf (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.


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


Member Typedef Documentation

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 66 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::int_type std::basic_stringbuf< _CharT, _Traits, _Alloc >::int_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 72 of file sstream.

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

template<typename _CharT, typename _Traits, typename _Alloc>
typedef traits_type::off_type std::basic_stringbuf< _CharT, _Traits, _Alloc >::off_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 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
 

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

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.


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

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


Member Function Documentation

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

References std::basic_stringbuf< _CharT, _Traits, _Alloc >::int_type , std::max() , std::basic_streambuf< _CharT, _Traits >::sputc() , and std::basic_stringbuf< _CharT, _Traits, _Alloc >::str() .

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_stringbuf< _CharT, _Traits, _Alloc >::int_type .

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

References std::basic_stringbuf< _CharT, _Traits, _Alloc >::char_type , std::basic_streambuf< _CharT, _Traits >::egptr() , std::basic_streambuf< _CharT, _Traits >::epptr() , std::basic_streambuf< _CharT, _Traits >::gptr() , std::basic_stringbuf< _CharT, _Traits, _Alloc >::off_type , std::basic_stringbuf< _CharT, _Traits, _Alloc >::pos_type , and std::basic_streambuf< _CharT, _Traits >::pptr() .

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

References std::basic_stringbuf< _CharT, _Traits, _Alloc >::char_type , std::basic_streambuf< _CharT, _Traits >::eback() , std::basic_streambuf< _CharT, _Traits >::egptr() , std::basic_stringbuf< _CharT, _Traits, _Alloc >::off_type , std::basic_streambuf< _CharT, _Traits >::pbase() , 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 229 of file sstream.

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

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

References std::max() .

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

template<typename _CharT, typename _Traits, typename _Alloc>
virtual int_type std::basic_stringbuf< _CharT, _Traits, _Alloc >::underflow   [inline, 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 201 of file sstream.


The documentation for this class was generated from the following files:
Generated on Thu Nov 21 03:13:24 2002 for libstdc++-v3 Source by doxygen1.2.18-20021030