Stream in DM and C++ - Practical Electron Microscopy and Database - - An Online Book - |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Microanalysis | EM Book http://www.globalsino.com/EM/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
================================================================================= | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The most fundamental point to understand the C++ I/O system is that it operates on streams. A stream is a common, logical interface to the various devices which comprise the computer. A stream either produces or consumes information, and it is linked to a physical device by the C++ I/O system. All streams behave in the same manner, even if the actual physical devices that they are linked are different. Because all streams act the same, the same I/O functions and operators can in fact operate on virtually any type of device. For instance, the method that you use to write to the screen can be used to write to a USB file or to the printer. In general, a stream is a logical interface to a file. As C++ defines the term "file", it can refer to any devices such as a disk file, the screen, the keyboard, a port, a file on tape, and so on. Although files are different in form and capabilities, all streams are actually the same. The advantage to this approach is that, to the programmer, one hardware device will look much like any other, namely, the stream provides a consistent interface. The stream is linked to a file through an open operation, and it is disassociated from a file through a close operation. There are two types of streams: C++ contains some predefined streams that are automatically opened when the program begins execution; however, DM might not provide such accesses of predefined streams to DM users as listed in Table 1101a.
By default, the C++ standard streams are linked to the console, but they can also be redirected
to other devices, files, or operating
systems by a program. In programs, C++ provides support for its I/O system in <iostream>.
In this header, a very complicated set of class hierarchies is specified that supports
I/O operations. The I/O classes begin with a set of template classes, which defines the form of a class without fully specifying
the data upon which it will operate. Once a template class has been defined, specific
instances of a template class can then be created. As it relates to the I/O library, Standard C++ creates two specializations of the I/O template classes: Table 1101b lists the mapping of template class names to their character-based versions.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
================================================================================= | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||