Qore::InputStream Class Referenceabstract

This class defines an abstract interface for input streams. More...

Inheritance diagram for Qore::InputStream:
[legend]

## Public Member Functions

abstract *binary | bulkRead (int limit, timeout timeout_ms=-1)
| Reads bytes (up to a specified limit) from the input stream; returns NOTHING if there are no more bytes in the stream. More...
abstract nothing | close ()
| Closes the input stream and releases any resources. More...
| constructor ()
| Constructor. More...
abstract int | read (timeout timeout_ms=-1)
| Reads a single byte from the input stream; returns -1 if the end of the stream has been reached. More...

## Detailed Description

This class defines an abstract interface for input streams.

Classes inheriting this class can be used to read bytes from various sources.

Since
  Qore 0.8.12

## Member Function Documentation

abstract *binary Qore::InputStream::bulkRead | ( | int | limit,
|  | timeout | timeout_ms = `-1`
| ) |  |

pure virtual

Reads bytes (up to a specified limit) from the input stream; returns NOTHING if there are no more bytes in the stream.

Parameters

  limit | the maximum number of bytes to read
  timeout_ms | a timeout period with a resolution of milliseconds (a relative date/time value; integer arguments will be assumed to be milliseconds); if not given or negative the call will never time out

Returns
  the read bytes (the length is between 1 and `limit` inclusive) or NOTHING if no more bytes are available

Example:
  *binary b;
  while (b = is.bulkRead(10)) {
  printf("Read: %y\n", i);
  }

Exceptions

  IO-ERROR | if an I/O error occurs
  TIMEOUT-ERROR | if no byte could be read in the specified timeout

Implemented in Qore::BinaryInputStream, Qore::FileInputStream, and Qore::EncodingConversionInputStream.

abstract nothing Qore::InputStream::close | ( |  | ) |

pure virtual

Closes the input stream and releases any resources.

Any methods called on a closed input stream will thrown an IO-ERROR exception.

Exceptions

  IO-ERROR | if an I/O error occurs

Implemented in Qore::BinaryInputStream, Qore::FileInputStream, and Qore::EncodingConversionInputStream.

Qore::InputStream::constructor | ( |  | ) |

Constructor.

Used by subclasses defined in the Qore programming language.

abstract int Qore::InputStream::read | ( | timeout | timeout_ms = `-1` | ) |

pure virtual

Reads a single byte from the input stream; returns -1 if the end of the stream has been reached.

Parameters

  timeout_ms | a timeout period with a resolution of milliseconds (a relative date/time value; integer arguments will be assumed to be milliseconds); if not given or negative the call will never time out

Returns
  the next byte (0 - 255) in the input stream or -1 if the end of the stream has been reached

Example:
  while ((int i = is.read()) != -1) {
  printf("Read: %y\n", i);
  }

Exceptions

  IO-ERROR | if an I/O error occurs
  TIMEOUT-ERROR | if no byte could be read in the specified timeout

Implemented in Qore::BinaryInputStream, Qore::FileInputStream, and Qore::EncodingConversionInputStream.