This class is a wrapper for writing to a block of bytes.
Public Member Functions | |
Writer () | |
Creates a new writer. This can be as long as you want it to be. More... | |
Writer (Stream stream) | |
Creates a new writer to the given stream. More... | |
Writer (int size) | |
Creates a fixed length writer. It can't write more data than the given number of bytes. More... | |
long | Position () |
Gets the current position the writer is at in the stream. More... | |
void | Seek (long point) |
Seeks to the given position in the stream relative to the start. More... | |
void | Seek (long to, SeekOrigin about) |
Seeks to the given position in the stream. More... | |
void | WriteByte (byte b) |
Writes the given byte to the stream. More... | |
string | Debug () |
Debugs this writer. Returns bytes as text. More... | |
void | WriteCompressed (ulong l) |
Writes a number compressed into the stream, taking a minimum of a single byte. More... | |
void | WriteCompressedSigned (long value) |
Writes an unsigned number compressed into the stream, taking a minimum of a single byte. More... | |
void | WriteInt24 (int number) |
void | WriteInt40 (long number) |
void | WriteInt48 (long number) |
void | WriteInt56 (long number) |
void | WriteUInt24 (uint number) |
void | WriteUInt40 (ulong number) |
void | WriteUInt48 (ulong number) |
void | WriteUInt56 (ulong number) |
override void | Write (string str) |
void | WriteString (string str) |
Writes a string to the stream of any length. More... | |
void | WriteLongString (string str) |
Writes a long string to the stream. Maximum length of 4GB. More... | |
virtual byte[] | GetResult () |
Gets the content written to the stream as a block of bytes. More... | |
void | WriteMessage (Writer writer) |
void | Write (Writer writer) |
void | WriteRange (bool[] data, float value, int start, int count, float min, float max) |
Writes the given floating point value to the given portion of a block of bits. The floating point value is mapped into a range first - between min and max. Note that this does not write the bits to the stream. More... | |
int | WriteRange (float value, int count, float min, float max) |
Maps the given floating point value into a range - between min and max. More... | |
void | WriteToBits (bool[] bits, int input, int start, int length) |
Writes the given input number to the given portion of a block of bits. More... | |
void | WriteBits (bool[] bits) |
Writes the given block of bits to the stream. Must be a multiple of 8. More... | |
void | WriteRoundBits (bool[] bits) |
Writes the given block of bits to the stream. It can be any length. More... | |
int | ReadFromBits (bool[] bits, int start, int length) |
Converts the given portion of a block of bits into an integer. More... | |
void | SeekToEnd () |
Seeks to the end of the stream. More... | |
int | WriteNetHeader (byte type) |
Writes a network header to this writer, returning it's size. More... | |
long | StartPackageUInt16 () |
Starts off a section that has a number representing its size in bytes before it. This size has a maximum of 64kb as it's stored as a ushort. More... | |
void | EndPackageUInt16 (long location) |
Ends a section that has a number representing the sections size in bytes before it. More... | |
long | StartPackageInt32 () |
Starts off a section that has a number representing its size in bytes before it. This size has a maximum of 2GB as it's stored as an int. More... | |
void | EndPackageInt32 (long location) |
Ends a section that has a number representing the sections size in bytes before it. More... | |
void | EndBlock (long location) |
Ends a block noted with the given value from StartBlock. When you call this, you must then write your length value and then call EndBlockLength. More... | |
void | EndBlockLength () |
Call when your done writing the length of a block. See StartBlock. More... | |
long | StartBlock (int byteCount) |
Starts a block. That's a section in the stream of unknown length which must have the length written at the start of it. More... | |
long | Length () |
Gets the current length of the stream. More... | |
void | MapRotation (float rotation) |
Maps a rotation into a single byte then writes it to the stream. More... | |
Static Public Member Functions | |
static int | CompressedSize (ulong l) |
How many bytes the given value would create if written out. More... | |
Static Public Attributes | |
static byte[] | EmptyInt16 =new byte[2] |
A block of bytes that represents 0 as a short. More... | |
static byte[] | EmptyInt32 =new byte[4] |
A block of bytes that represents 0 as an int. More... | |
Package Attributes | |
const byte | NetVerify =69 |
The verification byte. ASCII 'E'. Also in NetworkClient.Message More... | |
|
inline |
Creates a new writer. This can be as long as you want it to be.
|
inline |
Creates a new writer to the given stream.
stream | The stream to write to. |
|
inline |
Creates a fixed length writer. It can't write more data than the given number of bytes.
size | The maximum size of the writer in bytes. |
|
inlinestatic |
How many bytes the given value would create if written out.
|
inline |
Debugs this writer. Returns bytes as text.
|
inline |
Ends a block noted with the given value from StartBlock. When you call this, you must then write your length value and then call EndBlockLength.
location | The value from StartBlock which defines where the block is. |
|
inline |
Call when your done writing the length of a block. See StartBlock.
|
inline |
Ends a section that has a number representing the sections size in bytes before it.
location | The value you received from StartPackageInt32. |
|
inline |
Ends a section that has a number representing the sections size in bytes before it.
location | The value you received from StartPackageUInt16. |
|
inlinevirtual |
Gets the content written to the stream as a block of bytes.
|
inline |
Gets the current length of the stream.
|
inline |
Maps a rotation into a single byte then writes it to the stream.
rotation | The rotation to write (in degrees). |
|
inline |
Gets the current position the writer is at in the stream.
|
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 |
Seeks to the given position in the stream relative to the start.
point | The location to seek to. |
|
inline |
Seeks to the given position in the stream.
to | The location to seek to. |
about | The position that the given location is relative to. |
|
inline |
Seeks to the end of the stream.
|
inline |
Starts a block. That's a section in the stream of unknown length which must have the length written at the start of it.
byteCount | The number of bytes to leave for the length. |
|
inline |
Starts off a section that has a number representing its size in bytes before it. This size has a maximum of 2GB as it's stored as an int.
|
inline |
Starts off a section that has a number representing its size in bytes before it. This size has a maximum of 64kb as it's stored as a ushort.
|
inline |
|
inline |
|
inline |
Writes the given block of bits to the stream. Must be a multiple of 8.
bits | The bits to write. 8 bits are grouped together and written as a byte. |
|
inline |
Writes the given byte to the stream.
b | The byte to write. |
|
inline |
Writes a number compressed into the stream, taking a minimum of a single byte.
l | The number to write. |
|
inline |
Writes an unsigned number compressed into the stream, taking a minimum of a single byte.
value | The number to write. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Writes a long string to the stream. Maximum length of 4GB.
str | The string to write. |
|
inline |
|
inline |
Writes a network header to this writer, returning it's size.
type | The message type. |
header | The header block. |
verify | True if a verification 'E' should be added. |
|
inline |
Writes the given floating point value to the given portion of a block of bits. The floating point value is mapped into a range first - between min and max. Note that this does not write the bits to the stream.
data | The bits that the value will be written to. |
value | The floating point value that will be written. |
start | The starting index in the bit array for this value. |
count | The number of bits this value can take up. More results in higher accuracy. |
min | The minimum value of the range. |
max | The maximum value of the range. |
|
inline |
Maps the given floating point value into a range - between min and max.
value | The floating point value that will be mapped. |
count | The number of bits the mapped value can use. More results in higher accuracy. |
min | The minimum value of the range. |
max | The maximum value of the range. |
|
inline |
Writes the given block of bits to the stream. It can be any length.
bits | The bits to write. 8 bits are grouped together and written as a byte. |
|
inline |
Writes a string to the stream of any length.
str | The string to write. |
|
inline |
Writes the given input number to the given portion of a block of bits.
bits | The bits to write the number to. |
input | The number to write to the bits. |
start | The start location in the bit array to write the number to. |
length | The number of bits to use to write the number to. |
|
inline |
|
inline |
|
inline |
|
inline |
|
static |
A block of bytes that represents 0 as a short.
|
static |
A block of bytes that represents 0 as an int.
|
package |
The verification byte. ASCII 'E'. Also in NetworkClient.Message