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

Controlling output for files. More...

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

std::basic_ostream< _CharT, _Traits > std::basic_ios< _CharT, _Traits > std::ios_base 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
typedef basic_filebuf< char_type,
traits_type
__filebuf_type
typedef basic_ostream< char_type,
traits_type
__ostream_type

Public Member Functions

 basic_ofstream ()
 Default constructor.

 basic_ofstream (const char *__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
 Create an output file stream.

 ~basic_ofstream ()
 The destructor does nothing.

__filebuf_typerdbuf () const
 Accessing the underlying buffer.

bool is_open ()
 Wrapper to test for an open file.

void open (const char *__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
 Opens an external file.

void close ()
 Close the file.


Private Attributes

__filebuf_type _M_filebuf

Detailed Description

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

Controlling output for files.

This class supports reading from named files, using the inherited functions from std::basic_ostream. To control the associated sequence, an instance of std::basic_filebuf is used, which this page refers to as sb.

Definition at line 600 of file fstream.


Member Typedef Documentation

template<typename _CharT, typename _Traits>
typedef basic_filebuf<char_type, traits_type> std::basic_ofstream< _CharT, _Traits >::__filebuf_type
 

Definition at line 611 of file fstream.

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

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

Definition at line 612 of file fstream.

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

template<typename _CharT, typename _Traits>
typedef _CharT std::basic_ofstream< _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_ostream< _CharT, _Traits >.

Definition at line 604 of file fstream.

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

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

Definition at line 606 of file fstream.

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

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

Definition at line 608 of file fstream.

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

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

Definition at line 607 of file fstream.

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

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

Definition at line 605 of file fstream.


Constructor & Destructor Documentation

template<typename _CharT, typename _Traits>
std::basic_ofstream< _CharT, _Traits >::basic_ofstream  )  [inline]
 

Default constructor.

Initializes sb using its default constructor, and passes &sb to the base class initializer. Does not open any files (you haven't given it a filename to open).

Definition at line 631 of file fstream.

References std::basic_ofstream< _CharT, _Traits >::__ostream_type, and std::basic_ios< _CharT, _Traits >::init().

template<typename _CharT, typename _Traits>
std::basic_ofstream< _CharT, _Traits >::basic_ofstream const char *  __s,
ios_base::openmode  __mode = ios_base::out|ios_base::trunc
[inline, explicit]
 

Create an output file stream.

Parameters:
s Null terminated string specifying the filename.
mode Open file in specified mode (see std::ios_base).
ios_base::out|ios_base::trunc is automatically included in mode.

Tip: When using std::string to hold the filename, you must use .c_str() before passing it to this constructor.

Definition at line 646 of file fstream.

References std::basic_ofstream< _CharT, _Traits >::__ostream_type, std::basic_ios< _CharT, _Traits >::init(), std::basic_ofstream< _CharT, _Traits >::open(), and std::ios_base::openmode.

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

The destructor does nothing.

The file is closed by the filebuf object, not the formatting stream.

Definition at line 660 of file fstream.


Member Function Documentation

template<typename _CharT, typename _Traits>
void std::basic_ofstream< _CharT, _Traits >::close  )  [inline]
 

Close the file.

Calls std::basic_filebuf::close(). If that function fails, failbit is set in the stream's error state.

Definition at line 707 of file fstream.

References std::basic_ios< _CharT, _Traits >::setstate().

template<typename _CharT, typename _Traits>
bool std::basic_ofstream< _CharT, _Traits >::is_open  )  [inline]
 

Wrapper to test for an open file.

Returns:
rdbuf()->is_open()

Definition at line 679 of file fstream.

template<typename _CharT, typename _Traits>
void std::basic_ofstream< _CharT, _Traits >::open const char *  __s,
ios_base::openmode  __mode = ios_base::out | ios_base::trunc
[inline]
 

Opens an external file.

Parameters:
s The name of the file.
mode The open mode flags.
Calls std::basic_filebuf::open(s,mode|out|trunc). If that function fails, failbit is set in the stream's error state.

Tip: When using std::string to hold the filename, you must use .c_str() before passing it to this constructor.

Definition at line 693 of file fstream.

References std::ios_base::openmode, and std::basic_ios< _CharT, _Traits >::setstate().

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

template<typename _CharT, typename _Traits>
__filebuf_type* std::basic_ofstream< _CharT, _Traits >::rdbuf  )  const [inline]
 

Accessing the underlying buffer.

Returns:
The current basic_filebuf buffer.
This hides both signatures of std::basic_ios::rdbuf().

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

Definition at line 671 of file fstream.


Member Data Documentation

template<typename _CharT, typename _Traits>
__filebuf_type std::basic_ofstream< _CharT, _Traits >::_M_filebuf [private]
 

Definition at line 620 of file fstream.


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