Implement streams for handling standard input, output and stderr

The iostream implements a descendent of THandleStream streams that can be used to read from standard input and write to standard output and standard diagnostic output (stderr).

Used for definition of TStream Type of stream to create TIOSType is passed to the Create constructor of , it determines what kind of stream is created. The stream can be used to read from standard input The stream can be used to write to standard output The stream can be used to write to standard diagnostic output Error thrown in case of an invalid operation on a TIOStream. Stream which handles standard input/output and stderr.

TIOStream can be used to create a stream which reads from or writes to the standard input, output or stderr file descriptors. It is a descendent of THandleStream. The type of stream that is created is determined by the argument to the constructor. The handle of the standard input, output or stderr file descriptors is determined automatically.

The TIOStream keeps an internal Position, and attempts to provide minimal Seek behaviour based on this position.

THandleStream
Construct a new instance of TIOStream

Create creates a new instance of , which can subsequently be used

No checking is performed to see whether the requested file descriptor is actually open for reading/writing. In that case, subsequent calls to Read or Write or seek will fail.
Type of stream to create Read data from the stream. Read checks first whether the type of the stream allows reading (type is iosInput). If not, it raises a exception. If the stream can be read, it calls the inherited Read to actually read the data. An EIOStreamError exception is raised if the stream does not allow reading. The number of bytes actually read Memory buffer for the read data Number of bytes to read Write data to the stream Write checks first whether the type of the stream allows writing (type is iosOutput or iosError). If not, it raises a exception. If the stream can be written to, it calls the inherited Write to actually read the data. An EIOStreamError exception is raised if the stream does not allow writing. Number of bytes actually written. Memory buffer containing the data to be written. Number of bytes to write. Set the size of the stream SetSize overrides the standard SetSize implementation. It always raises an exception, because the standard input, output and stderr files have no size. An EIOStreamError exception is raised when this method is called. New size for the stream/ Set the stream position

Seek overrides the standard Seek implementation. Normally, standard input, output and stderr are not seekable. The TIOStream stream tries to provide seek capabilities for the following limited number of cases:

Origin=soFromBeginning
If Offset is larger than the current position, then the remaining bytes are skipped by reading them from the stream and discarding them, if the stream is of type iosInput.
Origin=soFromCurrent
If Offset is zero, the current position is returned. If it is positive, then Offset bytes are skipped by reading them from the stream and discarding them, if the stream is of type iosInput.

All other cases will result in a EIOStreamError exception.

An exception is raised if the stream does not allow the requested seek operation.
New position of the stream. Byte offset to position the stream on Where to start the byte offset Stream support