|
Input stream
istream objects are stream objects used to read and interpret input from sequences of characters. Specific members are provided to perform these input operations, which can be divided in two main groups:
- Formatted input
These functions extract data from a sequence of characters that may be interpreted and formatted to a value of a certain type. These type of operation is performed using member and global functions that overload the extraction operator ().
- Unformatted input
Most of the other member functions of the istream class are used to perform unformatted input, i.e. no interpretation is made on the characters got form the input. These member functions can get a determined number of characters from the input character sequence (get, getline, peek, read, readsome), manipulate the get pointer i(ignore, seekg, tellg, unget) or get information of the last unformatted input operation (gcount).
Additionally, a member function exists to synchronize the stream with the associated external source of characters: sync.
The standard object cin is an instantiation of this class.
The class inherits all the internal fields from its parent classes ios_base and ios:
- Formatting information
- format flags: a set of internal indicators describing how certain input/output operations shall be interpreted or generated. The state of these indicators can be obtained or modified by calling the members flags, setf and unsetf, or by using manipulators.
- field width: describes the width of the next element to be output. This value can be obtained/modified by calling the member function width or parameterized manipulator setw.
- display precision: describes the decimal precision to be used to output floating-point values. This value can be obtained/modified by calling member precision or parameterized manipulator setprecision.
- fill character: character used to pad a field up to the field width. It can be obtained or modified by calling member function fill or parameterized manipulator setfill.
- locale object: describes the localization properties to be considered when formatting i/o operations. The locale object used can be obtained calling member getloc and modified using member imbue.
- State information
- error state: internal indicator reflecting the integrity and current error state of the stream. The current object may be obtained by calling rdstate and can be modified by calling clear and setstate. Individual values may be obtained by calling good, eof, fail and bad.
- exception mask: internal exception status indicator. Its value can be retrieved/modified by calling member exceptions.
- Other
- event function stack: stack of pointers to callback functions that are called when certain events occur. Additional callback functions may be registered to be called when an event occurs, using member function register_callback.
- internal extensible arrays: two internal arrays to store long objects and void pointers. These arrays can be extended by calling member function xalloc, and references to these objects can be retrieved with iword or pword.
- pointer to tied stream: pointer to the stream object which is tied to this stream object. It can be obtained/modified by calling member function tie.
- pointer to stream buffer: pointer to the associated streambuf object. It can be obtained/modified by calling member function rdbuf.
Public members
Formatted input:
operator>> | Extract formatted data (public member function) |
Unformatted input:
gcount | Get number of characters extracted by last unformatted input operation (public member function) |
get | Get unformatted data from stream (public member function) |
getline | Get line from stream (public member function) |
ignore | Extract and discard characters (public member functions) |
peek | Peek next character (public member function) |
read | Read block of data (public member function) |
readsome | Read block of data available in the buffer (public member function) |
putback | Put character back (public member function) |
unget | Decrement get pointer (public member function) |
Positioning:
tellg | Get position of the get pointer. (public member function) |
seekg | Set position of the get pointer (public member function) |
Synchronization:
sync | Synchronize input buffer with source of characters (public member function) |
Prefix/Suffix:
sentry | Perform exception safe prefix/suffix operations (public member class) |
Member functions inherited from ios
good | Check if the state of the stream is good for i/o operations. (public member function) |
eof | Check if eofbit is set (public member function) |
fail | Check if either failbit or badbit is set (public member function) |
bad | Check if badbit is set (public member function) |
operator! | Evaluate stream object (public member function) |
rdstate | Get error state flags (public member function) |
setstate | Set error state flag (public member function) |
clear | Set error state flags (public member function) |
copyfmt | Copy formatting information (public member functions) |
fill | Get/set the fill character (public member function) |
exceptions | Get/set exception mask (public member function) |
imbue | Imbue locale (public member function) |
tie | Get/set the tied stream (public member function) |
rdbuf | Get/set the associated stream buffer (public member function) |
narrow | Narrow character (public member function) |
widen | Widen character (public member function) |
Member functions inherited from ios_base
flags | Get/set format flags (public member function) |
setf | Set specific format flags (public member function) |
unsetf | Clear specific format flags (public member function) |
precision | Get/Set floating-point decimal precision (public member function) |
width | Get/set field width (public member function) |
imbue | Imbue locale (public member function) |
getloc | Get current locale (public member function) |
xalloc | Return a new index for the internal extensible array [static] (public static member function) |
iword | Get reference to integer element of the internal extensible array (public member function) |
pword | Get reference to pointer of the internal extensible array (public member function) |
sync_with_stdio | Activate/deactivate synchronization of iostream and cstdio streams [static] (public static member function) |
|