ostreambuf_iterator class template — Output iterator to write characters to a streambuf
template<typename charT, typename traits=char_traits<charT> > class ostreambuf_iterator : public iterator<output_iterator_tag,void,void,void,void> { public: typedef charT char_type; typedef traits traits_type; typedef basic_streambuf<charT,traits> streambuf_type; typedef basic_ostream<charT,traits> ostream_type; ostreambuf_iterator(ostream_type& s) throw( ); ostreambuf_iterator(streambuf_type* s) throw( ); ostreambuf_iterator& operator=(charT c); ostreambuf_iterator& operator*( ); ostreambuf_iterator& operator++( ); ostreambuf_iterator& operator++(int); bool failed( ) const throw( ); };
The ostreambuf_iterator
class template wraps a basic_streambuf
object as an output
iterator to write characters to the stream buffer. Example 13-21 (under istreambuf_iterator
) shows how to use
streambuf
iterators to copy
files.
In the following descriptions of the member functions of
ostreambuf_iterator
, the data
member sbuf
is a pointer to the
iterator's stream buffer. The sbuf
member
serves only to keep the function descriptions clear and simple; the
class is not required to have such a member, or a member with that
name.
ostreambuf_iterator
(ostream_type& s) throw(
)
, ostreambuf_iterator
(streambuf_type* sb) throw(
)
Saves the stream buffer s.rdbuf( )
or sb
in
sbuf
.
ostreambuf_iterator&
operator=
(charT
c)
Calls sbuf
->sputc(c)
(only if failed( )
returns false
) and returns *this
.
ostreambuf_iterator&
operator*
( )
Returns *this
.
ostreambuf_iterator&
operator++
( )
, ostreambuf_iterator&
operator++
(int)
Returns *this
.
bool
failed
( )
const
throw(
)
Returns true
if
sbuf
->sputc( )
ever returned traits::eof( )
. Otherwise, it
returns false
.
istreambuf_iterator class
template, ostream_iterator
class template, basic_streambuf
in <streambuf>