Cerberus X Documentation

Class DataStream

A datastream allows you to read and write data to and from a databuffer in a stream-like way. More...

Declarations

Extends
Stream Streams are used to read or write data in a sequential manner.
Properties
Data : DataBuffer () Returns the databuffer object wrapped by this datastream.
Length : Int () Returns the length of the data in the databuffer object wrapped by this datastream.
Offset : Int () Returns the start offset of the data in the databuffer object wrapped by this datastream.
Constructors
New ( data:DataBuffer, offset:Int, length:Int ) Creates a datastream that wraps the specified databuffer.
New ( data:DataBuffer, offset:Int=0 ) Creates a datastream that wraps the specified databuffer.
Inherited Properties
Eof : Int () Returns 1 if end-of-file has been reached, -1 if an IO error has occurred or 0 if the stream can be read.
Position : Int () Returns the read/write position within the stream if the stream is seekable, else 0.
Inherited Methods
Close : Void () Closes the stream and released any OS resources in use.
Read : Int ( buffer:DataBuffer, offset:Int, count:Int ) Reads count bytes from the stream into databuffer, starting at address offset within the databuffer.
ReadAll : DataBuffer () Reads all remaining bytes from the stream into a databuffer.
ReadAll : Void ( buffer:DataBuffer, offset:Int, count:Int ) Reads count bytes from the stream into databuffer, starting at address offset within the databuffer.
ReadByte : Int () Reads an 8 bit byte from the stream.
ReadFloat : Float () Reads a 32 bit float value from the stream.
ReadInt : Int () Reads a 32 bit int value from the stream.
ReadShort : Int () Reads a 16 bit int value from the stream.
ReadString : String ( count:Int, encoding:String="utf8" ) Reads count bytes from the stream and converts them to a string using the given encoding.
ReadString : String ( encoding:String="utf8" ) Reads all bytes from the stream until end-of-file and converts them to a string using the given encoding.
Seek : Int ( position:Int ) If the stream is seekable, adjusts the read/write position within the stream and returns the new read/write position.
Write : Int ( buffer:DataBuffer, offset:Int, count:Int ) Writes count bytes from databuffer to the stream, starting at address offset within the databuffer.
WriteAll : Void ( buffer:DataBuffer, offset:Int, count:Int ) Writes count bytes from databuffer to the stream, starting at address offset within the databuffer.
WriteByte : Void ( value:Int ) Writes an 8 bit byte to the stream.
WriteFloat : Void ( value:Float ) Writes a 32 bit float value to the stream.
WriteInt : Void ( value:Int ) Writes a 32 bit int value to the stream.
WriteShort : Void ( value:Int ) Write a 16 bit int value to the stream.
WriteString : Void ( value:String, encoding:String="utf8" ) Writes a string to the stream using the given encoding.

Detailed Discussion

A datastream allows you to read and write data to and from a databuffer in a stream-like way.


Properties Documentation

Method Data : DataBuffer () Property

Returns the databuffer object wrapped by this datastream.

Method Length : Int () Property

Returns the length of the data in the databuffer object wrapped by this datastream.

Method Offset : Int () Property

Returns the start offset of the data in the databuffer object wrapped by this datastream.


Constructors Documentation

Method New ( data:DataBuffer, offset:Int, length:Int )

Creates a datastream that wraps the specified databuffer.

The wrapped range of data begins at byte address offset and extends for length bytes. Data outside of this range will not be modified by any stream operations.

Method New ( data:DataBuffer, offset:Int=0 )

Creates a datastream that wraps the specified databuffer.

The wrapped range of data begins at byte address offset and extends to the end of the buffer. Data outside this range will not be modified by any stream operations.