Skip to content

Bitstream Class Reference

devongovett edited this page Jun 15, 2012 · 7 revisions

The Bitstream class wraps a Stream and adds methods to read data on an individual bit level.

Constructor

new Bitstream(stream)

Creates a Bitstream with the given Stream.

Properties

Bitstream#bitPosition

The bit position within the current byte.

Methods

Bitstream#copy()

Returns a new Bitstream backed by the same data at the same bit position.

Bitstream#offset()

Returns the current offset from the start of the stream in bits.

Bitstream#available(bits)

Returns whether or not the bitstream has the specified number of bits, as a boolean.

Bitstream#advance(bits)

Advances the current bit offset by the specified number of bits. Advancing the bit stream also advances the backing Stream.

Bitstream#align()

Byte aligns the bitstream to the next available byte.

Bitstream#readOne()

Reads a single bit from the bitstream and advances the current bit position.

Bitstream#peekOne()

Reads a single bit from the bitstream without advancing the bit position.

Bitstream#readSmall(bits)

Reads the specified number of bits from the bitstream, up to 16 bits, and advances the current bit position.

Bitstream#peekSmall(bits)

Reads the specified number of bits from the bitstream, up to 16 bits, without advancing the bit position.

Bitstream#read(bits)

Reads the specified number of bits from the bitstream, up to 32 bits, and advances the current bit position.

Bitstream#peek(bits)

Reads the specified number of bits from the bitstream, up to 32 bits, without advancing the bit position.

Bitstream#readBig(bits)

Reads the specified number of bits from the bitstream, up to 40 bits, and advances the current bit position.

Bitstream#peekBig(bits)

Reads the specified number of bits from the bitstream, up to 40 bits, without advancing the bit position.

Clone this wiki locally