TStream: | Methods |
TStream extends TIO to provide methods for reading and writing various types of values to and from a stream.
Note that methods dealing with strings - ReadLine, WriteLine, ReadString and WriteString -
assume that strings are represented by bytes in the stream. In future, a more powerful
TextStream type will be added capable of decoding text streams in multiple formats.
ReadBytes | Reads bytes from a stream |
WriteBytes | Writes bytes to a stream |
SkipBytes | Skip bytes in a stream |
ReadByte | Read a byte from the stream |
WriteByte | Write a byte to the stream |
ReadShort | Read a short (two bytes) from the stream |
WriteShort | Write a short (two bytes) to the stream |
ReadInt | Read an int (four bytes) from the stream |
WriteInt | Write an int (four bytes) to the stream |
ReadLong | Read a long (eight bytes) from the stream |
WriteLong | Write a long (eight bytes) to the stream |
ReadFloat | Read a float (four bytes) from the stream |
WriteFloat | Write a float (four bytes) to the stream |
ReadDouble | Read a double (eight bytes) from the stream |
WriteDouble | Write a double (eight bytes) to the stream |
ReadLine | Read a line of text from the stream |
WriteLine | Write a line of text to the stream |
ReadString | Read characters from the stream |
WriteString | Write characters to the stream |
Method ReadBytes( buf:Byte Ptr,count ) | |
Description | Reads bytes from a stream |
Information |
ReadBytes reads count bytes from the stream into the memory block specified by buf.
If count bytes were not successfully read, a TStreamReadException is thrown. This typically occurs due to end of file. |
Method WriteBytes( buf:Byte Ptr,count ) | |
Description | Writes bytes to a stream |
Information |
WriteBytes writes count bytes from the memory block specified by buf to the stream.
If count bytes were not successfully written, a TStreamWriteException is thrown. This typically occurs due to end of file. |
Method SkipBytes( count ) | |
Description | Skip bytes in a stream |
Information |
SkipBytes read count bytes from the stream and throws them away.
If count bytes were not successfully read, a TStreamReadException is thrown. This typically occurs due to end of file. |
Method ReadByte() | |
Returns | The read value |
Description | Read a byte from the stream |
Information | If a value could not be read (possibly due to end of file), a TStreamReadException is thrown. |
Method WriteByte( n ) | |
Description | Write a byte to the stream |
Information | If the value could not be written (possibly due to end of file), a TStreamWriteException is thrown. |
Method ReadShort() | |
Returns | The read value |
Description | Read a short (two bytes) from the stream |
Information | If a value could not be read (possibly due to end of file), a TStreamReadException is thrown. |
Method WriteShort( n ) | |
Description | Write a short (two bytes) to the stream |
Information | If the value could not be written (possibly due to end of file), a TStreamWriteException is thrown. |
Method ReadInt() | |
Returns | The read value |
Description | Read an int (four bytes) from the stream |
Information | If a value could not be read (possibly due to end of file), a TStreamReadException is thrown. |
Method WriteInt( n ) | |
Description | Write an int (four bytes) to the stream |
Information | If the value could not be written (possibly due to end of file), a TStreamWriteException is thrown. |
Method ReadLong:Long() | |
Returns | The read value |
Description | Read a long (eight bytes) from the stream |
Information | If a value could not be read (possibly due to end of file), a TStreamReadException is thrown. |
Method WriteLong( n:Long ) | |
Description | Write a long (eight bytes) to the stream |
Information | If the value could not be written (possibly due to end of file), a TStreamWriteException is thrown. |
Method ReadFloat#() | |
Returns | The read value |
Description | Read a float (four bytes) from the stream |
Information | If a value could not be read (possibly due to end of file), a TStreamReadException is thrown. |
Method WriteFloat( n# ) | |
Description | Write a float (four bytes) to the stream |
Information | If the value could not be written (possibly due to end of file), a TStreamWriteException is thrown. |
Method ReadDouble!() | |
Returns | The read value |
Description | Read a double (eight bytes) from the stream |
Information | If a value could not be read (possibly due to end of file), a TStreamReadException is thrown. |
Method WriteDouble( n! ) | |
Description | Write a double (eight bytes) to the stream |
Information | If the value could not be written (possibly due to end of file), a TStreamWriteException is thrown. |
Method ReadLine$() | |
Description | Read a line of text from the stream |
Information |
Bytes are read from the stream until a newline character (ascii code 10) or null
character (ascii code 0) is read, or end of file is detected.
Carriage return characters (ascii code 13) are silently ignored. The bytes read are returned in the form of a string, excluding any terminating newline or null character. |
Method WriteLine( str$ ) | |
Returns | True if line successfully written, else False |
Description | Write a line of text to the stream |
Information | A sequence of bytes is written to the stream (one for each character in str) followed by the line terminating sequence "rn". |
Method ReadString$( length ) | |
Returns | A string composed of length bytes read from the stream |
Description | Read characters from the stream |
Information | A TStreamReadException is thrown if not all bytes could be read. |
Method WriteString( str$ ) | |
Description | Write characters to the stream |
Information | A TStreamWriteException is thrown if not all bytes could be written. |