Bytes

haxe.io.Bytes (Class)

Static Members

alloc(length: Int): Bytes

Returns a new Bytes instance with the given length. The values of the bytes are not initialized and may not be zero.

Name Type
length Int
Returns
Bytes

ofString(s: String, ?encoding: Anonymous): Bytes

Returns the Bytes representation of the given String, using the specified encoding (UTF-8 by default).

Name Type Default
s String
encoding Anonymous (optional)
Returns
Bytes

ofData(b: BytesData): Bytes

Returns the Bytes representation of the given BytesData.

Name Type
b BytesData
Returns
Bytes

ofHex(s: String): Bytes

Converts the given hexadecimal String to Bytes. s must be a string of even length consisting only of hexadecimal digits. For example: "0FDA14058916052309".

Name Type
s String
Returns
Bytes

Instance Members

length: Int

get(pos: Int): Int

Returns the byte at index pos.

Name Type
pos Int
Returns
Int

set(pos: Int, v: Int): Void

Stores the given byte v at the given position pos.

Name Type
pos Int
v Int

blit(pos: Int, src: Bytes, srcpos: Int, len: Int): Void

Copies len bytes from src into this instance.

Name Type Description
pos Int Zero-based location in this instance at which to start writing bytes.
src Bytes Source Bytes instance from which to copy bytes.
srcpos Int Zero-based location at src from which bytes will be copied.
len Int Number of bytes to be copied.

fill(pos: Int, len: Int, value: Int): Void

Sets len consecutive bytes starting from index pos of this instance to value.

Name Type
pos Int
len Int
value Int

sub(pos: Int, len: Int): Bytes

Returns a new Bytes instance that contains a copy of len bytes of this instance, starting at index pos.

Name Type
pos Int
len Int
Returns
Bytes

compare(other: Bytes): Int

Returns 0 if the bytes of this instance and the bytes of other are identical.

Returns a negative value if the length of this instance is less than the length of other, or a positive value if the length of this instance is greater than the length of other.

In case of equal lengths, returns a negative value if the first different value in other is greater than the corresponding value in this instance; otherwise returns a positive value.

Name Type
other Bytes
Returns
Int

getUInt16(pos: Int): Int

Returns the 16-bit unsigned integer at the given position pos (in little-endian encoding).

Name Type
pos Int
Returns
Int

setUInt16(pos: Int, v: Int): Void

Stores the given 16-bit unsigned integer v at the given position pos (in little-endian encoding).

Name Type
pos Int
v Int

getInt32(pos: Int): Int

Returns the 32-bit integer at the given position pos (in little-endian encoding).

Name Type
pos Int
Returns
Int

setInt32(pos: Int, v: Int): Void

Stores the given 32-bit integer v at the given position pos (in little-endian encoding).

Name Type
pos Int
v Int

getString(pos: Int, len: Int, ?encoding: Anonymous): String

Returns the len-bytes long string stored at the given position pos, interpreted with the given encoding (UTF-8 by default).

Name Type Default
pos Int
len Int
encoding Anonymous (optional)
Returns
String

toString(): String

Returns a String representation of the bytes interpreted as UTF-8.

Returns
String

getData(): BytesData

Returns the bytes of this instance as BytesData.

Returns
BytesData

Private Members


new(length: Int, b: BytesData): Void
Name Type
length Int
b BytesData