libstdc++
std::basic_istream Class Reference
Inheritance diagram for std::basic_istream:

List of all members.

Classes

Public Types

Public Member Functions

Arithmetic Extractors

All the operator>> functions (aka formatted input functions) have some common behavior. Each starts by constructing a temporary object of type std::basic_istream::sentry with the second argument (noskipws) set to false. 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 extract whatever data is appropriate for the type of the argument.

If an exception is thrown during extraction, 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.

Unformatted Input Functions

All the unformatted input functions have some common behavior. Each starts by constructing a temporary object of type std::basic_istream::sentry with the second argument (noskipws) set to true. 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 extract whatever data is appropriate for the type of the argument.

The number of characters extracted is stored for later retrieval by gcount().

If an exception is thrown during extraction, 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.

Protected Member Functions

Protected Attributes

Friends


Detailed Description

Controlling input.

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


Member Typedef Documentation

These are non-standard types.

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

Definition at line 73 of file istream.

These are non-standard types.

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

Definition at line 72 of file istream.

typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> > std::basic_ios::__num_put_type [inherited]

These are non-standard types.

Reimplemented in std::basic_ostream.

Definition at line 86 of file basic_ios.h.

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

Definition at line 61 of file istream.

typedef _Traits::int_type std::basic_istream::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_ios< _CharT, _Traits >.

Definition at line 62 of file istream.

typedef _Traits::off_type std::basic_istream::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_ios< _CharT, _Traits >.

Definition at line 64 of file istream.

typedef _Traits::pos_type std::basic_istream::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_ios< _CharT, _Traits >.

Definition at line 63 of file istream.

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

Definition at line 65 of file istream.


Constructor & Destructor Documentation

