Qore Programming Language Reference Manual  0.8.12.3
Qore::BinaryInputStream Class Reference

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

Inheritance diagram for Qore::BinaryInputStream:

Public Member Functions

 constructor (binary src)
 Creates the BinaryInputStream based on the Binary given. More...
 
*binary read (int limit)
 Reads bytes (up to a specified limit) from the input stream; returns NOTHING if there are no more bytes in the stream. 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.13
Example: BinaryInputStream basic usage
1 binary src = <2AFF04>;
2 BinaryInputStream bis(src);
3 *binary b;
4 while (b = bis.read(2)) {
5  printf("read %d\n", make_hex_string(b));
6 }
7 
8 read 2AFF
9 read 04

Member Function Documentation

Qore::BinaryInputStream::constructor ( binary  src)

Creates the BinaryInputStream based on the Binary given.

Parameters
srcthe Binary to read bytes from
*binary Qore::BinaryInputStream::read ( int  limit)
virtual

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

Parameters
limitthe maximum number of bytes to read
Returns
the read bytes (the length is between 1 and `limit` inclusive) or NOTHING if no more bytes are available
Example:
1 binary src = <2AFF04>;
2 BinaryInputStream is(src);
3 *binary b;
4 while (b = is.read(2)) {
5  printf("read %s\n", make_hex_string(b));
6 }
7 
8 read 2aff
9 read 04

Implements Qore::InputStream.