Class JSC3D.BinaryStream
BinaryStream
The helper class to parse data from a binary stream.
Defined in: jsc3d.js.
Constructor Attributes | Constructor Name and Description |
---|---|
JSC3D.BinaryStream(data, isBigEndian)
|
Method Attributes | Method Name and Description |
---|---|
Get count of the remaining bytes in the stream.
|
|
eof()
See if the position indicator is already at the end of the stream.
|
|
readBytes(buffer, bytesToRead)
Read a piece of the stream into a given buffer.
|
|
Read a 32-bits' (IEEE 754) floating point number.
|
|
Read a 64-bits' (IEEE 754) floating point number.
|
|
Read a 16-bits' signed int number.
|
|
Read a 32-bits' signed int number.
|
|
readInt8()
Read an 8-bits' signed int number.
|
|
Read a 16-bits' unsigned int number.
|
|
Read a 32-bits' unsigned int number.
|
|
Read an 8-bits' unsigned int number.
|
|
reset()
Reset the position indicator to the beginning of the stream.
|
|
seek(position)
Set the position indicator of the stream to a new position.
|
|
size()
Get the full length (in bytes) of the stream.
|
|
skip(bytesToSkip)
Advance the position indicator to skip a given number of bytes.
|
|
tell()
Get current position of the indicator.
|
Method Detail
{Number}
available()
Get count of the remaining bytes in the stream.
- Returns:
- {Number} the number of bytes from current position to the end of the stream.
{Boolean}
eof()
See if the position indicator is already at the end of the stream.
- Returns:
- {Boolean} true if the position indicator is at the end of the stream; false if not.
{Number}
readBytes(buffer, bytesToRead)
Read a piece of the stream into a given buffer.
- Parameters:
- {Array} buffer
- the buffer to receive the result.
- {Number} bytesToRead
- length of the piece to be read, in bytes.
- Returns:
- {Number} the total number of bytes that are successfully read.
{Number}
readFloat32()
Read a 32-bits' (IEEE 754) floating point number.
- Returns:
- {Number} a 32-bits' floating point number, or NaN if any error occured.
{Number}
readFloat64()
Read a 64-bits' (IEEE 754) floating point number.
- Returns:
- {Number} a 64-bits' floating point number, or NaN if any error occured.
{Number}
readInt16()
Read a 16-bits' signed int number.
- Returns:
- {Number} a 16-bits' signed int number, or NaN if any error occured.
{Number}
readInt32()
Read a 32-bits' signed int number.
- Returns:
- {Number} a 32-bits' signed int number, or NaN if any error occured.
{Number}
readInt8()
Read an 8-bits' signed int number.
- Returns:
- {Number} an 8-bits' signed int number, or NaN if any error occured.
{Number}
readUInt16()
Read a 16-bits' unsigned int number.
- Returns:
- {Number} a 16-bits' unsigned int number, or NaN if any error occured.
{Number}
readUInt32()
Read a 32-bits' unsigned int number.
- Returns:
- {Number} a 32-bits' unsigned int number, or NaN if any error occured.
{Number}
readUInt8()
Read an 8-bits' unsigned int number.
- Returns:
- {Number} an 8-bits' unsigned int number, or NaN if any error occured.
reset()
Reset the position indicator to the beginning of the stream.
{Boolean}
seek(position)
Set the position indicator of the stream to a new position.
- Parameters:
- {Number} position
- the new position.
- Returns:
- {Boolean} true if succeeded; false if the given position is out of range.
{Number}
size()
Get the full length (in bytes) of the stream.
- Returns:
- {Number} the length of the stream.
skip(bytesToSkip)
Advance the position indicator to skip a given number of bytes.
- Parameters:
- {Number} bytesToSkip
- the number of bytes to skip.
{Number}
tell()
Get current position of the indicator.
- Returns:
- {Number} current position in stream.