3rd Eye Scene C#
3rd Eye Scene C# documentation
|
The StreamReader
supports reading and decoding of a data stream into T:PacketBuffer packets.
More...
Public Member Functions | |
PacketStreamReader (Stream baseStream) | |
Create a Tes stream reader around the given baseStream . | |
override void | Flush () |
Flush the collation buffer and the underlying stream. | |
override int | Read (byte[] buffer, int offset, int count) |
Read directly from the stream. | |
override long | Seek (long offset, SeekOrigin origin) |
Seek to position in the stream. | |
override void | SetLength (long value) |
Not supported. | |
override void | Write (byte[] buffer, int offset, int count) |
Not supported. | |
void | Reset () |
Reset to the start of the stream. | |
PacketBuffer | NextPacket (ref long processedBytes) |
Read the next T:PacketBuffer from the stream. | |
Protected Member Functions | |
void | Reset (long streamPosition) |
Reset the stream to the given seekable position. | |
Properties | |
Stream | BaseStream [get, set] |
Access the underlying Stream . | |
bool | EndOfStream [get, set] |
True when the end of the stream has been reached. | |
bool | DecodingCollated [get] |
True while in the middle of decoding a collated packet. | |
override bool | CanRead [get] |
false | |
override bool | CanSeek [get] |
false | |
override bool | CanWrite [get] |
false | |
override long | Length [get] |
Returns the number of bytes written plus the outstanding buffered bytes. | |
override long | Position [get, set] |
Get/set the number of bytes written plus the outstanding buffered bytes. |
The StreamReader
supports reading and decoding of a data stream into T:PacketBuffer packets.
The reader supports reading from a stream and decoding uncompressed T:PacketBuffer data, packets in T:CollatedPacket messages, both compressed and uncompressed, and data compressed using GZip compression.
The algorithm supports the BaseStream being a GZip encoded stream part way through, separate to the contents of a T:CollatedPacket. If the stream is compressed, then it can no longer seek, but can reset to the beginning, so long as the BaseStream supports seeking.
Compression of the overall stream and in T:CollatedPacket messages is redundant.
Tes::IO::PacketStreamReader::PacketStreamReader | ( | Stream | baseStream | ) | [inline] |
Create a Tes stream reader around the given baseStream .
baseStream | The underlying stream to reader from. |
The baseStream should generally be a FileStream
.
PacketBuffer Tes::IO::PacketStreamReader::NextPacket | ( | ref long | processedBytes | ) | [inline] |
Read the next T:PacketBuffer from the stream.
processedBytes | Incremented by the number of bytes read from the stream. See remarks. |
The next packet is returned first from the current T:CollatedPacketDecoder if possible. Otherwise packet data are read from the stream and decoded as required. The processedBytes value is only adjusted when data are read from the stream, not when a packet is extracted from the collation buffer.
override int Tes::IO::PacketStreamReader::Read | ( | byte[] | buffer, |
int | offset, | ||
int | count | ||
) | [inline] |
Read directly from the stream.
Preferred usage is NextPacket(ref long).
buffer | Buffer to read into. |
offset | Offset into buffer to read into. |
count | Number of bytes to read. |
void Tes::IO::PacketStreamReader::Reset | ( | long | streamPosition | ) | [inline, protected] |
Reset the stream to the given seekable position.
Provides common code to Reset() and Seek(long, SeekOrigin).
streamPosition | The stream position to set. Must be a valid seekable position for the current stream. |
See class comments on seeking.
override long Tes::IO::PacketStreamReader::Seek | ( | long | offset, |
SeekOrigin | origin | ||
) | [inline] |
Seek to position in the stream.
See class remarks on seeking support.
offset | Byte offset from origin to seek to. |
origin | Location to seek relative to. |
Seeking to the beginning of the stream is equivalent to calling Reset().
override void Tes::IO::PacketStreamReader::SetLength | ( | long | value | ) | [inline] |
Not supported.
value | Ignored. |
override void Tes::IO::PacketStreamReader::Write | ( | byte[] | buffer, |
int | offset, | ||
int | count | ||
) | [inline] |
Not supported.
buffer | Ignored. |
offset | Ignored. |
count | Ignored. |
override bool Tes::IO::PacketStreamReader::CanRead [get] |
false
override bool Tes::IO::PacketStreamReader::CanSeek [get] |
false
override bool Tes::IO::PacketStreamReader::CanWrite [get] |
false
override long Tes::IO::PacketStreamReader::Position [get, set] |
Get/set the number of bytes written plus the outstanding buffered bytes.
Seeking is only supported for uncompressed streams. Also, it is recommended that the position only be set to the start of an uncompressed T:PacketHeader.
Setting the position to zero is equivalent to calling Reset().