Static methods

@:keepstaticalloc(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.

@:has_untyped@:keepstaticfastGet(b:BytesData, pos:Int):Int

Reads the pos-th byte of the given b bytes, in the most efficient way possible. Behavior when reading outside of the available data is unspecified.

@:keepstaticofData(b:BytesData):Bytes

Returns the Bytes representation of the given BytesData.

@:keepstaticofHex(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".

@:has_untyped@:keepstaticofString(s:String, ?encoding:Encoding):Bytes

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

Constructor

new(length:Int, b:BytesData)

Available on macro

Variables

@:keepread onlylength:Int

Methods

@:keepblit(pos:Int, src:Bytes, srcpos:Int, len:Int):Void

Copies len bytes from src into this instance.

Parameters:

pos

Zero-based location in this instance at which to start writing bytes.

src

Source Bytes instance from which to copy bytes.

srcpos

Zero-based location at src from which bytes will be copied.

len

Number of bytes to be copied.

@:keepcompare(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.

@:has_untyped@:keepfill(pos:Int, len:Int, value:Int):Void

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

@:has_untyped@:keepget(pos:Int):Int

Returns the byte at index pos.

@:keepgetData():BytesData

Returns the bytes of this instance as BytesData.

@:has_untyped@:keepgetDouble(pos:Int):Float

Returns the IEEE double-precision value at the given position pos (in little-endian encoding). Result is unspecified if pos is outside the bounds.

@:has_untyped@:keepgetFloat(pos:Int):Float

Returns the IEEE single-precision value at the given position pos (in little-endian encoding). Result is unspecified if pos is outside the bounds.

@:keepgetInt32(pos:Int):Int

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

@:keepgetInt64(pos:Int):Int64

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

@:has_untyped@:keepgetString(pos:Int, len:Int, ?encoding:Encoding):String

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

@:keepgetUInt16(pos:Int):Int

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

@:has_untyped@:keepset(pos:Int, v:Int):Void

Stores the given byte v at the given position pos.

@:has_untyped@:keepsetDouble(pos:Int, v:Float):Void

Stores the given IEEE double-precision value v at the given position pos in little-endian encoding. Result is unspecified if writing outside of bounds.

@:has_untyped@:keepsetFloat(pos:Int, v:Float):Void

Stores the given IEEE single-precision value v at the given position pos in little-endian encoding. Result is unspecified if writing outside of bounds.

@:keepsetInt32(pos:Int, v:Int):Void

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

@:keepsetInt64(pos:Int, v:Int64):Void

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

@:keepsetUInt16(pos:Int, v:Int):Void

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

@:keepsub(pos:Int, len:Int):Bytes

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

@:keeptoHex():String

Returns a hexadecimal String representation of the bytes of this instance.

@:keeptoString():String

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