Interface nsIBinaryOutputStreamType

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.

See

nsIBinaryInputStream

Hierarchy

Methods

  • Increases the reference count for this interface. The associated instance will not be deleted unless the reference count is returned to zero.

    Returns

    The resulting reference count.

    Returns number

  • Parameters

    • aIID: object
    • Optional aInstancePtr: object

    Returns any

  • A run time mechanism for interface discovery.

    Returns

    NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.

    aInstancePtr must not be null.

    Parameters

    • aIID: object

      [in] A requested interface IID

    • aInstancePtr: object

      [out] A pointer to an interface pointer to receive the result.

    Returns void

  • Decreases the reference count for this interface. Generally, if the reference count returns to zero, the associated instance is deleted.

    Returns

    The resulting reference count.

    Returns number

  • Close the stream. Forces the output stream to flush any buffered data. Any subsequent calls to StreamStatus should throw NS_BASE_STREAM_CLOSED. Succeeds without effect if already closed.

    Throws

    NS_BASE_STREAM_WOULD_BLOCK if unable to flush without blocking the calling thread (non-blocking mode only)

    Returns void

  • Flush the stream.

    Throws

    NS_BASE_STREAM_WOULD_BLOCK if unable to flush without blocking the calling thread (non-blocking mode only)

    Returns void

  • 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.

    NOTE: a non-blocking output stream may implement nsIAsyncOutputStream to provide consumers with a way to wait for the stream to accept more data once its write method is unable to accept any data without blocking.

    Returns boolean

  • Parameters

    • aOutputStream: nsIOutputStream

    Returns void

  • Check the current status of the stream. A stream that is closed will throw an exception when this method is called. That enables the caller to know the condition of the stream before attempting to write into it.

    This method will not throw NS_BASE_STREAM_WOULD_BLOCK, even if the stream is a non-blocking stream with no available space. A non-blocking stream which has not been closed, but has no available room should return NS_OK.

    NOTE: This method should not block the calling thread (e.g. to query the state of a file descriptor), even when called on a blocking stream.

    Throws

    NS_BASE_STREAM_CLOSED if the stream closed normally

    Throws

    if the stream closed with a different status

    Returns void

  • Write data into the stream.

    Returns

    number of bytes written (may be less than aCount)

    Throws

    NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would block the calling thread (non-blocking mode only)

    Throws

    on failure

    Parameters

    • aBuf: string

      the buffer containing the data to be written

    • aCount: number

      the maximum number of bytes to be written

    Returns number

  • Parameters

    • a16: uint16_t

    Returns void

  • Parameters

    • a32: uint32_t

    Returns void

  • Parameters

    • a64: uint64_t

    Returns void

  • Parameters

    • aByte: uint8_t

    Returns void

  • Write a boolean as an 8-bit char to the stream.

    Parameters

    • aBoolean: boolean

    Returns void

  • Write an opaque byte array to the stream.

    Parameters

    • aBytes: invalid

    Returns void

  • Write an opaque byte array to the stream.

    Parameters

    • aString: string
    • aLength: uint32_t

    Returns void

  • Non-scriptable and saner-signature version of the same.

    Parameters

    • aBytes: Bytes

    Returns void

  • Parameters

    • aDouble: number

    Returns void

  • Parameters

    • aFloat: number

    Returns void

  • Writes data into the stream from an input stream.

    Returns

    number of bytes written (may be less than aCount)

    Throws

    NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would block the calling thread (non-blocking mode only). This failure means no bytes were transferred.

    Throws

    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.

    Parameters

    • aFromStream: nsIInputStream

      the stream containing the data to be written

    • aCount: number

      the maximum number of bytes to be written

    Returns number

  • 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.

    Returns

    number of bytes written (may be less than aCount)

    Throws

    NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would block the calling thread (non-blocking mode only). This failure means no bytes were transferred.

    Throws

    NS_ERROR_NOT_IMPLEMENTED if the stream has no underlying buffer

    Throws

    on failure

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

    Parameters

    • aReader: nsReadSegmentFun

      the "provider" of the data to be written

    • aClosure: voidPtr

      opaque parameter passed to reader

    • aCount: number

      the maximum number of bytes to be written

    Returns number

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

    Parameters

    • aString: string

    Returns void

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

    Parameters

    • aString: wstring

    Returns void

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

    Parameters

    • aString: wstring

    Returns void

Generated using TypeDoc