Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions
nsIBinaryOutputStream Interface Reference

This interface allows writing of primitive data types (integers, floating-point values, booleans, etc.) to a stream in a binary, untagged, fixed-endianness format. More...

import "nsIBinaryOutputStream.idl";

Inheritance diagram for nsIBinaryOutputStream:
Inheritance graph
[legend]
Collaboration diagram for nsIBinaryOutputStream:
Collaboration graph
[legend]

List of all members.

Public Member Functions

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)
 Write a NUL-terminated 8-bit char* string to a binary stream.
void writeWStringZ (in wstring aString)
 Write a NUL-terminated 16-bit PRUnichar* string to a binary stream.
void writeUtf8Z (in wstring aString)
 Write a NUL-terminated UTF8-encoded string to a binary stream, produced from a NUL-terminated 16-bit PRUnichar* string argument.
void writeBytes ([size_is(aLength)] in string aString, in PRUint32 aLength)
 Write an opaque byte array to a binary stream.
void writeByteArray ([array, size_is(aLength)] in PRUint8 aBytes, in PRUint32 aLength)
 Write an opaque byte array to a binary stream.
void close ()
 Close the stream.
void flush ()
 Flush the stream.
unsigned long write (in string aBuf, in unsigned long aCount)
 Write data into the stream.
unsigned long writeFrom (in nsIInputStream aFromStream, in unsigned long aCount)
 Writes data into the stream from an input stream.
unsigned long writeSegments (in nsReadSegmentFun aReader, in voidPtr aClosure, in unsigned long aCount)
 Low-level write method that has access to the stream's underlying buffer.
boolean isNonBlocking ()

Detailed Description

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.

nsIBinaryInputStream

Definition at line 55 of file nsIBinaryOutputStream.idl.


Member Function Documentation

void nsIOutputStream::close ( ) [inherited]

Close the stream.

Forces the output stream to flush any buffered data.

Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif unable to flush without blocking the calling thread (non-blocking mode only)
void nsIOutputStream::flush ( ) [inherited]

Flush the stream.

Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif unable to flush without blocking the calling thread (non-blocking mode only)
Returns:
true if stream is non-blocking

NOTE: writing to a blocking output stream will block the calling thread until all given data can be consumed by the stream.

unsigned long nsIOutputStream::write ( in string  aBuf,
in unsigned long  aCount 
) [inherited]

Write data into the stream.

Parameters:
aBufthe buffer containing the data to be written
aCountthe maximum number of bytes to be written
Returns:
number of bytes written (may be less than aCount)
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif writing to the output stream would block the calling thread (non-blocking mode only)
<other-error>on failure
void nsIBinaryOutputStream::writeByteArray ( [array, size_is(aLength)] in PRUint8  aBytes,
in PRUint32  aLength 
)

Write an opaque byte array to a binary stream.

void nsIBinaryOutputStream::writeBytes ( [size_is(aLength)] in string  aString,
in PRUint32  aLength 
)

Write an opaque byte array to a binary stream.

unsigned long nsIOutputStream::writeFrom ( in nsIInputStream  aFromStream,
in unsigned long  aCount 
) [inherited]

Writes data into the stream from an input stream.

Parameters:
aFromStreamthe stream containing the data to be written
aCountthe maximum number of bytes to be written
Returns:
number of bytes written (may be less than aCount)
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif writing to the output stream would block the calling thread (non-blocking mode only)
<other-error>on failure

NOTE: This method is defined by this interface in order to allow the output stream to efficiently copy the data from the input stream into its internal buffer (if any). If this method was provided as an external facility, a separate char* buffer would need to be used in order to call the output stream's other Write method.

unsigned long nsIOutputStream::writeSegments ( in nsReadSegmentFun  aReader,
in voidPtr  aClosure,
in unsigned long  aCount 
) [inherited]

Low-level write method that has access to the stream's underlying buffer.

The reader function may be called multiple times for segmented buffers. WriteSegments is expected to keep calling the reader until either there is nothing left to write or the reader returns an error. WriteSegments should not call the reader with zero bytes to provide.

Parameters:
aReaderthe "provider" of the data to be written
aClosureopaque parameter passed to reader
aCountthe maximum number of bytes to be written
Returns:
number of bytes written (may be less than aCount)
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif writing to the output stream would block the calling thread (non-blocking mode only)
<other-error>on failure

NOTE: this function may be unimplemented if a stream has no underlying buffer (e.g., socket output stream).

Write a NUL-terminated 8-bit char* string to a binary stream.

Write a NUL-terminated UTF8-encoded string to a binary stream, produced from a NUL-terminated 16-bit PRUnichar* string argument.

Write a NUL-terminated 16-bit PRUnichar* string to a binary stream.


The documentation for this interface was generated from the following file: