istream

#include <iostream.h>

The istream class provides the basic capability for sequential and random-access input. An istream object has a streambuf-derived object attached, and the two classes work together; the istream class does the formatting, and the streambuf class does the low-level buffered input.

You can use istream objects for sequential disk input if you first construct an appropriate filebuf object. More often, you will use the predefined stream object cin (which is actually an object of class istream_withassign), or you will use objects of classes ifstream (disk file streams) and istrstream (string streams).

Derivation

It is not always necessary to derive from istream to add functionality to a stream; consider deriving from streambuf instead, as illustrated in Deriving Your Own Stream Classes. The ifstream and istrstream classes are examples of istream-derived classes that construct member objects of predetermined derived streambuf classes. You can add manipulators without deriving a new class.

If you add new extraction operators for a derived istream class, then the rules of C++ dictate that you must reimplement all the base class extraction operators. See the “Derivation” section of class ostream for an efficient reimplementation technique.

Construction/Destruction — Public Members

istream

Constructs an istream object attached to an existing object of a streambuf-derived class.

~istream

Destroys an istream object.

Prefix/Suffix Functions — Public Members

ipfx

Check for error conditions prior to extraction operations (input prefix function).

isfx

Called after extraction operations (input suffix function).

Input Functions — Public Members

get

Extracts characters from the stream up to, but not including, delimiters.

getline

Extracts characters from the stream (extracts and discards delimiters).

read

Extracts data from the stream.

ignore

Extracts and discards characters.

peek

Returns a character without extracting it from the stream.

gcount

Counts the characters extracted in the last unformatted operation.

eatwhite

Extracts leading white space.

Other Functions — Public Members

putback

Puts characters back to the stream.

sync

Synchronizes the stream buffer with the external source of characters.

seekg

Changes the stream’s get pointer.

tellg

Gets the value of the stream’s get pointer.

Operators — Public Members

operator >>

Extraction operator for various types.

Protected Members

istream

Constructs an istream object.

Manipulators

ws

Extracts leading white space.

Input Stream Classes

See Also   streambuf, ifstream, istrstream, istream_withassign