std::basic_istream::basic_istream ( __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 93 of file istream.

virtual std::basic_istream::~basic_istream ( ) [inline, virtual]

Base destructor.

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

Definition at line 103 of file istream.


Member Function Documentation

bool std::basic_ios::bad ( ) const [inline, inherited]

Fast error checking.

Returns:
True if the badbit is set.

Note that other iostate flags may also be set.

Definition at line 203 of file basic_ios.h.

References std::basic_ios::rdstate(), and std::ios_base::badbit.

void std::basic_ios::clear ( iostate  __state = goodbit) [inherited]

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

Referenced by putback(), unget(), and seekg().

basic_ios& std::basic_ios::copyfmt ( const basic_ios< _CharT, _Traits > &  __rhs) [inherited]

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().

bool std::basic_ios::eof ( ) const [inline, inherited]

Fast error checking.

Returns:
True if the eofbit is set.

Note that other iostate flags may also be set.

Definition at line 182 of file basic_ios.h.

References std::basic_ios::rdstate(), and std::ios_base::eofbit.

Referenced by std::basic_istream::sentry::sentry(), get(), getline(), ignore(), peek(), putback(), unget(), std::operator>>(), and std::ws().

iostate std::basic_ios::exceptions ( ) const [inline, inherited]

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.

Definition at line 214 of file basic_ios.h.

void std::basic_ios::exceptions ( iostate  __except) [inline, inherited]

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:

  #include <iostream>
  #include <fstream>
  #include <exception>

  int main()
  {
      std::set_terminate (__gnu_cxx::__verbose_terminate_handler);

      std::ifstream f ("/etc/motd");

      std::cerr << "Setting badbit\n";
      f.setstate (std::ios_base::badbit);

      std::cerr << "Setting exception mask\n";
      f.exceptions (std::ios_base::badbit);
  }

Definition at line 249 of file basic_ios.h.

References std::basic_ios::clear().

bool std::basic_ios::fail ( ) const [inline, inherited]

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.

Definition at line 193 of file basic_ios.h.

References std::basic_ios::rdstate(), std::ios_base::badbit, and std::ios_base::failbit.

Referenced by tellg(), seekg(), std::basic_ostream::tellp(), and std::basic_ostream::seekp().

char_type std::basic_ios::fill ( ) const [inline, inherited]

Retrieves the empty character.

Returns:
The current fill character.

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

Definition at line 362 of file basic_ios.h.

References std::basic_ios::widen().

char_type std::basic_ios::fill ( char_type  __ch) [inline, inherited]

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.

Definition at line 382 of file basic_ios.h.

References std::basic_ios::fill().

streamsize std::basic_istream::gcount ( ) const [inline]

Character counting.

Returns:
The number of characters extracted by the previous unformatted input function dispatched for this stream.

Definition at line 251 of file istream.

basic_istream< _CharT, _Traits >::int_type std::basic_istream::get ( void  )

Simple extraction.

Returns:
A character, or eof().

Tries to extract a character. If none are available, sets failbit and returns traits::eof().

Definition at line 238 of file istream.tcc.

References std::basic_ios< _CharT, _Traits >::eof(), _M_gcount, std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::sbumpc(), std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

basic_istream< _CharT, _Traits > & std::basic_istream::get ( char_type __c)

Simple extraction.

Parameters:
cThe character in which to store data.
Returns:
*this

Tries to extract a character and store it in c. If none are available, sets failbit and returns traits::eof().

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

Definition at line 274 of file istream.tcc.

References _M_gcount, std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::sbumpc(), std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

basic_istream< _CharT, _Traits > & std::basic_istream::get ( char_type __s,
streamsize  __n,
char_type  __delim 
)

Simple multiple-character extraction.

Parameters:
sPointer to an array.
nMaximum number of characters to store in s.
delimA "stop" character.
Returns:
*this

Characters are extracted and stored into s until one of the following happens:

  • n-1 characters are stored
  • the input sequence reaches EOF
  • the next character equals delim, in which case the character is not extracted

If no characters are stored, failbit is set in the stream's error state.

In any case, a null character is stored into the next location in the array.

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

Definition at line 311 of file istream.tcc.

References _M_gcount, std::basic_ios< _CharT, _Traits >::eof(), std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::sgetc(), std::basic_streambuf::snextc(), std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

__istream_type& std::basic_istream::get ( char_type __s,
streamsize  __n 
) [inline]

Simple multiple-character extraction.

Parameters:
sPointer to an array.
nMaximum number of characters to store in s.
Returns:
*this

Returns get(s,n,widen('\n')).

Definition at line 335 of file istream.

basic_istream< _CharT, _Traits > & std::basic_istream::get ( __streambuf_type __sb,
char_type  __delim 
)

Extraction into another streambuf.

Parameters:
sbA streambuf in which to store data.
delimA "stop" character.
Returns:
*this

Characters are extracted and inserted into sb until one of the following happens:

  • the input sequence reaches EOF
  • insertion into the output buffer fails (in this case, the character that would have been inserted is not extracted)
  • the next character equals delim (in this case, the character is not extracted)
  • an exception occurs (and in this case is caught)

If no characters are stored, failbit is set in the stream's error state.

Definition at line 358 of file istream.tcc.

References _M_gcount, std::basic_ios< _CharT, _Traits >::eof(), std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::sgetc(), std::basic_streambuf::sputc(), std::basic_streambuf::snextc(), std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

__istream_type& std::basic_istream::get ( __streambuf_type __sb) [inline]

Extraction into another streambuf.

Parameters:
sbA streambuf in which to store data.
Returns:
*this

Returns get(sb,widen('\n')).

Definition at line 368 of file istream.

basic_istream< _CharT, _Traits > & std::basic_istream::getline ( char_type __s,
streamsize  __n,
char_type  __delim 
)

String extraction.

Parameters:
sA character array in which to store the data.
nMaximum number of characters to extract.
delimA "stop" character.
Returns:
*this

Extracts and stores characters into s until one of the following happens. Note that these criteria are required to be tested in the order listed here, to allow an input line to exactly fill the s array without setting failbit.

  1. the input sequence reaches end-of-file, in which case eofbit is set in the stream error state
  2. the next character equals delim, in which case the character is extracted (and therefore counted in gcount()) but not stored
  3. n-1 characters are stored, in which case failbit is set in the stream error state

If no characters are extracted, failbit is set. (An empty line of input should therefore not cause failbit to be set.)

In any case, a null character is stored in the next location in the array.

Definition at line 402 of file istream.tcc.

References _M_gcount, std::basic_ios< _CharT, _Traits >::eof(), std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::sgetc(), std::basic_streambuf::snextc(), std::basic_streambuf::sbumpc(), std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

__istream_type& std::basic_istream::getline ( char_type __s,
streamsize  __n 
) [inline]

String extraction.

Parameters:
sA character array in which to store the data.
nMaximum number of characters to extract.
Returns:
*this

Returns getline(s,n,widen('\n')).

Definition at line 408 of file istream.

Referenced by std::basic_istream< char >::getline().

bool std::basic_ios::good ( ) const [inline, inherited]

Fast error checking.

Returns:
True if no error flags are set.

A wrapper around rdstate.

Definition at line 172 of file basic_ios.h.

References std::basic_ios::rdstate().

basic_istream< _CharT, _Traits > & std::basic_istream::ignore ( void  )

Discarding characters.

Parameters:
nNumber of characters to discard.
delimA "stop" character.
Returns:
*this

Extracts characters and throws them away until one of the following happens:

  • if n != std::numeric_limits<int>::max(), n characters are extracted
  • the input sequence reaches end-of-file
  • the next character equals delim (in this case, the character is extracted); note that this condition will never occur if delim equals traits::eof().

NB: Provide three overloads, instead of the single function (with defaults) mandated by the Standard: this leads to a better performing implementation, while still conforming to the Standard.

Definition at line 462 of file istream.tcc.

References _M_gcount, std::basic_ios< _CharT, _Traits >::eof(), std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::sbumpc(), std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

basic_istream< _CharT, _Traits > & std::basic_istream::ignore ( streamsize  __n)

Simple extraction.

Returns:
A character, or eof().

Tries to extract a character. If none are available, sets failbit and returns traits::eof().

Definition at line 495 of file istream.tcc.

References _M_gcount, std::basic_ios< _CharT, _Traits >::eof(), std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::sgetc(), std::basic_streambuf::snextc(), std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

basic_istream< _CharT, _Traits > & std::basic_istream::ignore ( streamsize  __n,
int_type  __delim 
)

Simple extraction.

Returns:
A character, or eof().

Tries to extract a character. If none are available, sets failbit and returns traits::eof().

Definition at line 557 of file istream.tcc.

References _M_gcount, std::basic_ios< _CharT, _Traits >::eof(), std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::sgetc(), std::basic_streambuf::snextc(), std::basic_streambuf::sbumpc(), std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

locale std::basic_ios::imbue ( const locale __loc) [inherited]

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

void std::basic_ios::init ( basic_streambuf< _CharT, _Traits > *  __sb) [protected, inherited]

All setup is performed here.

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

Referenced by std::basic_istream< char >::basic_istream(), and std::basic_ostream< char >::basic_ostream().

char std::basic_ios::narrow ( char_type  __c,
char  __dfault 
) const [inline, inherited]

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

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

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

Definition at line 422 of file basic_ios.h.

std::basic_ios::operator void * ( ) const [inline, inherited]

The quick-and-easy status check.

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

Definition at line 113 of file basic_ios.h.

References std::basic_ios::fail().

bool std::basic_ios::operator! ( ) const [inline, inherited]

The quick-and-easy status check.

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

Definition at line 117 of file basic_ios.h.

References std::basic_ios::fail().

__istream_type& std::basic_istream::operator>> ( __istream_type &(*)(__istream_type &)  __pf) [inline]

Interface for manipulators.

Manipulators such as std::ws and std::dec use these functions in constructs like std::cin >> std::ws. For more information, see the iomanip header.

Definition at line 122 of file istream.

__istream_type& std::basic_istream::operator>> ( __ios_type &(*)(__ios_type &)  __pf) [inline]

Interface for manipulators.

Manipulators such as std::ws and std::dec use these functions in constructs like std::cin >> std::ws. For more information, see the iomanip header.

Definition at line 126 of file istream.

__istream_type& std::basic_istream::operator>> ( ios_base &(*)(ios_base &)  __pf) [inline]

Interface for manipulators.

Manipulators such as std::ws and std::dec use these functions in constructs like std::cin >> std::ws. For more information, see the iomanip header.

Definition at line 133 of file istream.

__istream_type& std::basic_istream::operator>> ( bool &  __n) [inline]

Basic arithmetic extractors.

Parameters:
Avariable of builtin type.
Returns:
*this if successful

These functions use the stream's current locale (specifically, the num_get facet) to parse the input data.

Definition at line 169 of file istream.

basic_istream< _CharT, _Traits > & std::basic_istream::operator>> ( short &  __n)

Basic arithmetic extractors.

Parameters:
Avariable of builtin type.
Returns:
*this if successful

These functions use the stream's current locale (specifically, the num_get facet) to parse the input data.

Definition at line 116 of file istream.tcc.

References std::num_get::get(), std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

__istream_type& std::basic_istream::operator>> ( unsigned short &  __n) [inline]

Basic arithmetic extractors.

Parameters:
Avariable of builtin type.
Returns:
*this if successful

These functions use the stream's current locale (specifically, the num_get facet) to parse the input data.

Definition at line 176 of file istream.

basic_istream< _CharT, _Traits > & std::basic_istream::operator>> ( int &  __n)

Basic arithmetic extractors.

Parameters:
Avariable of builtin type.
Returns:
*this if successful

These functions use the stream's current locale (specifically, the num_get facet) to parse the input data.

Definition at line 161 of file istream.tcc.

References std::num_get::get(), std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

__istream_type& std::basic_istream::operator>> ( unsigned int &  __n) [inline]

Basic arithmetic extractors.

Parameters:
Avariable of builtin type.
Returns:
*this if successful

These functions use the stream's current locale (specifically, the num_get facet) to parse the input data.

Definition at line 183 of file istream.

__istream_type& std::basic_istream::operator>> ( long &  __n) [inline]

Basic arithmetic extractors.

Parameters:
Avariable of builtin type.
Returns:
*this if successful

These functions use the stream's current locale (specifically, the num_get facet) to parse the input data.

Definition at line 187 of file istream.

__istream_type& std::basic_istream::operator>> ( unsigned long &  __n) [inline]

Basic arithmetic extractors.

Parameters:
Avariable of builtin type.
Returns:
*this if successful

These functions use the stream's current locale (specifically, the num_get facet) to parse the input data.

Definition at line 191 of file istream.

__istream_type& std::basic_istream::operator>> ( long long &  __n) [inline]

Basic arithmetic extractors.

Parameters:
Avariable of builtin type.
Returns:
*this if successful

These functions use the stream's current locale (specifically, the num_get facet) to parse the input data.

Definition at line 196 of file istream.

__istream_type& std::basic_istream::operator>> ( unsigned long long &  __n) [inline]

Basic arithmetic extractors.

Parameters:
Avariable of builtin type.
Returns:
*this if successful

These functions use the stream's current locale (specifically, the num_get facet) to parse the input data.

Definition at line 200 of file istream.

__istream_type& std::basic_istream::operator>> ( float &  __f) [inline]

Basic arithmetic extractors.

Parameters:
Avariable of builtin type.
Returns:
*this if successful

These functions use the stream's current locale (specifically, the num_get facet) to parse the input data.

Definition at line 205 of file istream.

__istream_type& std::basic_istream::operator>> ( double &  __f) [inline]

Basic arithmetic extractors.

Parameters:
Avariable of builtin type.
Returns:
*this if successful

These functions use the stream's current locale (specifically, the num_get facet) to parse the input data.

Definition at line 209 of file istream.

__istream_type& std::basic_istream::operator>> ( long double &  __f) [inline]

Basic arithmetic extractors.

Parameters:
Avariable of builtin type.
Returns:
*this if successful

These functions use the stream's current locale (specifically, the num_get facet) to parse the input data.

Definition at line 213 of file istream.

__istream_type& std::basic_istream::operator>> ( void *&  __p) [inline]

Basic arithmetic extractors.

Parameters:
Avariable of builtin type.
Returns:
*this if successful

These functions use the stream's current locale (specifically, the num_get facet) to parse the input data.

Definition at line 217 of file istream.

basic_istream< _CharT, _Traits > & std::basic_istream::operator>> ( __streambuf_type __sb)

Extracting into another streambuf.

Parameters:
sbA 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 this stream and inserted into the sb streambuf until one of the following occurs:

  • the input stream reaches end-of-file,
  • insertion into the output buffer fails (in this case, the character that would have been inserted is not extracted), or
  • an exception occurs (and in this case is caught)

If the function inserts no characters, failbit is set.

Definition at line 206 of file istream.tcc.

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

basic_istream< _CharT, _Traits >::int_type std::basic_istream::peek ( void  )

Looking ahead in the stream.

Returns:
The next character, or eof().

If, after constructing the sentry object, good() is false, returns traits::eof(). Otherwise reads but does not extract the next input character.

Definition at line 622 of file istream.tcc.

References std::basic_ios< _CharT, _Traits >::eof(), _M_gcount, std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::sgetc(), std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

basic_istream< _CharT, _Traits > & std::basic_istream::putback ( char_type  __c)

Unextracting a single character.

Parameters:
cThe character to push back into the input stream.
Returns:
*this

If rdbuf() is not null, calls rdbuf()->sputbackc(c).

If rdbuf() is null or if sputbackc() fails, sets badbit in the error state.

Note:
This function first clears eofbit. Since no characters are extracted, the next call to gcount() will return 0, as required by DR 60.

Definition at line 713 of file istream.tcc.

References _M_gcount, std::basic_ios< _CharT, _Traits >::clear(), std::basic_ios< _CharT, _Traits >::rdstate(), std::ios_base::eofbit, std::basic_ios< _CharT, _Traits >::eof(), std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::sputbackc(), std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

Referenced by std::operator>>().

basic_streambuf<_CharT, _Traits>* std::basic_ios::rdbuf ( ) const [inline, inherited]

Accessing the underlying buffer.

Returns:
The current stream buffer.

This does not change the state of the stream.

Definition at line 313 of file basic_ios.h.

Referenced by operator>>(), get(), getline(), ignore(), peek(), read(), readsome(), putback(), unget(), sync(), tellg(), seekg(), std::basic_ostream< char >::_M_write(), std::basic_ostream::operator<<(), std::basic_ostream::put(), std::basic_ostream::flush(), std::basic_ostream::tellp(), and std::basic_ostream::seekp().

basic_streambuf<_CharT, _Traits>* std::basic_ios::rdbuf ( basic_streambuf< _CharT, _Traits > *  __sb) [inherited]

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:

  std::fstream     foo;         // or some other derived type
  std::streambuf*  p = .....;

  foo.ios::rdbuf(p);            // ios == basic_ios<char>
iostate std::basic_ios::rdstate ( ) const [inline, inherited]

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().

Definition at line 129 of file basic_ios.h.

Referenced by putback(), unget(), and seekg().

basic_istream< _CharT, _Traits > & std::basic_istream::read ( char_type __s,
streamsize  __n 
)

Extraction without delimiters.

Parameters:
sA character array.
nMaximum number of characters to store.
Returns:
*this

If the stream state is good(), extracts characters and stores them into s until one of the following happens:

  • n characters are stored
  • the input sequence reaches end-of-file, in which case the error state is set to failbit|eofbit.
Note:
This function is not overloaded on signed char and unsigned char.

Definition at line 652 of file istream.tcc.

References _M_gcount, std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::sgetn(), std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

streamsize std::basic_istream::readsome ( char_type __s,
streamsize  __n 
)

Extraction until the buffer is exhausted, but no more.

Parameters:
sA character array.
nMaximum number of characters to store.
Returns:
The number of characters extracted.

Extracts characters and stores them into s depending on the number of characters remaining in the streambuf's buffer, rdbuf()->in_avail(), called A here:

  • if A == -1, sets eofbit and extracts no characters
  • if A == 0, extracts no characters
  • if A > 0, extracts min(A,n)

The goal is to empty the current buffer, and to not request any more from the external input sequence controlled by the streambuf.

Definition at line 681 of file istream.tcc.

References _M_gcount, std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::in_avail(), std::basic_streambuf::sgetn(), std::min(), std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

basic_istream< _CharT, _Traits > & std::basic_istream::seekg ( pos_type  __pos)

Changing the current read position.

Parameters:
posA file position object.
Returns:
*this

If fail() is not true, calls rdbuf()->pubseekpos(pos). If that function fails, sets failbit.

Note:
This function first clears eofbit. It does not count the number of characters extracted, if any, and therefore does not affect the next call to gcount().

Definition at line 847 of file istream.tcc.

References std::basic_ios< _CharT, _Traits >::clear(), std::basic_ios< _CharT, _Traits >::rdstate(), std::ios_base::eofbit, std::basic_ios< _CharT, _Traits >::fail(), std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::pubseekpos(), std::ios_base::in, std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

basic_istream< _CharT, _Traits > & std::basic_istream::seekg ( off_type  __off,
ios_base::seekdir  __dir 
)

Changing the current read position.

Parameters:
offA file offset object.
dirThe direction in which to seek.
Returns:
*this

If fail() is not true, calls rdbuf()->pubseekoff(off,dir). If that function fails, sets failbit.

Note:
This function first clears eofbit. It does not count the number of characters extracted, if any, and therefore does not affect the next call to gcount().

Definition at line 886 of file istream.tcc.

References std::basic_ios< _CharT, _Traits >::clear(), std::basic_ios< _CharT, _Traits >::rdstate(), std::ios_base::eofbit, std::basic_ios< _CharT, _Traits >::fail(), std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::pubseekoff(), std::ios_base::in, std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

void std::basic_ios::setstate ( iostate  __state) [inline, inherited]

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.

Definition at line 149 of file basic_ios.h.

References std::basic_ios::clear(), and std::basic_ios::rdstate().

Referenced by operator>>(), get(), getline(), ignore(), peek(), read(), readsome(), putback(), unget(), sync(), seekg(), std::basic_ostream< char >::_M_write(), std::basic_ostream::operator<<(), std::basic_ostream::put(), std::basic_ostream::flush(), and std::basic_ostream::seekp().

int std::basic_istream::sync ( void  )

Synchronizing the stream buffer.

Returns:
0 on success, -1 on failure

If rdbuf() is a null pointer, returns -1.

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

Otherwise, returns 0.

Note:
This function does not count the number of characters extracted, if any, and therefore does not affect the next call to gcount().

Definition at line 783 of file istream.tcc.

References std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::pubsync(), std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

basic_istream< _CharT, _Traits >::pos_type std::basic_istream::tellg ( void  )

Getting the current read position.

Returns:
A file position object.

If fail() is not false, returns pos_type(-1) to indicate failure. Otherwise returns rdbuf()->pubseekoff(0,cur,in).

Note:
This function does not count the number of characters extracted, if any, and therefore does not affect the next call to gcount(). At variance with putback, unget and seekg, eofbit is not cleared first.

Definition at line 819 of file istream.tcc.

References std::basic_ios< _CharT, _Traits >::fail(), std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::pubseekoff(), std::ios_base::cur, std::ios_base::in, and std::ios_base::badbit.

basic_ostream<_CharT, _Traits>* std::basic_ios::tie ( ) const [inline, inherited]

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.

Definition at line 287 of file basic_ios.h.

basic_ostream<_CharT, _Traits>* std::basic_ios::tie ( basic_ostream< _CharT, _Traits > *  __tiestr) [inline, inherited]

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.

Definition at line 299 of file basic_ios.h.

basic_istream< _CharT, _Traits > & std::basic_istream::unget ( void  )

Unextracting the previous character.

Returns:
*this

If rdbuf() is not null, calls rdbuf()->sungetc(c).

If rdbuf() is null or if sungetc() fails, sets badbit in the error state.

Note:
This function first clears eofbit. Since no characters are extracted, the next call to gcount() will return 0, as required by DR 60.

Definition at line 748 of file istream.tcc.

References _M_gcount, std::basic_ios< _CharT, _Traits >::clear(), std::basic_ios< _CharT, _Traits >::rdstate(), std::ios_base::eofbit, std::basic_ios< _CharT, _Traits >::eof(), std::basic_ios< _CharT, _Traits >::rdbuf(), std::basic_streambuf::sungetc(), std::ios_base::badbit, and std::basic_ios< _CharT, _Traits >::setstate().

char_type std::basic_ios::widen ( char  __c) const [inline, inherited]

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

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

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

Definition at line 441 of file basic_ios.h.

Referenced by std::basic_istream< char >::get(), and std::basic_istream< char >::getline().


Member Data Documentation

The number of characters extracted in the previous unformatted function; see gcount().

Definition at line 81 of file istream.

Referenced by std::basic_istream< char >::~basic_istream(), std::basic_istream< char >::gcount(), get(), getline(), ignore(), peek(), read(), readsome(), putback(), and unget().


The documentation for this class was generated from the following files: