nsIBinaryInputStream

This interface allows consumption of primitive data types from a "binary stream" containing untagged, big-endian binary data, that is as produced by an implementation of nsIBinaryOutputStream. This might be used, for example, to implement network protocols or to read from architecture-neutral disk files, that is ones that can be read and written by both big-endian and little-endian platforms.
Inherits from: nsIInputStream Last changed in Gecko 1.7

Method overview

PRUint8 read8();
PRUint16 read16();
PRUint32 read32();
PRUint64 read64();
PRBool readBoolean();
void readByteArray(in PRUint32 aLength, [array, size_is(aLength), retval] out PRUint8 aBytes);
void readBytes(in PRUint32 aLength, [size_is(aLength), retval] out string aString);
ACString readCString();
double readDouble();
float readFloat();
AString readString();
void setInputStream(in nsIInputStream aInputStream);

Methods

read8()

Reads from the stream.

PRUint8 read8();
Parameters

None.

Return value

An 8-bit integer read from the stream.

read16()

Reads from the stream.

PRUint16 read16();
Parameters

None.

Return value

A 16-bit integer read from the stream.

read32()

Reads from the stream.

PRUint32 read32();
Parameters

None.

Return value

A 32-bit integer read from the stream.

read64()

Reads from the stream.

Warning: This method is available from JavaScript; however JavaScript does not support 64-bit integers.
PRUint64 read64();
Parameters

None.

Return value

A 64-bit integer read from the stream.

readBoolean()

Reads an 8-bit value from the stream, treating it as a Boolean value.

PRBool readBoolean();
Parameters

None.

Return value

A boolean value read from the stream.

readByteArray()

Reads an opaque byte array from the stream, storing the results as an array of PRUint8s.

void readByteArray(
  in PRUint32 aLength,
  [array, size_is(aLength), retval] out PRUint8 aBytes
);
Parameters
aLength
The number of bytes that must be read.
aBytes
An array containing the bytes read from the stream.
Exceptions thrown
NS_ERROR_FAILURE
If it can't read aLength bytes.

readBytes()

Reads an opaque byte array from the stream.

void readBytes(
  in PRUint32 aLength,
  [size_is(aLength), retval] out string aString
);
Parameters
aLength
The number of bytes to read.
aString
A string containing the bytes read from the stream.
Exceptions thrown
NS_ERROR_FAILURE
If it can't read aLength bytes.

readCString()

Reads an 8-bit pascal style string from the stream. 32-bit length field, followed by length 8-bit chars.

ACString readCString();
Parameters

None.

Return value

The string read from the stream.

readDouble()

Reads from the stream.

double readDouble();
Parameters

None.

Return value

A double read from the stream.

readFloat()

Reads from the stream.

float readFloat();
Parameters

None.

Return value

A float read from the stream.

readString()

Reads an 16-bit pascal style string from the stream. 32-bit length field, followed by length PRUnichars.

AString readString();
Parameters

None.

Return value

The string read from the stream.

setInputStream()

void setInputStream(
  in nsIInputStream aInputStream
);
Parameters
aInputStream
The stream from which to read.

See also

Document Tags and Contributors

 Contributors to this page: Sheppy, gew, trevorh, DaveG, Kglee
 Last updated by: Sheppy,