std::basic_ostream< _CharT, _Traits > Class Template Reference

Controlling output. More...

Inheritance diagram for std::basic_ostream< _CharT, _Traits >:

std::basic_ios< _CharT, _Traits > std::ios_base std::basic_iostream< _CharT, _Traits > std::basic_ofstream< _CharT, _Traits > std::basic_ostringstream< _CharT, _Traits, _Alloc > std::basic_fstream< _CharT, _Traits > std::basic_stringstream< _CharT, _Traits, _Alloc > List of all members.

Public Types

typedef _CharT char_type
typedef _Traits::int_type int_type
typedef _Traits::pos_type pos_type
typedef _Traits::off_type off_type
typedef _Traits traits_type
typedef basic_streambuf< _CharT,
_Traits > 
__streambuf_type
typedef basic_ios< _CharT,
_Traits > 
__ios_type
typedef basic_ostream< _CharT,
_Traits > 
__ostream_type
typedef num_put< _CharT, ostreambuf_iterator<
_CharT, _Traits > > 
__num_put_type
typedef ctype< _CharT > __ctype_type

Public Member Functions

 basic_ostream (__streambuf_type *__sb)
 Base constructor.

virtual ~basic_ostream ()
 Base destructor.

__ostream_typeflush ()
 Synchronizing the stream buffer.

pos_type tellp ()
 Getting the current write position.

__ostream_typeseekp (pos_type)
 Changing the current write position.

__ostream_typeseekp (off_type, ios_base::seekdir)
 Changing the current write position.

__ostream_typeoperator<< (__ostream_type &(*__pf)(__ostream_type &))
 Interface for manipulators.

__ostream_typeoperator<< (__ios_type &(*__pf)(__ios_type &))
__ostream_typeoperator<< (ios_base &(*__pf)(ios_base &))
Arithmetic Inserters
All the operator<< functions (aka formatted output functions) have some common behavior. Each starts by constructing a temporary object of type std::basic_ostream::sentry. This can have several effects, concluding with the setting of a status flag; see the sentry documentation for more.

If the sentry status is good, the function tries to generate whatever data is appropriate for the type of the argument.

If an exception is thrown during insertion, ios_base::badbit will be turned on in the stream's error state without causing an ios_base::failure to be thrown. The original exception will then be rethrown.

__ostream_typeoperator<< (long __n)
 Basic arithmetic inserters.

__ostream_typeoperator<< (unsigned long __n)
__ostream_typeoperator<< (bool __n)
__ostream_typeoperator<< (short __n)
__ostream_typeoperator<< (unsigned short __n)
__ostream_typeoperator<< (int __n)
__ostream_typeoperator<< (unsigned int __n)
__ostream_typeoperator<< (double __f)
__ostream_typeoperator<< (float __f)
__ostream_typeoperator<< (long double __f)
__ostream_typeoperator<< (const void *__p)
__ostream_typeoperator<< (__streambuf_type *__sb)
 Extracting from another streambuf.

Unformatted Output Functions
All the unformatted output functions have some common behavior. Each starts by constructing a temporary object of type std::basic_ostream::sentry. This has several effects, concluding with the setting of a status flag; see the sentry documentation for more.

If the sentry status is good, the function tries to generate whatever data is appropriate for the type of the argument.

If an exception is thrown during insertion, ios_base::badbit will be turned on in the stream's error state. If badbit is on in the stream's exceptions mask, the exception will be rethrown without completing its actions.

__ostream_typeput (char_type __c)
 Simple insertion.

void _M_write (const char_type *__s, streamsize __n)
__ostream_typewrite (const char_type *__s, streamsize __n)
 Character string insertion.


Protected Member Functions

 basic_ostream ()

Friends

class sentry
template<typename _CharT2, typename _Traits2> basic_ostream< _CharT2, _Traits2 > & operator<< (basic_ostream< _CharT2, _Traits2 > &, _CharT2)
template<typename _Traits2> basic_ostream< char, _Traits2 > & operator<< (basic_ostream< char, _Traits2 > &, char)
template<typename _CharT2, typename _Traits2> basic_ostream< _CharT2, _Traits2 > & operator<< (basic_ostream< _CharT2, _Traits2 > &, const _CharT2 *)
template<typename _Traits2> basic_ostream< char, _Traits2 > & operator<< (basic_ostream< char, _Traits2 > &, const char *)
template<typename _CharT2, typename _Traits2> basic_ostream< _CharT2, _Traits2 > & operator<< (basic_ostream< _CharT2, _Traits2 > &, const char *)

Detailed Description

template<typename _CharT, typename _Traits>
class std::basic_ostream< _CharT, _Traits >

Controlling output.

