Qore::BinaryInputStream Class Reference

This class implements the InputStream interface for reading bytes from a Binary variable. More...

Inheritance diagram for Qore::BinaryInputStream:
[legend]

## Public Member Functions

*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...
nothing | close ()
| Closes the input stream and releases any resources. More...
| constructor (binary src)
| Creates the BinaryInputStream based on the Binary given. More...
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...
Public Member Functions inherited from Qore::InputStream
| constructor ()
| Constructor. More...

## Detailed Description

This class implements the InputStream interface for reading bytes from a Binary variable.

Since
  Qore 0.8.12

Example: BinaryInputStream basic usage
  binary src = <2AFF04>;
  BinaryInputStream bis(src);
  while ((int i = bis.read()) != -1) {
  printf("read %d\n", i);
  }
  read 42
  read 255
  read 4

## Member Function Documentation

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

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 | ignored

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

Example:
  binary src = <2AFF04>;
  BinaryInputStream is(src);
  *binary b;
  while (b = is.bulkRead(2)) {
  printf("read %s\n", make_hex_string(b));
  }
  read 2aff
  read 04

Implements Qore::InputStream.

nothing Qore::BinaryInputStream::close | ( |  | ) |

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

Implements Qore::InputStream.

Qore::BinaryInputStream::constructor | ( | binary | src | ) |

Creates the BinaryInputStream based on the Binary given.

Parameters

  src | the Binary to read bytes from

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

virtual

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

Parameters

  timeout_ms | ignored

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

Example:
  binary src = <2AFF04>;
  BinaryInputStream bis(src);
  while ((int i = bis.read()) != -1) {
  printf("read %d\n", i);
  }
  read 42
  read 255
  read 4

Implements Qore::InputStream.