This class is a wrapper for any block of bytes. It allows values to be read from the stream one at a time. Works best with streams created by BinaryIO.Writer.
Public Member Functions | |
| Reader (Stream stream) | |
| Creates a new reader for the given stream. More... | |
| Reader (byte[] src) | |
| Creates a new reader for the given block of bytes. More... | |
| byte[] | ReadImageBytes () |
| Reads the bytes of a texture from the stream. More... | |
| void | Skip (int count) |
| int | PeekByte () |
| Gets the value of the next byte in the stream. More... | |
| virtual long | MarkStart () |
| The current starting location. More... | |
| long | PackedInt () |
| Reads a packed integer from the stream. Not the opposite of More... | |
| float | ReadInt16F (float low, float width) |
| Reads a compressed floating point value from the stream. Compressed floats are stored as a ushort. Their value represents a percentage of a range (i.e. it gets divided by the max ushort value 64k), where 64k = 100% (the top of the range, low + width). More... | |
| ulong | ReadUInt48 () |
| ulong | ReadUInt40 () |
| long | ReadInt40 () |
| uint | ReadUInt24 () |
| Reads a 3 byte unsigned integer from the stream. More... | |
| int | ReadInt24 () |
| Reads a 3 byte integer from the stream. More... | |
| ulong | ReadCompressed () |
| Reads a compressed integer - the opposite of Writer.WriteCompressed. More... | |
| long | ReadCompressedSigned () |
| Reads a signed compressed number. More... | |
| override string | ReadString () |
| Reads a string from the stream; it has no length limit. More... | |
| string | ReadString (int length) |
| Reads a string with the given length from the stream. More... | |
| string | ReadZeroString () |
| Reads a string that is terminated with the null character. No length limit but slower to read. More... | |
| string | ReadLongString () |
| Reads a long string from the stream. Maximum length of 2GB. More... | |
| float | ReadRange (bool[] data, int start, int count, float min, float max) |
| Reverses Writer.WriteRange. Converts a compressed float stored in a block of bits back into a floating point. More... | |
| float | ReadRange (int value, int valueMax, float min, float max) |
| Reverses Writer.WriteRange. Converts a compressed float back into a floating point. More... | |
| float | UnmapRotation () |
| Unmaps a single byte rotation. More... | |
| long | BytesLeft () |
| Gets how many bytes are left in this stream, if it can be known. More... | |
| bool | More (int manyMore) |
| Checks if there are at least the given number of bytes more in this stream. More... | |
| bool | More () |
| Checks if there are any more bytes in this stream. More... | |
| long | GetPosition () |
| Gets the current position in the stream this reader is at. More... | |
| bool[] | ReadBitsFrom (byte byteValue) |
| Reads the bits from the given byte as a block of booleans. More... | |
| int | ReadFromBits (bool[] bits) |
| Converts the given block of bits into an integer. More... | |
| int | ReadFromBits (bool[] bits, int start, int length) |
| Converts the given portion of a block of bits into an integer. More... | |
| bool[] | ReadBits (int bytes) |
| Reads the given number of bytes from the stream into a set of bits. More... | |
| void | Seek (long to) |
| void | Seek (int to, SeekOrigin origin) |
| Seek the stream to the given location. More... | |
Static Public Member Functions | |
| static int | ValueMax (int bitCount) |
| Returns the maximum number that x bits can hold. More... | |
| static int | CompressedSize (ulong l) |
| How many bytes the given value would create if written out. More... | |
Public Attributes | |
| long | Length |
| The length of the stream. More... | |
Static Public Attributes | |
| static Encoding | TextEncoding =Encoding.UTF8 |
| The text encoding in use. More... | |
Properties | |
| virtual int | DataIndex [get] |
| The current data index. More... | |
| bool | IsMore [get] |
| Checks if there are any more bytes in this stream. More... | |
| long | Position [get, set] |
|
inline |
Creates a new reader for the given stream.
| stream | A stream to read from. |
|
inline |
Creates a new reader for the given block of bytes.
| src | The source block of bytes to read from. |
|
inline |
Gets how many bytes are left in this stream, if it can be known.
|
inlinestatic |
How many bytes the given value would create if written out.
|
inline |
Gets the current position in the stream this reader is at.
|
inlinevirtual |
The current starting location.
|
inline |
Checks if there are at least the given number of bytes more in this stream.
|
inline |
Checks if there are any more bytes in this stream.
|
inline |
Reads a packed integer from the stream. Not the opposite of
|
inline |
Gets the value of the next byte in the stream.
|
inline |
Reads the given number of bytes from the stream into a set of bits.
| bytes | The number of bytes to read from the stream. |
|
inline |
Reads the bits from the given byte as a block of booleans.
| byteValue | The byte to read the bits from. |
|
inline |
Reads a compressed integer - the opposite of Writer.WriteCompressed.
|
inline |
Reads a signed compressed number.
|
inline |
Converts the given block of bits into an integer.
| bits | The bits to read from. The highest index is the lowest bit. |
|
inline |
Converts the given portion of a block of bits into an integer.
| bits | The bits to read from. The highest index is the lowest bit. |
| start | The index of where to start. This is the location of the highest bit of the value. |
| length | How many bits represent this value. |
|
inline |
Reads the bytes of a texture from the stream.
|
inline |
Reads a compressed floating point value from the stream. Compressed floats are stored as a ushort. Their value represents a percentage of a range (i.e. it gets divided by the max ushort value 64k), where 64k = 100% (the top of the range, low + width).
| low | The bottom of the float range this was compressed into. |
| width | This value is high-low; the width of the range. |
|
inline |
Reads a 3 byte integer from the stream.
|
inline |
|
inline |
Reads a long string from the stream. Maximum length of 2GB.
|
inline |
Reverses Writer.WriteRange. Converts a compressed float stored in a block of bits back into a floating point.
| data | The bits the value is held in. |
| start | The starting bit index. |
| count | The number of bits the value is stored in. |
| min | The minimum value of the range. |
| max | The maximum value of the range. |
|
inline |
Reverses Writer.WriteRange. Converts a compressed float back into a floating point.
| value | The compressed float. |
| valueMax | The maximum number that value can be. |
| min | The minimum value of the range. |
| max | The maximum value of the range. |
|
inline |
Reads a string from the stream; it has no length limit.
|
inline |
Reads a string with the given length from the stream.
| length | The length of the string. |
|
inline |
Reads a 3 byte unsigned integer from the stream.
|
inline |
|
inline |
|
inline |
Reads a string that is terminated with the null character. No length limit but slower to read.
|
inline |
|
inline |
Seek the stream to the given location.
| to | The location to seek to. |
| origin | Where your location is relative to. |
|
inline |
|
inline |
Unmaps a single byte rotation.
|
inlinestatic |
Returns the maximum number that x bits can hold.
| bitCount | The number of bits. |
| long BinaryIO.Reader.Length |
The length of the stream.
|
static |
The text encoding in use.
|
get |
The current data index.
|
get |
Checks if there are any more bytes in this stream.
|
getset |