This is the base class for all output streams. It provides text formatting of all builtin types, and communicates with any class derived from basic_streambuf to do the actual output.

Definition at line 58 of file ostream.


Member Typedef Documentation

template<typename _CharT, typename _Traits>
typedef ctype<_CharT> std::basic_ostream< _CharT, _Traits >::__ctype_type
 

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

Definition at line 74 of file ostream.

template<typename _CharT, typename _Traits>
typedef basic_ios<_CharT, _Traits> std::basic_ostream< _CharT, _Traits >::__ios_type
 

Reimplemented in std::basic_fstream< _CharT, _Traits >.

Definition at line 70 of file ostream.

template<typename _CharT, typename _Traits>
typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> > std::basic_ostream< _CharT, _Traits >::__num_put_type
 

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

Definition at line 73 of file ostream.

template<typename _CharT, typename _Traits>
typedef basic_ostream<_CharT, _Traits> std::basic_ostream< _CharT, _Traits >::__ostream_type
 

Reimplemented in std::basic_ofstream< _CharT, _Traits >, std::basic_iostream< _CharT, _Traits >, std::basic_ostringstream< _CharT, _Traits, _Alloc >, and std::basic_iostream< char >.

Definition at line 71 of file ostream.

template<typename _CharT, typename _Traits>
typedef basic_streambuf<_CharT, _Traits> std::basic_ostream< _CharT, _Traits >::__streambuf_type
 

Definition at line 69 of file ostream.

template<typename _CharT, typename _Traits>
typedef _CharT std::basic_ostream< _CharT, _Traits >::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_ios< _CharT, _Traits >.

Reimplemented in std::strstream, std::basic_ofstream< _CharT, _Traits >, std::basic_fstream< _CharT, _Traits >, std::basic_iostream< _CharT, _Traits >, std::basic_ostringstream< _CharT, _Traits, _Alloc >, std::basic_stringstream< _CharT, _Traits, _Alloc >, and std::basic_iostream< char >.

Definition at line 62 of file ostream.

template<typename _CharT, typename _Traits>
typedef _Traits::int_type std::basic_ostream< _CharT, _Traits >::int_type
 

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

Reimplemented in std::strstream, std::basic_ofstream< _CharT, _Traits >, std::basic_fstream< _CharT, _Traits >, std::basic_iostream< _CharT, _Traits >, std::basic_ostringstream< _CharT, _Traits, _Alloc >, std::basic_stringstream< _CharT, _Traits, _Alloc >, and std::basic_iostream< char >.

Definition at line 63 of file ostream.

template<typename _CharT, typename _Traits>
typedef _Traits::off_type std::basic_ostream< _CharT, _Traits >::off_type
 

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

Reimplemented in std::strstream, std::basic_ofstream< _CharT, _Traits >, std::basic_fstream< _CharT, _Traits >, std::basic_iostream< _CharT, _Traits >, std::basic_ostringstream< _CharT, _Traits, _Alloc >, std::basic_stringstream< _CharT, _Traits, _Alloc >, and std::basic_iostream< char >.

Definition at line 65 of file ostream.

Referenced by std::basic_ostream< _CharT, _Traits >::seekp().

template<typename _CharT, typename _Traits>
typedef _Traits::pos_type std::basic_ostream< _CharT, _Traits >::pos_type
 

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

Reimplemented in std::strstream, std::basic_ofstream< _CharT, _Traits >, std::basic_fstream< _CharT, _Traits >, std::basic_iostream< _CharT, _Traits >, std::basic_ostringstream< _CharT, _Traits, _Alloc >, std::basic_stringstream< _CharT, _Traits, _Alloc >, and std::basic_iostream< char >.

Definition at line 64 of file ostream.

Referenced by std::basic_ostream< _CharT, _Traits >::seekp(), and std::basic_ostream< _CharT, _Traits >::tellp().

template<typename _CharT, typename _Traits>
typedef _Traits std::basic_ostream< _CharT, _Traits >::traits_type
 

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

Reimplemented in std::basic_ofstream< _CharT, _Traits >, std::basic_fstream< _CharT, _Traits >, std::basic_iostream< _CharT, _Traits >, std::basic_ostringstream< _CharT, _Traits, _Alloc >, std::basic_stringstream< _CharT, _Traits, _Alloc >, and std::basic_iostream< char >.

Definition at line 66 of file ostream.


Constructor & Destructor Documentation

template<typename _CharT, typename _Traits>
std::basic_ostream< _CharT, _Traits >::basic_ostream __streambuf_type __sb  )  [inline, explicit]
 

Base constructor.

This ctor is almost never called by the user directly, rather from derived classes' initialization lists, which pass a pointer to their own stream buffer.

Definition at line 105 of file ostream.

template<typename _CharT, typename _Traits>
virtual std::basic_ostream< _CharT, _Traits >::~basic_ostream  )  [inline, virtual]
 

Base destructor.

This does very little apart from providing a virtual base dtor.

Definition at line 114 of file ostream.

template<typename _CharT, typename _Traits>
std::basic_ostream< _CharT, _Traits >::basic_ostream  )  [inline, explicit, protected]
 

Definition at line 361 of file ostream.


Member Function Documentation

template<typename _CharT, typename _Traits>
void std::basic_ostream< _CharT, _Traits >::_M_write const char_type __s,
streamsize  __n
[inline]
 

Definition at line 286 of file ostream.

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::flush  ) 
 

Synchronizing the stream buffer.

Returns:
*this
If rdbuf() is a null pointer, changes nothing.

Otherwise, calls rdbuf()->pubsync(), and if that returns -1, sets badbit.

Definition at line 382 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::_M_setstate(), std::ios_base::iostate, std::basic_ios< _CharT, _Traits >::rdbuf(), and std::basic_ios< _CharT, _Traits >::setstate().

Referenced by std::flush().

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< __streambuf_type __sb  ) 
 

Extracting from another streambuf.

Parameters:
sb A pointer to a streambuf
This function behaves like one of the basic arithmetic extractors, in that it also constructs a sentry object and has the same error handling behavior.

If sb is NULL, the stream will set failbit in its error state.

Characters are extracted from sb and inserted into *this until one of the following occurs:

  • the input stream reaches end-of-file,
  • insertion into the output sequence fails (in this case, the character that would have been inserted is not extracted), or
  • an exception occurs while getting a character from sb, which sets failbit in the error state

If the function inserts no characters, failbit is set.

Definition at line 306 of file ostream.tcc.

References std::__copy_streambufs(), std::basic_ios< _CharT, _Traits >::_M_setstate(), std::ios_base::iostate, and std::basic_ios< _CharT, _Traits >::setstate().

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< const void *  __p  ) 
 

Definition at line 283 of file ostream.tcc.

References std::__check_facet(), std::basic_ios< _CharT, _Traits >::_M_setstate(), std::ios_base::iostate, and std::basic_ios< _CharT, _Traits >::setstate().

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< long double  __f  ) 
 

Definition at line 260 of file ostream.tcc.

References std::__check_facet(), std::basic_ios< _CharT, _Traits >::_M_setstate(), std::ios_base::iostate, and std::basic_ios< _CharT, _Traits >::setstate().

template<typename _CharT, typename _Traits>
__ostream_type& std::basic_ostream< _CharT, _Traits >::operator<< float  __f  )  [inline]
 

Definition at line 218 of file ostream.

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< double  __f  ) 
 

Definition at line 237 of file ostream.tcc.

References std::__check_facet(), std::basic_ios< _CharT, _Traits >::_M_setstate(), std::ios_base::iostate, and std::basic_ios< _CharT, _Traits >::setstate().

template<typename _CharT, typename _Traits>
__ostream_type& std::basic_ostream< _CharT, _Traits >::operator<< unsigned int  __n  )  [inline]
 

Definition at line 203 of file ostream.

template<typename _CharT, typename _Traits>
__ostream_type& std::basic_ostream< _CharT, _Traits >::operator<< int  __n  )  [inline]
 

Definition at line 192 of file ostream.

template<typename _CharT, typename _Traits>
__ostream_type& std::basic_ostream< _CharT, _Traits >::operator<< unsigned short  __n  )  [inline]
 

Definition at line 188 of file ostream.

template<typename _CharT, typename _Traits>
__ostream_type& std::basic_ostream< _CharT, _Traits >::operator<< short  __n  )  [inline]
 

Definition at line 177 of file ostream.

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< bool  __n  ) 
 

Definition at line 97 of file ostream.tcc.

References std::__check_facet(), std::basic_ios< _CharT, _Traits >::_M_setstate(), std::ios_base::iostate, and std::basic_ios< _CharT, _Traits >::setstate().

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< unsigned long  __n  ) 
 

Definition at line 154 of file ostream.tcc.

References std::__check_facet(), std::basic_ios< _CharT, _Traits >::_M_setstate(), std::ios_base::iostate, and std::basic_ios< _CharT, _Traits >::setstate().

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< long  __n  ) 
 

Basic arithmetic inserters.

Parameters:
A variable of builtin type.
Returns:
*this if successful
These functions use the stream's current locale (specifically, the num_get facet) to perform numeric formatting.

Definition at line 120 of file ostream.tcc.

References std::__check_facet(), std::basic_ios< _CharT, _Traits >::_M_setstate(), std::basic_ios< _CharT, _Traits >::fill(), std::ios_base::flags(), std::ios_base::fmtflags, std::ios_base::iostate, and std::basic_ios< _CharT, _Traits >::setstate().

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< ios_base &(*  __pf)(ios_base &)  )  [inline]
 

Definition at line 85 of file ostream.tcc.

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< __ios_type &(*  __pf)(__ios_type &)  )  [inline]
 

Definition at line 73 of file ostream.tcc.

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< __ostream_type &(*  __pf)(__ostream_type &)  )  [inline]
 

Interface for manipulators.

Manuipulators such as std::endl and std::hex use these functions in constructs like "std::cout << std::endl". For more information, see the iomanip header.

Definition at line 62 of file ostream.tcc.

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::put char_type  __c  ) 
 

Simple insertion.

Parameters:
c The character to insert.
Returns:
*this
Tries to insert c.

Note:
This function is not overloaded on signed char and unsigned char.

Definition at line 330 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::_M_setstate(), std::ios_base::iostate, std::basic_ios< _CharT, _Traits >::rdbuf(), and std::basic_ios< _CharT, _Traits >::setstate().

Referenced by std::endl(), and std::ends().

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::seekp off_type  ,
ios_base::seekdir 
 

Changing the current write position.

Parameters:
off A file offset object.
dir The direction in which to seek.
Returns:
*this
If fail() is not true, calls rdbuf()->pubseekoff(off,dir). If that function fails, sets failbit.

Definition at line 446 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::_M_setstate(), std::basic_ios< _CharT, _Traits >::fail(), std::ios_base::iostate, std::basic_ostream< _CharT, _Traits >::off_type, std::basic_ostream< _CharT, _Traits >::pos_type, std::basic_ios< _CharT, _Traits >::rdbuf(), std::ios_base::seekdir, and std::basic_ios< _CharT, _Traits >::setstate().

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::seekp pos_type   ) 
 

Changing the current write position.

Parameters:
pos A file position object.
Returns:
*this
If fail() is not true, calls rdbuf()->pubseekpos(pos). If that function fails, sets failbit.

Definition at line 419 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::_M_setstate(), std::basic_ios< _CharT, _Traits >::fail(), std::ios_base::iostate, std::basic_ostream< _CharT, _Traits >::off_type, std::basic_ostream< _CharT, _Traits >::pos_type, std::basic_ios< _CharT, _Traits >::rdbuf(), and std::basic_ios< _CharT, _Traits >::setstate().

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits >::pos_type std::basic_ostream< _CharT, _Traits >::tellp  ) 
 

Getting the current write position.

Returns:
A file position object.
If fail() is not false, returns pos_type(-1) to indicate failure. Otherwise returns rdbuf()->pubseekoff(0,cur,out).

Definition at line 403 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::_M_setstate(), std::basic_ios< _CharT, _Traits >::fail(), std::basic_ostream< _CharT, _Traits >::pos_type, and std::basic_ios< _CharT, _Traits >::rdbuf().

template<typename _CharT, typename _Traits>
__ostream_type& std::basic_ostream< _CharT, _Traits >::write const char_type __s,
streamsize  __n
 

Character string insertion.

Parameters:
s The array to insert.
n Maximum number of characters to insert.
Returns:
*this
Characters are copied from s and inserted into the stream until one of the following happens:

  • n characters are inserted
  • inserting into the output sequence fails (in this case, badbit will be set in the stream's error state)

Note:
This function is not overloaded on signed char and unsigned char.


Friends And Related Function Documentation

template<typename _CharT, typename _Traits>
template<typename _CharT2, typename _Traits2>
basic_ostream<_CharT2, _Traits2>& operator<< basic_ostream< _CharT2, _Traits2 > &  ,
const char * 
[friend]
 

template<typename _CharT, typename _Traits>
template<typename _Traits2>
basic_ostream<char, _Traits2>& operator<< basic_ostream< char, _Traits2 > &  ,
const char * 
[friend]
 

template<typename _CharT, typename _Traits>
template<typename _CharT2, typename _Traits2>
basic_ostream<_CharT2, _Traits2>& operator<< basic_ostream< _CharT2, _Traits2 > &  ,
const _CharT2 * 
[friend]
 

template<typename _CharT, typename _Traits>
template<typename _Traits2>
basic_ostream<char, _Traits2>& operator<< basic_ostream< char, _Traits2 > &  ,
char 
[friend]
 

template<typename _CharT, typename _Traits>
template<typename _CharT2, typename _Traits2>
basic_ostream<_CharT2, _Traits2>& operator<< basic_ostream< _CharT2, _Traits2 > &  ,
_CharT2 
[friend]
 

template<typename _CharT, typename _Traits>
friend class sentry [friend]
 

Definition at line 118 of file ostream.


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