3rd Eye Scene C#
3rd Eye Scene C# documentation
Tes::IO::PacketStreamReader Class Reference

The StreamReader supports reading and decoding of a data stream into T:PacketBuffer packets. More...

List of all members.

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.

Detailed Description

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.


Constructor & Destructor Documentation

Tes::IO::PacketStreamReader::PacketStreamReader ( Stream  baseStream) [inline]

Create a Tes stream reader around the given baseStream .

Parameters:
baseStreamThe underlying stream to reader from.

The baseStream should generally be a FileStream.


Member Function Documentation

PacketBuffer Tes::IO::PacketStreamReader::NextPacket ( ref long  processedBytes) [inline]

Read the next T:PacketBuffer from the stream.

Returns:
The next packet extracted from the stream.
Parameters:
processedBytesIncremented 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).

Returns:
The number of bytes read. Zero at the end of the stream
Parameters:
bufferBuffer to read into.
offsetOffset into buffer to read into.
countNumber 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).

Parameters:
streamPositionThe 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.

Returns:
The new position in the stream.
Parameters:
offsetByte offset from origin to seek to.
originLocation 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.

Parameters:
valueIgnored.
override void Tes::IO::PacketStreamReader::Write ( byte[]  buffer,
int  offset,
int  count 
) [inline]

Not supported.

Returns:
N/A
Parameters:
bufferIgnored.
offsetIgnored.
countIgnored.

Property Documentation

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


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Enumerations Properties Events