Skip to main content

StreamReader

A class in Alta.Serialization.Runtime, Alta.Serialization.

A Stream that reads bits from a uint buffer. Used on both sides to read network messages and saves; the same serialize calls that write with StreamWriter read with this.

Constructors​

MemberWhat it is
StreamReader(Func<uint[], uint[]> getMoreData, int byteCount)Creates a StreamReader with default values.
StreamReader(uint[] data, int byteCount)Creates a StreamReader with default values.
1 private and internal constructor
MemberWhat it is
private StreamReader()Creates a StreamReader with default values.

Fields​

2 private and internal fields
MemberWhat it is
private BitReader readerThe underlying bit reader.
private static byte[] stringBufferStatic shared buffer for string reads, doubled when a string is bigger. Not thread safe.

Properties​

MemberWhat it is
override uint BitIndex { get; }Number of bits read so far.
bool IsFinished { get; }True once fewer than 8 bits are left to read.
override uint TotalByteCount { get; }Size of the data in bytes.

Methods​

MemberWhat it is
override void Align()Skips to the next byte boundary.
override void BackTrack(uint bitCount)Moves the read position back by the given number of bits.
override object Clone()Returns a new reader over a copy of this reader's state.
override void Dispose()Clears the bit reader and drops it. The reader can't be used afterwards.
void Initialize(uint[] data, int newSize)Points the reader at a new buffer and byte count.
void Reset()Moves the read position back to the start.
override void SerializeBits(ref uint value, int bitCount)Reads the given number of bits into the value.
override void SerializeString(ref string value, Stream.StringEncoding encoding = 0)Reads a 16-bit length then that many aligned bytes, decoded as ASCII or UTF-8.
byte[] ToBytes()Copies the whole buffer out as a byte array.
protected override void Finalize()Destructor: calls Dispose if it hasn't run.
protected override void SerializeBytes(byte[] value, int byteCount)Reads raw bytes into the array.

Used in​

Members of other types that take, return or hold a StreamReader: