Static methods

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

@:has_untypedstaticofData(b:BytesData):Bytes

Returns the Bytes representation of the given BytesData.

staticofHex(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_untypedstaticofString(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

read onlylength:Int

Methods

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

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

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

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

@:has_untypedget(pos:Int):Int

Returns the byte at index pos.

getData():BytesData

Returns the bytes of this instance as BytesData.

getDouble(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.

getFloat(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.

getInt32(pos:Int):Int

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

getInt64(pos:Int):Int64

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

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

getUInt16(pos:Int):Int

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

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

Stores the given byte v at the given position pos.

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

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

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

setInt64(pos:Int, v:Int64):Void

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

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

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

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

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

toHex():String

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

@:has_untypedtoString():String

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