Visit Mozilla.org

nsIBinaryOutputStream

From MDC


This interface allows writing of primitive data types (integers, floating-point values, booleans, etc.) to a stream in a binary, untagged, fixed-endianness format. This might be used, for example, to implement network protocols or to produce architecture-neutral binary disk files, i.e. ones that can be read and written by both big-endian and little-endian platforms. Output is written in big-endian order (high-order byte first), as this is traditional network order.

Contents

nsIBinaryOutputStream is defined in xpcom/io/nsIBinaryOutputStream.idl. It is scriptable and has been frozen since Mozilla 1.8.


Inherits from: nsIOutputStream

[edit] Method overview

void setOutputStream(in nsIOutputStream aOutputStream);
void writeBoolean(in PRBool aBoolean);
void write8(in PRUint8 aByte);
void write16(in PRUint16 a16);
void write32(in PRUint32 a32);
void write64(in PRUint64 a64);
void writeFloat(in float aFloat);
void writeDouble(in double aDouble);
void writeStringZ(in string aString);
void writeWStringZ(in wstring aString);
void writeUtf8Z(in wstring aString);
void writeBytes([size_is(aLength)] in string aString, in PRUint32 aLength);
void writeByteArray([array, size_is(aLength)] in PRUint8 aBytes, in PRUint32 aLength);

[edit] Methods

[edit] setOutputStream()

  void setOutputStream(
     in nsIOutputStream aOutputStream
  );
[edit] Parameters
aOutputStream
Instance of the nsIOutputStream object

[edit] write8()

Write a boolean as an bit char to the stream.

  void write8(
     in PRUint8 aByte
  );
[edit] Parameters
aByte

[edit] write16()

Write a boolean as an bit char to the stream.

  void write16(
     in PRUint16 a16
  );
[edit] Parameters
a16

[edit] write32()

Write a boolean as an bit char to the stream.

  void write32(
     in PRUint32 a32
  );
[edit] Parameters
a32

[edit] write32()

Write a boolean as an bit char to the stream.

  void write64(
     in PRUint64 a64
  );
[edit] Parameters
a64

[edit] write32()

Write a boolean as an bit char to the stream.

  void writeFloat(
     in float aFloat
  );
[edit] Parameters
aFloat

[edit] write32()

Write a boolean as an bit char to the stream.

  void writeDouble(
     in double aDouble
  );
[edit] Parameters
aDouble

[edit] writeStringZ()

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

  void writeStringZ(
     in string aString
  );
[edit] Parameters
aString

[edit] writeWStringZ()

Write a 16-bit pascal style string to the stream. 32-bit length field, followed by length PRUnichars.

  void writeWStringZ(
     in wstring aString
  );
[edit] Parameters
aString

[edit] writeUtf8Z()

Write an 8-bit pascal style string (UTF8-encoded) to the stream. 32-bit length field, followed by length 8-bit chars.

  void writeUtf8Z(
     in wstring aString
  );
[edit] Parameters
aString

[edit] writeBytes()

Write an opaque byte array to the stream.

  void writeBytes(
     [size_is(aLength)] in string aString, 
     in PRUint32 aLength
  );
[edit] Parameters
aString
aLength

[edit] writeByteArray()

Write an opaque byte array to the stream.

  void writeByteArray(
     [array, size_is(aLength)] in PRUint8 aBytes,
     in PRUint32 aLength
  );
[edit] Parameters
aBytes
aLength