Visit Mozilla.org

nsIBinaryInputStream

From MDC


This interface allows consumption of primitive data types from a "binary stream" containing untagged, big-endian binary data, i.e. 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, i.e. ones that can be read and written by both big-endian and little-endian platforms.

Contents

nsIBinaryInputStream is defined in xpcom/io/nsIBinaryInputStream.idl. It is scriptable and unfrozen (hasn't changed since Mozilla 1.8).

Inherits from: nsIInputStream

[edit] Method overview

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

[edit] Methods

[edit] setInputStream()

  void setInputStream(
     in nsIInputStream aInputStream
  );
[edit] Parameters
aInputStream

[edit] readBoolean()

Reads from the stream.

  PRBool readBoolean();
[edit] Return value

Return that byte to be treated as a boolean.

[edit] read8()

Reads from the stream.

  PRUint8 read8();
[edit] Return value

Return that byte to be treated as a boolean.


[edit] read16()

Reads from the stream.

  PRUint16 read16();
[edit] Return value

Return that byte to be treated as a boolean.

[edit] read32()

Reads from the stream.

  PRUint32 read32();
[edit] Return value

Return that byte to be treated as a boolean.

[edit] read64()

Reads from the stream.

  PRUint64 read64();
[edit] Return value

Return that byte to be treated as a boolean.

[edit] readFloat()

Reads from the stream.

  float readFloat();
[edit] Return value

Return that byte to be treated as a boolean.

[edit] readDouble()

Reads from the stream.

  double readDouble();
[edit] Return value

Return that byte to be treated as a boolean.

[edit] readCString()

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

  ACString readCString();

[edit] readString()

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

  AString readString();

[edit] readBytes()

Read an opaque byte array from the stream.

  void readBytes(
     in PRUint32 aLength,
     [size_is(aLength), retval] out string aString
  );
[edit] Parameters
aLength
The number of bytes that must be read
[edit] Return value

Throws NS_ERROR_FAILURE if it can't read aLength bytes

[edit] readByteArray()

Read 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
  );
[edit] Parameters
aLength
The number of bytes that must be read
[edit] Return value

Throws NS_ERROR_FAILURE if it can't read aLength bytes