nsIBinaryInputStream 编辑

xpcom/io/nsIBinaryInputStream.idlScriptable 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();
unsigned long readArrayBuffer(in PRUint32 aLength, in jsval aArrayBuffer);
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.

readArrayBuffer()

Read opaque bytes from the stream, storing the results in an ArrayBuffer.

unsigned long readArrayBuffer(in PRUint32 aLength, in jsval aArrayBuffer);
Parameters
aLength
The number of bytes that should be read.
aArrayBuffer
The arraybuffer in which to store the results.
Return value

The number of bytes actually read into aArrayBuffer.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:106 次

字数:9083

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文