GNU g++  v5.2.1
GNU Standard C++
basic_ios.h File Reference

This is an internal header file, included by other library headers. More...

#include <bits/localefwd.h>
#include <bits/locale_classes.h>
#include <bits/locale_facets.h>
#include <bits/streambuf_iterator.h>
#include <bits/move.h>
#include <bits/basic_ios.tcc>
Include dependency graph for basic_ios.h:

Functions

namespace std _GLIBCXX_VISIBILITY (default)
 

Detailed Description

This is an internal header file, included by other library headers.

Do not attempt to use it directly. {ios}

Function Documentation

namespace std _GLIBCXX_VISIBILITY ( default  )

Template class basic_ios, virtual base class for all stream classes.

Template Parameters
_CharTType of character stream.
_TraitsTraits for character type, defaults to char_traits<_CharT>.

Most of the member functions called dispatched on stream objects (e.g., std::cout.foo(bar);) are consolidated in this class.

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

These are non-standard types.

The quick-and-easy status check.

This allows you to write constructs such as if (!a_stream) ... and while (a_stream) ...

Returns the error state of the stream buffer.

Returns
A bit pattern (well, isn't everything?)

See std::ios_base::iostate for the possible bit values. Most users will call one of the interpreting wrappers, e.g., good().

[Re]sets the error state.

Parameters
__stateThe new state flag(s) to set.

See std::ios_base::iostate for the possible bit values. Most users will not need to pass an argument.

Sets additional flags in the error state.

Parameters
__stateThe additional state flag(s) to set.

See std::ios_base::iostate for the possible bit values.

Fast error checking.

Returns
True if no error flags are set.

A wrapper around rdstate.

Fast error checking.

Returns
True if the eofbit is set.

Note that other iostate flags may also be set.

Fast error checking.

Returns
True if either the badbit or the failbit is set.

Checking the badbit in fail() is historical practice. Note that other iostate flags may also be set.

Fast error checking.

Returns
True if the badbit is set.

Note that other iostate flags may also be set.

Throwing exceptions on errors.

Returns
The current exceptions mask.

This changes nothing in the stream. See the one-argument version of exceptions(iostate) for the meaning of the return value.

Throwing exceptions on errors.

Parameters
__exceptThe new exceptions mask.

By default, error flags are set silently. You can set an exceptions mask for each stream; if a bit in the mask becomes set in the error flags, then an exception of type std::ios_base::failure is thrown.

If the error flag is already set when the exceptions mask is added, the exception is immediately thrown. Try running the following under GCC 3.1 or later:

1 #include <iostream>
2 #include <fstream>
3 #include <exception>
4 
5 int main()
6 {
7  std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
8 
9  std::ifstream f ("/etc/motd");
10 
11  std::cerr << "Setting badbit\n";
12  f.setstate (std::ios_base::badbit);
13 
14  std::cerr << "Setting exception mask\n";
15  f.exceptions (std::ios_base::badbit);
16 }

Constructor performs initialization.

The parameter is passed by derived streams.

Empty.

The destructor does nothing. More specifically, it does not destroy the streambuf held by rdbuf().

Fetches the current tied stream.

Returns
A pointer to the tied stream, or NULL if the stream is not tied.

A stream may be tied (or synchronized) to a second output stream. When this stream performs any I/O, the tied stream is first flushed. For example, std::cin is tied to std::cout.

Ties this stream to an output stream.

Parameters
__tiestrThe output stream.
Returns
The previously tied output stream, or NULL if the stream was not tied.

This sets up a new tie; see tie() for more.

Accessing the underlying buffer.

Returns
The current stream buffer.

This does not change the state of the stream.

Changing the underlying buffer.

Parameters
__sbThe new stream buffer.
Returns
The previous stream buffer.

Associates a new buffer with the current stream, and clears the error state.

Due to historical accidents which the LWG refuses to correct, the I/O library suffers from a design error: this function is hidden in derived classes by overrides of the zero-argument rdbuf(), which is non-virtual for hysterical raisins. As a result, you must use explicit qualifications to access this function via any derived class. For example:

1 std::fstream foo; // or some other derived type
2 std::streambuf* p = .....;
3 
4 foo.ios::rdbuf(p); // ios == basic_ios<char>

Copies fields of __rhs into this.

Parameters
__rhsThe source values for the copies.
Returns
Reference to this object.

All fields of __rhs are copied into this object except that rdbuf() and rdstate() remain unchanged. All values in the pword and iword arrays are copied. Before copying, each callback is invoked with erase_event. After copying, each (new) callback is invoked with copyfmt_event. The final step is to copy exceptions().

Retrieves the empty character.

Returns
The current fill character.

It defaults to a space (' ') in the current locale.

Sets a new empty character.

Parameters
__chThe new character.
Returns
The previous fill character.

The fill character is used to fill out space when P+ characters have been requested (e.g., via setw), Q characters are actually used, and Q<P. It defaults to a space (' ') in the current locale.

Moves to a new locale.

Parameters
__locThe new locale.
Returns
The previous locale.

Calls ios_base::imbue(loc), and if a stream buffer is associated with this stream, calls that buffer's pubimbue(loc).

Additional l10n notes are at http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html

Squeezes characters.

Parameters
__cThe character to narrow.
__dfaultThe character to narrow.
Returns
The narrowed character.

Maps a character of char_type to a character of char, if possible.

Returns the result of

1 std::use_facet<ctype<char_type> >(getloc()).narrow(c,dfault)

Additional l10n notes are at http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html

Widens characters.

Parameters
__cThe character to widen.
Returns
The widened character.

Maps a character of char to a character of char_type.

Returns the result of

1 std::use_facet<ctype<char_type> >(getloc()).widen(c)

Additional l10n notes are at http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html

Empty.

The default constructor does nothing and is not normally accessible to users.

All setup is performed here.

This is called from the public constructor. It is not virtual and cannot be redefined.

References __throw_exception_again, and std::__exception_ptr::swap().

Here is the call graph for this function: