USL I/O Streaming

This section refers to the USL I/O Stream Library.

We recommend that you use the standard C++ stream classes instead of the USL I/O Stream Library to develop thread-safe applications. For more information about the Standard C++ I/O Stream Library, see the Standard C++ Library Reference.

The USL I/O Stream Library provides the standard input and output capabilities for C++. In C++, input and output are described in terms of streams. The processing of these streams is done at two levels. The first level treats the data as sequences of characters; the second level treats it as a series of values of a particular type.

There are two primary base classes for the USL I/O Stream Library:

  1. The streambuf class and the classes derived from it (strstreambuf, stdiobuf, and filebuf) implement the stream buffers. Stream buffers act as temporary repositories for characters that are coming from the ultimate producers of input or are being sent to the ultimate consumers of output.
  2. The ios class maintains formatting and error-state information for these streams. The classes derived from ios implement the formatting of these streams. This formatting involves converting sequences of characters from the stream buffer into values of a particular type and converting values of a particular type into their external display format.

The USL I/O Stream Library predefines streams for standard input, standard output, and standard error. If you want to open your own streams for input or output, you must create an object of an appropriate I/O Stream class. The iostream constructor takes as an argument a pointer to a streambuf object. This object is associated with the device, file, or array of bytes in memory that is going to be the ultimate producer of input or the ultimate consumer of output.

Input and Output for User-Defined Classes

You can overload the input and output operators for the classes that you create yourself. Once you have overloaded the input and output operators for a class, you can perform input and output operations on objects of that class in the same way that you would perform input and output on char, int, double, and the other built-in types.

Related Concepts