Class DataBuffer

Информация

Databuffer objects provide storage for arbitrary data.

Подробнее...

Подробное описание

Databuffer objects provide storage for arbitrary data.

Data may be written to a databufffer using one of the 'poke' methods, and read from a databuffer using one of the 'peek' methods.

Parameters that specify buffer addresses or array indices for data transfers are not currently range checked. In general, you should always ensure that these are always valid, ie: >=0 And <=length of the buffer/array. Any transfer count parameters should always be >=0, but will always be clipped to make sure no overreads or overwrites occur.

Конструкторы

Method New ( length:Int )


Creates a new data buffer of the specified byte length.

Values can be written into the databuffer using the various 'poke' methods, or read using the 'peek' methods.

Свойства

Method Length:Int () Property


Returns the length, in bytes, of the data buffer.

Методы

Method CopyBytes:Void ( srcAddress:Int, dst:DataBuffer, dstAddress:Int, count:Int )


Copies count bytes starting at srcAddress from this buffer to dst.

Method Discard:Void ()


Releases any resources used by the data buffer.

Once discarded, a data buffer should not be used again.

Method PeekByte:Int ( address:Int )


Returns the 8 bit byte contained in the databuffer at address.

Method PeekBytes:Void ( address:Int, bytes:Int[], offset:Int, count:Int )


Copies count bytes starting at address from the databuffer to bytes.

Data is written to bytes starting at index offset.

Method PeekFloat:Float ( address:Int )


Returns the 32 bit float value stored in the data buffer at address.

Method PeekFloats:Void ( address:Int, floats:Float[], offset:Int, count:Int )


Copies count 32 bit floats starting at address from the databuffer to bytes.

Data is written to data starting at index offset.

Method PeekInt:Int ( address:Int )


Returns the 32 bit int value contained in the data buffer at address.

Method PeekInts:Void ( address:Int, ints:Int[], offset:Int, count:Int )


Copies count 32 bit ints starting at address from the databuffer to bytes.

Data is written to ints starting at index offset.

Method PeekShort:Int ( address:Int )


Returns the 16 bit int value contained in the data buffer at address.

Method PeekShorts:Void ( address:Int, shorts:Int[], offset:Int, count:Int )


Copies count 16 bit shorts starting at address from the databuffer to bytes.

Data is written to shorts starting at index offset.

Method PeekString:String ( address:Int, encoding:String="utf8" )


Peeks and returns a string from the data buffer.

Data is read from address up until the end of the data buffer.

The encoding parameter should be one of:

EncodingDescription
"utf8"Unicode
"ascii"8 bit ascii

Method PeekString:String ( address:Int, count:Int, encoding:String="utf8" )


Peeks and returns a string from the data buffer.

Up to count bytes are read from the data buffer starting from address.

The encoding parameter should be one of:

EncodingDescription
"utf8"Unicode
"ascii"8 bit ascii

Method PokeByte:Void ( address:Int, value:Int )


Writes an 8 bit byte into the data buffer at address.

Method PokeBytes:Void ( address:Int, bytes:Int[], offset:Int, count:Int )


Copies count 8 bit bytes from the bytes array to the databuffer.

offset is the starting index within the source array, and address is the starting byte address within the databuffer.

Method PokeFloat:Void ( address:Int, value:Float )


Writes a 32 bit float value into the data buffer at address.

Method PokeFloats:Void ( address:Int, floats:Int[], offset:Int, count:Int )


Copies count 32 bit floats from the floats array to the databuffer.

offset is the starting index within the source array, and address is the starting byte address within the databuffer.

Method PokeInt:Void ( address:Int, value:Int )


Writes a 32 bit int value into the data buffer at address.

Method PokeInts:Void ( address:Int, ints:Int[], offset:Int, count:Int )


Copies count 32 bit ints from the ints array to the databuffer.

offset is the starting index within the source array, and address is the starting byte address within the databuffer.

Method PokeShort:Void ( address:Int, value:Int )


Writes a 16 bit int value into the data buffer at address.

Method PokeShorts:Void ( address:Int, shorts:Int[], offset:Int, count:Int )


Copies count 16 bit shorts from the shorts array to the databuffer.

offset is the starting index within the source array, and address is the starting byte address within the databuffer.

Method PokeString:Int ( address:Int, value:String, encoding:String="utf8" )


Pokes value into the data buffer at location address.

The encoding parameter should be one of:

EncodingDescription
"utf8"Unicode
"ascii"8 bit ascii

Функции

Function Load:DataBuffer ( path:String )


Creates and returns a databuffer containing the binary contents of the specified file.

If the file does not exist or cannot be read, null is returned instead.

См. также
Resource paths

Function LoadAsync:Void ( path:String, onComplete:IOnLoadDataComplete )


Loads a databuffer asynchronously.

When data has finished loading, the OnLoadDataComplete method of the onComplete object is called.

См. также
Resource paths