|
Output Stream
ostream objects are stream objects used to write and format output as sequences of characters. Specific members are provided to perform these output operations, which can be divided in two main groups:
- Formatted output
These member functions interpret and format the data to be written as sequences of characters. These type of operation is performed using member and global functions that overload the insertion operator (operator<<).
- Unformatted output
Most of the other member functions of the ostream class are used to perform unformatted output operations, i.e. output operations that write the data as it is, with no formatting adaptations. These member functions can write a determined number of characters to the output character sequence (put, write) and manipulate the put pointer (seekp, tellp).
Additionally, a member function exists to synchronize the stream with the associated external destination of characters: sync.
The standard objects cout, cerr and clog are instantiations 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 output:
operator<< | Insert data with format (public member function) |
Unformatted output:
put | Put character (public member function) |
write | Write block of data (public member function) |
Positioning:
tellp | Get position of put pointer (public member function) |
seekp | Set position of put pointer (public member function) |
Synchronization:
flush | Flush output stream buffer (public member function) |
Prefix/Suffix:
sentry | Perform exception safe prefix/suffix operations (public member classes) |
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) |
|