Photon Fusion 2.0.4

Public Member Functions | Static Public Member Functions | Properties | List of all members
BitStream Class Reference

BitStream serialization methods. More...

Public Member Functions

delegate void ArrayElementSerializer< T > (ref T element)
 Serialize a value. More...
 
 BitStream ()
 Initializes a new instance of the BitStream class with an empty byte array. More...
 
 BitStream (byte[] arr)
 Initializes a new instance of the BitStream class with the specified byte array. More...
 
 BitStream (byte[] arr, int size)
 Initializes a new instance of the BitStream class with the specified byte array and size. More...
 
 BitStream (Int32 size)
 Initializes a new instance of the BitStream class with a specified size in bytes. More...
 
bool CanRead ()
 Checks if at least one bit can be read from the stream. More...
 
bool CanRead (int bits)
 Checks if the specified number of bits can be read from the stream. More...
 
bool CanWrite ()
 Checks if at least one bit can be written to the stream. More...
 
bool CanWrite (int bits)
 Checks if the specified number of bits can be written to the stream. More...
 
bool Condition (bool condition)
 Evaluates a condition and serializes it if in write mode, or deserializes it if in read mode. More...
 
void CopyFromArray (Byte[] array)
 Copies data from the specified byte array into the internal buffer. More...
 
void Expand ()
 Doubles the capacity of the internal buffer. More...
 
bool ReadBool ()
 Reads a boolean value from the stream. More...
 
bool ReadBoolean ()
 Reads a boolean value from the stream. More...
 
byte ReadByte ()
 Reads a byte value from the stream. More...
 
byte ReadByte (int bits)
 Reads a byte value from the stream with a specified number of bits. More...
 
void ReadByteArray (byte[] to)
 Reads bytes from the stream into the specified byte array. More...
 
void ReadByteArray (byte[] to, int count)
 Reads a specified number of bytes from the stream into the specified byte array. More...
 
void ReadByteArray (byte[] to, int offset, int count)
 Reads a specified number of bytes from the stream into the specified byte array starting at a given offset. More...
 
byte[] ReadByteArray (int size)
 Reads a specified number of bytes from the stream into a new byte array. More...
 
byte[] ReadByteArrayLengthPrefixed ()
 Reads a byte array from the stream with a length prefix. More...
 
Char ReadChar ()
 Reads a character value from the stream. More...
 
double ReadDouble ()
 Reads a 64-bit floating point value from the stream. More...
 
float ReadFloat ()
 Reads a 32-bit floating point value from the stream. More...
 
Guid ReadGuid ()
 Reads a GUID from the stream. More...
 
int ReadInt ()
 Reads a 32-bit integer value from the stream. More...
 
int ReadInt (int bits)
 Reads a 32-bit integer value from the stream with a specified number of bits. More...
 
int ReadInt_Shifted (int bits, int shift)
 Reads a shifted 32-bit integer value from the stream with a specified number of bits. More...
 
long ReadLong ()
 Reads a signed 64-bit integer value from the stream. More...
 
long ReadLong (int bits)
 Reads a signed 64-bit integer value from the stream with a specified number of bits. More...
 
sbyte ReadSByte ()
 Reads a signed byte value from the stream. More...
 
short ReadShort ()
 Reads a short value from the stream. More...
 
short ReadShort (int bits)
 Reads a short value from the stream with a specified number of bits. More...
 
string ReadString ()
 Reads a string from the stream using UTF-8 encoding. More...
 
string ReadString (Encoding encoding)
 Reads a string from the stream using the specified encoding. More...
 
uint ReadUInt ()
 Reads an unsigned 32-bit integer value from the stream. More...
 
uint ReadUInt (int bits)
 Reads an unsigned 32-bit integer value from the stream with a specified number of bits. More...
 
ulong ReadULong ()
 Reads an unsigned 64-bit integer value from the stream. More...
 
ulong ReadULong (int bits)
 Reads an unsigned 64-bit integer value from the stream with a specified number of bits. More...
 
ushort ReadUShort ()
 Reads an unsigned short value from the stream. More...
 
ushort ReadUShort (int bits)
 Reads an unsigned short value from the stream with a specified number of bits. More...
 
void Reset ()
 Resets the internal buffer to its initial state. More...
 
void Reset (Int32 byteSize)
 Resets the internal buffer to the specified size. More...
 
void ResetFast (Int32 byteSize)
 Resets the internal buffer to the specified size without clearing the data. More...
 
int RoundToByte ()
 Rounds the current position to the nearest byte boundary by filling with zero bits if necessary. More...
 
unsafe void Serialize (byte *v)
 Serializes or deserializes a byte value. More...
 
unsafe void Serialize (int *v)
 Serializes or deserializes an integer value. More...
 
unsafe void Serialize (int *v, int bits)
 Serializes or deserializes a 32-bit integer value with a specified number of bits. More...
 
unsafe void Serialize (long *v)
 Serializes or deserializes a 64-bit integer value. More...
 
void Serialize (ref bool value)
 Serializes or deserializes a boolean value. More...
 
void Serialize (ref Byte value)
 Serializes or deserializes a byte value. More...
 
void Serialize (ref Byte[] array, ref Int32 length)
 Serializes or deserializes a byte array with a specified length. More...
 
void Serialize (ref Byte[] array, ref Int32 length, Int32 fixedSize)
 Serializes or deserializes a byte array with a specified length and fixed size. More...
 
void Serialize (ref Byte[] value)
 Serializes or deserializes a byte array with a length prefix. More...
 
void Serialize (ref Byte[] value, Int32 fixedSize)
 Serializes or deserializes a byte array with a fixed size. More...
 
void Serialize (ref Double value)
 Serializes or deserializes a double value. More...
 
void Serialize (ref float value)
 Serializes or deserializes a float value. More...
 
void Serialize (ref int value)
 Serializes or deserializes a 32-bit integer value. More...
 
void Serialize (ref int value, int bits)
 Serializes or deserializes a 32-bit integer value with a specified number of bits. More...
 
void Serialize (ref Int32[] value)
 Serializes or deserializes an array of 32-bit integers. More...
 
void Serialize (ref Int64 value)
 Serializes or deserializes a 64-bit integer value. More...
 
void Serialize (ref String value)
 Serializes or deserializes a string value. More...
 
void Serialize (ref uint value)
 Serializes or deserializes a 32-bit unsigned integer value. More...
 
void Serialize (ref uint value, int bits)
 Serializes or deserializes a 32-bit unsigned integer value with a specified number of bits. More...
 
void Serialize (ref UInt64 value)
 Serializes or deserializes a 64-bit unsigned integer value. More...
 
void Serialize (ref ulong value, int bits)
 Serializes or deserializes a 64-bit unsigned integer value with a specified number of bits. More...
 
unsafe void Serialize (sbyte *v)
 Serializes or deserializes a signed byte value. More...
 
unsafe void Serialize (short *v)
 Serializes or deserializes a short value. More...
 
unsafe void Serialize (uint *v)
 Serializes or deserializes an unsigned 32-bit integer value. More...
 
unsafe void Serialize (uint *v, int bits)
 Serializes or deserializes an unsigned 32-bit integer value with a specified number of bits. More...
 
unsafe void Serialize (ulong *v)
 Serializes or deserializes an unsigned 64-bit integer value. More...
 
unsafe void Serialize (ushort *v)
 Serializes or deserializes an unsigned short value. More...
 
void SerializeArray< T > (ref T[] array, ArrayElementSerializer< T > serializer)
 Serializes or deserializes an array of elements using a specified serializer. More...
 
void SerializeArrayLength< T > (ref T[] array)
 Serializes or deserializes the length of an array. More...
 
unsafe void SerializeBuffer (byte *buffer, int length)
 Serializes or deserializes a buffer of byte values. More...
 
unsafe void SerializeBuffer (int *buffer, int length)
 Serializes or deserializes a buffer of 32-bit integer values. More...
 
unsafe void SerializeBuffer (long *buffer, int length)
 Serializes or deserializes a buffer of 64-bit integer values. More...
 
unsafe void SerializeBuffer (sbyte *buffer, int length)
 Serializes or deserializes a buffer of signed byte values. More...
 
unsafe void SerializeBuffer (short *buffer, int length)
 Serializes or deserializes a buffer of short values. More...
 
unsafe void SerializeBuffer (uint *buffer, int length)
 Serializes or deserializes a buffer of unsigned 32-bit integer values. More...
 
unsafe void SerializeBuffer (ulong *buffer, int length)
 Serializes or deserializes a buffer of unsigned 64-bit integer values. More...
 
unsafe void SerializeBuffer (ushort *buffer, int length)
 Serializes or deserializes a buffer of unsigned short values. More...
 
void SetBuffer (byte[] arr)
 Sets the internal buffer to the specified byte array. More...
 
void SetBuffer (byte[] arr, int size)
 Sets the internal buffer to the specified byte array and size. More...
 
byte[] ToArray ()
 Converts the internal buffer to a byte array. More...
 
bool WriteBool (bool value)
 Writes a boolean value to the stream. More...
 
bool WriteBoolean (bool value)
 Writes a boolean value to the stream. More...
 
void WriteByte (byte value)
 Writes a byte value to the stream. More...
 
void WriteByte (byte value, int bits)
 Writes a byte value to the stream with a specified number of bits. More...
 
void WriteByteArray (byte[] from)
 Writes a byte array to the stream. More...
 
void WriteByteArray (byte[] from, int count)
 Writes a specified number of bytes from a byte array to the stream. More...
 
void WriteByteArray (byte[] from, int offset, int count)
 Writes a specified number of bytes from a byte array to the stream starting at a given offset. More...
 
void WriteByteArrayLengthPrefixed (byte[] array)
 Writes a byte array to the stream with a length prefix. More...
 
void WriteByteArrayLengthPrefixed (byte[] array, int maxLength)
 Writes a byte array to the stream with a length prefix and a specified maximum length. More...
 
void WriteChar (Char value)
 Writes a character value to the stream. More...
 
void WriteDouble (double value)
 Writes a 64-bit floating point value to the stream. More...
 
void WriteFloat (float value)
 Writes a 32-bit floating point value to the stream. More...
 
void WriteGuid (Guid guid)
 Writes a GUID to the stream. More...
 
void WriteInt (int value)
 Writes a 32-bit integer value to the stream. More...
 
void WriteInt (int value, int bits)
 Writes a 32-bit integer value to the stream with a specified number of bits. More...
 
void WriteInt_Shifted (int value, int bits, int shift)
 Writes a shifted 32-bit integer value to the stream with a specified number of bits. More...
 
void WriteLong (long value)
 Writes a signed 64-bit integer value to the stream. More...
 
void WriteLong (long value, int bits)
 Writes a signed 64-bit integer value to the stream with a specified number of bits. More...
 
void WriteSByte (sbyte value)
 Writes a signed byte value to the stream. More...
 
void WriteShort (short value)
 Writes a short value to the stream. More...
 
void WriteShort (short value, int bits)
 Writes a short value to the stream with a specified number of bits. More...
 
void WriteString (string value)
 Writes a string to the stream using UTF-8 encoding. More...
 
void WriteString (string value, Encoding encoding)
 Writes a string to the stream using the specified encoding. More...
 
void WriteUInt (uint value)
 Writes an unsigned 32-bit integer value to the stream. More...
 
void WriteUInt (uint value, int bits)
 Writes an unsigned 32-bit integer value to the stream with a specified number of bits. More...
 
void WriteULong (ulong value)
 Writes an unsigned 64-bit integer value to the stream. More...
 
void WriteULong (ulong value, int bits)
 Writes an unsigned 64-bit integer value to the stream with a specified number of bits. More...
 
void WriteUShort (ushort value)
 Writes an unsigned short value to the stream. More...
 
void WriteUShort (ushort value, int bits)
 Writes an unsigned short value to the stream with a specified number of bits. More...
 

Static Public Member Functions

static void WriteByteAt (byte[] data, int ptr, int bits, byte value)
 Writes a byte value at a specified bit position in a byte array. More...
 

Properties

int BytesRequired [get]
 Size of written buffer in BYTES Ammount of bytes required considering the total of written bytes More...
 
int Capacity [get]
 Total Size in BYTES of the Buffer More...
 
Byte[] Data [get]
 Internal Byte Array More...
 
bool Done [get]
 Signal if the buffer was completely written More...
 
bool IsEvenBytes [get]
 Gets a value indicating whether the current position is at an even byte boundary. More...
 
bool Overflowing [get]
 Signal if the buffer is overflowing More...
 
int Position [get, set]
 Current read/write position in BITS inside the Buffer More...
 
bool Reading [get, set]
 Signal if the Buffer is in Read Mode More...
 
int Size [get, set]
 Total size in BITS of the buffer More...
 
bool Writing [get, set]
 Signal if the Buffer is in Write Mode More...
 

Detailed Description

BitStream serialization methods.

Constructor & Destructor Documentation

◆ BitStream() [1/4]

BitStream ( )

Initializes a new instance of the BitStream class with an empty byte array.

◆ BitStream() [2/4]

BitStream ( Int32  size)

Initializes a new instance of the BitStream class with a specified size in bytes.

Parameters
sizeThe size of the byte array in bytes.

◆ BitStream() [3/4]

BitStream ( byte[]  arr)

Initializes a new instance of the BitStream class with the specified byte array.

Parameters
arrThe byte array to use as the internal buffer.

◆ BitStream() [4/4]

BitStream ( byte[]  arr,
int  size 
)

Initializes a new instance of the BitStream class with the specified byte array and size.

Parameters
arrThe byte array to use as the internal buffer.
sizeThe size of the byte array in bytes.

Member Function Documentation

◆ ArrayElementSerializer< T >()

delegate void ArrayElementSerializer< T > ( ref T  element)

Serialize a value.

Template Parameters
TThe value type.

◆ CanRead() [1/2]

bool CanRead ( )

Checks if at least one bit can be read from the stream.

Returns
True if at least one bit can be read, otherwise false.

◆ CanRead() [2/2]

bool CanRead ( int  bits)

Checks if the specified number of bits can be read from the stream.

Parameters
bitsThe number of bits to check.
Returns
True if the specified number of bits can be read, otherwise false.

◆ CanWrite() [1/2]

bool CanWrite ( )

Checks if at least one bit can be written to the stream.

Returns
True if at least one bit can be written, otherwise false.

◆ CanWrite() [2/2]

bool CanWrite ( int  bits)

Checks if the specified number of bits can be written to the stream.

Parameters
bitsThe number of bits to check.
Returns
True if the specified number of bits can be written, otherwise false.

◆ Condition()

bool Condition ( bool  condition)

Evaluates a condition and serializes it if in write mode, or deserializes it if in read mode.

Parameters
conditionThe condition to evaluate and serialize/deserialize.
Returns
The evaluated condition.

◆ CopyFromArray()

void CopyFromArray ( Byte[]  array)

Copies data from the specified byte array into the internal buffer.

Parameters
arrayThe byte array to copy from.

◆ Expand()

void Expand ( )

Doubles the capacity of the internal buffer.

◆ ReadBool()

bool ReadBool ( )

Reads a boolean value from the stream.

Returns
The boolean value that was read.

◆ ReadBoolean()

bool ReadBoolean ( )

Reads a boolean value from the stream.

Returns
The boolean value that was read.

◆ ReadByte() [1/2]

byte ReadByte ( )

Reads a byte value from the stream.

Returns
The byte value that was read.

◆ ReadByte() [2/2]

byte ReadByte ( int  bits)

Reads a byte value from the stream with a specified number of bits.

Parameters
bitsThe number of bits to read.
Returns
The byte value that was read.

◆ ReadByteArray() [1/4]

void ReadByteArray ( byte[]  to)

Reads bytes from the stream into the specified byte array.

Parameters
toThe byte array to read into.

◆ ReadByteArray() [2/4]

void ReadByteArray ( byte[]  to,
int  count 
)

Reads a specified number of bytes from the stream into the specified byte array.

Parameters
toThe byte array to read into.
countThe number of bytes to read.

◆ ReadByteArray() [3/4]

void ReadByteArray ( byte[]  to,
int  offset,
int  count 
)

Reads a specified number of bytes from the stream into the specified byte array starting at a given offset.

Parameters
toThe byte array to read into.
offsetThe starting offset in the byte array.
countThe number of bytes to read.

◆ ReadByteArray() [4/4]

byte [] ReadByteArray ( int  size)

Reads a specified number of bytes from the stream into a new byte array.

Parameters
sizeThe number of bytes to read.
Returns
A byte array containing the read bytes.

◆ ReadByteArrayLengthPrefixed()

byte [] ReadByteArrayLengthPrefixed ( )

Reads a byte array from the stream with a length prefix.

Returns
A byte array containing the read bytes, or null if the length prefix indicates no data.

◆ ReadChar()

Char ReadChar ( )

Reads a character value from the stream.

Returns
The character value that was read.

◆ ReadDouble()

double ReadDouble ( )

Reads a 64-bit floating point value from the stream.

Returns
The 64-bit floating point value that was read.

◆ ReadFloat()

float ReadFloat ( )

Reads a 32-bit floating point value from the stream.

Returns
The 32-bit floating point value that was read.

◆ ReadGuid()

Guid ReadGuid ( )

Reads a GUID from the stream.

Returns
The GUID that was read.

◆ ReadInt() [1/2]

int ReadInt ( )

Reads a 32-bit integer value from the stream.

Returns
The 32-bit integer value that was read.

◆ ReadInt() [2/2]

int ReadInt ( int  bits)

Reads a 32-bit integer value from the stream with a specified number of bits.

Parameters
bitsThe number of bits to read.
Returns
The 32-bit integer value that was read.

◆ ReadInt_Shifted()

int ReadInt_Shifted ( int  bits,
int  shift 
)

Reads a shifted 32-bit integer value from the stream with a specified number of bits.

Parameters
bitsThe number of bits to read.
shiftThe number of bits to shift.
Returns
The 32-bit integer value that was read.

◆ ReadLong() [1/2]

long ReadLong ( )

Reads a signed 64-bit integer value from the stream.

Returns
The signed 64-bit integer value that was read.

◆ ReadLong() [2/2]

long ReadLong ( int  bits)

Reads a signed 64-bit integer value from the stream with a specified number of bits.

Parameters
bitsThe number of bits to read.
Returns
The signed 64-bit integer value that was read.

◆ ReadSByte()

sbyte ReadSByte ( )

Reads a signed byte value from the stream.

Returns
The signed byte value that was read.

◆ ReadShort() [1/2]

short ReadShort ( )

Reads a short value from the stream.

Returns
The short value that was read.

◆ ReadShort() [2/2]

short ReadShort ( int  bits)

Reads a short value from the stream with a specified number of bits.

Parameters
bitsThe number of bits to read.
Returns
The short value that was read.

◆ ReadString() [1/2]

string ReadString ( )

Reads a string from the stream using UTF-8 encoding.

Returns
The string that was read, or null if the length prefix indicates no data.

◆ ReadString() [2/2]

string ReadString ( Encoding  encoding)

Reads a string from the stream using the specified encoding.

Parameters
encodingThe encoding to use for the string.
Returns
The string that was read, or null if the length prefix indicates no data.

◆ ReadUInt() [1/2]

uint ReadUInt ( )

Reads an unsigned 32-bit integer value from the stream.

Returns
The unsigned 32-bit integer value that was read.

◆ ReadUInt() [2/2]

uint ReadUInt ( int  bits)

Reads an unsigned 32-bit integer value from the stream with a specified number of bits.

Parameters
bitsThe number of bits to read.
Returns
The unsigned 32-bit integer value that was read.

◆ ReadULong() [1/2]

ulong ReadULong ( )

Reads an unsigned 64-bit integer value from the stream.

Returns
The unsigned 64-bit integer value that was read.

◆ ReadULong() [2/2]

ulong ReadULong ( int  bits)

Reads an unsigned 64-bit integer value from the stream with a specified number of bits.

Parameters
bitsThe number of bits to read.
Returns
The unsigned 64-bit integer value that was read.

◆ ReadUShort() [1/2]

ushort ReadUShort ( )

Reads an unsigned short value from the stream.

Returns
The unsigned short value that was read.

◆ ReadUShort() [2/2]

ushort ReadUShort ( int  bits)

Reads an unsigned short value from the stream with a specified number of bits.

Parameters
bitsThe number of bits to read.
Returns
The unsigned short value that was read.

◆ Reset() [1/2]

void Reset ( )

Resets the internal buffer to its initial state.

◆ Reset() [2/2]

void Reset ( Int32  byteSize)

Resets the internal buffer to the specified size.

Parameters
byteSizeThe size in bytes to reset the buffer to.

◆ ResetFast()

void ResetFast ( Int32  byteSize)

Resets the internal buffer to the specified size without clearing the data.

Parameters
byteSizeThe size in bytes to reset the buffer to.

◆ RoundToByte()

int RoundToByte ( )

Rounds the current position to the nearest byte boundary by filling with zero bits if necessary.

Returns
The number of bytes required to store the current position.

◆ Serialize() [1/27]

unsafe void Serialize ( byte *  v)

Serializes or deserializes a byte value.

Parameters
vThe byte value to serialize/deserialize.

◆ Serialize() [2/27]

unsafe void Serialize ( int *  v)

Serializes or deserializes an integer value.

Parameters
vThe integer value to serialize/deserialize.

◆ Serialize() [3/27]

unsafe void Serialize ( int *  v,
int  bits 
)

Serializes or deserializes a 32-bit integer value with a specified number of bits.

Parameters
vThe 32-bit integer value to serialize/deserialize.
bitsThe number of bits to use for serialization/deserialization.

◆ Serialize() [4/27]

unsafe void Serialize ( long *  v)

Serializes or deserializes a 64-bit integer value.

Parameters
vThe 64-bit integer value to serialize/deserialize.

◆ Serialize() [5/27]

void Serialize ( ref bool  value)

Serializes or deserializes a boolean value.

Parameters
valueThe boolean value to serialize/deserialize.

◆ Serialize() [6/27]

void Serialize ( ref Byte  value)

Serializes or deserializes a byte value.

Parameters
valueThe byte value to serialize/deserialize.

◆ Serialize() [7/27]

void Serialize ( ref Byte[]  array,
ref Int32  length 
)

Serializes or deserializes a byte array with a specified length.

Parameters
arrayThe byte array to serialize/deserialize.
lengthThe length of the byte array.

◆ Serialize() [8/27]

void Serialize ( ref Byte[]  array,
ref Int32  length,
Int32  fixedSize 
)

Serializes or deserializes a byte array with a specified length and fixed size.

Parameters
arrayThe byte array to serialize/deserialize.
lengthThe length of the byte array.
fixedSizeThe fixed size of the byte array.

◆ Serialize() [9/27]

void Serialize ( ref Byte[]  value)

Serializes or deserializes a byte array with a length prefix.

Parameters
valueThe byte array to serialize/deserialize.

◆ Serialize() [10/27]

void Serialize ( ref Byte[]  value,
Int32  fixedSize 
)

Serializes or deserializes a byte array with a fixed size.

Parameters
valueThe byte array to serialize/deserialize.
fixedSizeThe fixed size of the byte array.

◆ Serialize() [11/27]

void Serialize ( ref Double  value)

Serializes or deserializes a double value.

Parameters
valueThe double value to serialize/deserialize.

◆ Serialize() [12/27]

void Serialize ( ref float  value)

Serializes or deserializes a float value.

Parameters
valueThe float value to serialize/deserialize.

◆ Serialize() [13/27]

void Serialize ( ref int  value)

Serializes or deserializes a 32-bit integer value.

Parameters
valueThe 32-bit integer value to serialize/deserialize.

◆ Serialize() [14/27]

void Serialize ( ref int  value,
int  bits 
)

Serializes or deserializes a 32-bit integer value with a specified number of bits.

Parameters
valueThe 32-bit integer value to serialize/deserialize.
bitsThe number of bits to use for serialization/deserialization.

◆ Serialize() [15/27]

void Serialize ( ref Int32[]  value)

Serializes or deserializes an array of 32-bit integers.

Parameters
valueThe array of 32-bit integers to serialize/deserialize.

◆ Serialize() [16/27]

void Serialize ( ref Int64  value)

Serializes or deserializes a 64-bit integer value.

Parameters
valueThe 64-bit integer value to serialize/deserialize.

◆ Serialize() [17/27]

void Serialize ( ref String  value)

Serializes or deserializes a string value.

Parameters
valueThe string value to serialize/deserialize.

◆ Serialize() [18/27]

void Serialize ( ref uint  value)

Serializes or deserializes a 32-bit unsigned integer value.

Parameters
valueThe 32-bit unsigned integer value to serialize/deserialize.

◆ Serialize() [19/27]

void Serialize ( ref uint  value,
int  bits 
)

Serializes or deserializes a 32-bit unsigned integer value with a specified number of bits.

Parameters
valueThe 32-bit unsigned integer value to serialize/deserialize.
bitsThe number of bits to use for serialization/deserialization.

◆ Serialize() [20/27]

void Serialize ( ref UInt64  value)

Serializes or deserializes a 64-bit unsigned integer value.

Parameters
valueThe 64-bit unsigned integer value to serialize/deserialize.

◆ Serialize() [21/27]

void Serialize ( ref ulong  value,
int  bits 
)

Serializes or deserializes a 64-bit unsigned integer value with a specified number of bits.

Parameters
valueThe 64-bit unsigned integer value to serialize/deserialize.
bitsThe number of bits to use for serialization/deserialization.

◆ Serialize() [22/27]

unsafe void Serialize ( sbyte *  v)

Serializes or deserializes a signed byte value.

Parameters
vThe signed byte value to serialize/deserialize.

◆ Serialize() [23/27]

unsafe void Serialize ( short *  v)

Serializes or deserializes a short value.

Parameters
vThe short value to serialize/deserialize.

◆ Serialize() [24/27]

unsafe void Serialize ( uint *  v)

Serializes or deserializes an unsigned 32-bit integer value.

Parameters
vThe unsigned 32-bit integer value to serialize/deserialize.

◆ Serialize() [25/27]

unsafe void Serialize ( uint *  v,
int  bits 
)

Serializes or deserializes an unsigned 32-bit integer value with a specified number of bits.

Parameters
vThe unsigned 32-bit integer value to serialize/deserialize.
bitsThe number of bits to use for serialization/deserialization.

◆ Serialize() [26/27]

unsafe void Serialize ( ulong *  v)

Serializes or deserializes an unsigned 64-bit integer value.

Parameters
vThe unsigned 64-bit integer value to serialize/deserialize.

◆ Serialize() [27/27]

unsafe void Serialize ( ushort *  v)

Serializes or deserializes an unsigned short value.

Parameters
vThe unsigned short value to serialize/deserialize.

◆ SerializeArray< T >()

void SerializeArray< T > ( ref T[]  array,
ArrayElementSerializer< T >  serializer 
)

Serializes or deserializes an array of elements using a specified serializer.

Template Parameters
TThe type of the array elements.
Parameters
arrayThe array to serialize/deserialize.
serializerThe serializer to use for each element.

◆ SerializeArrayLength< T >()

void SerializeArrayLength< T > ( ref T[]  array)

Serializes or deserializes the length of an array.

Template Parameters
TThe type of the array elements.
Parameters
arrayThe array whose length to serialize/deserialize.

◆ SerializeBuffer() [1/8]

unsafe void SerializeBuffer ( byte *  buffer,
int  length 
)

Serializes or deserializes a buffer of byte values.

Parameters
bufferThe buffer of byte values to serialize/deserialize.
lengthThe length of the buffer.

◆ SerializeBuffer() [2/8]

unsafe void SerializeBuffer ( int *  buffer,
int  length 
)

Serializes or deserializes a buffer of 32-bit integer values.

Parameters
bufferThe buffer of 32-bit integer values to serialize/deserialize.
lengthThe length of the buffer.

◆ SerializeBuffer() [3/8]

unsafe void SerializeBuffer ( long *  buffer,
int  length 
)

Serializes or deserializes a buffer of 64-bit integer values.

Parameters
bufferThe buffer of 64-bit integer values to serialize/deserialize.
lengthThe length of the buffer.

◆ SerializeBuffer() [4/8]

unsafe void SerializeBuffer ( sbyte *  buffer,
int  length 
)

Serializes or deserializes a buffer of signed byte values.

Parameters
bufferThe buffer of signed byte values to serialize/deserialize.
lengthThe length of the buffer.

◆ SerializeBuffer() [5/8]

unsafe void SerializeBuffer ( short *  buffer,
int  length 
)

Serializes or deserializes a buffer of short values.

Parameters
bufferThe buffer of short values to serialize/deserialize.
lengthThe length of the buffer.

◆ SerializeBuffer() [6/8]

unsafe void SerializeBuffer ( uint *  buffer,
int  length 
)

Serializes or deserializes a buffer of unsigned 32-bit integer values.

Parameters
bufferThe buffer of unsigned 32-bit integer values to serialize/deserialize.
lengthThe length of the buffer.

◆ SerializeBuffer() [7/8]

unsafe void SerializeBuffer ( ulong *  buffer,
int  length 
)

Serializes or deserializes a buffer of unsigned 64-bit integer values.

Parameters
bufferThe buffer of unsigned 64-bit integer values to serialize/deserialize.
lengthThe length of the buffer.

◆ SerializeBuffer() [8/8]

unsafe void SerializeBuffer ( ushort *  buffer,
int  length 
)

Serializes or deserializes a buffer of unsigned short values.

Parameters
bufferThe buffer of unsigned short values to serialize/deserialize.
lengthThe length of the buffer.

◆ SetBuffer() [1/2]

void SetBuffer ( byte[]  arr)

Sets the internal buffer to the specified byte array.

Parameters
arrThe byte array to use as the internal buffer.

◆ SetBuffer() [2/2]

void SetBuffer ( byte[]  arr,
int  size 
)

Sets the internal buffer to the specified byte array and size.

Parameters
arrThe byte array to use as the internal buffer.
sizeThe size of the byte array in bytes.

◆ ToArray()

byte [] ToArray ( )

Converts the internal buffer to a byte array.

Returns
A byte array containing the data in the internal buffer.

◆ WriteBool()

bool WriteBool ( bool  value)

Writes a boolean value to the stream.

Parameters
valueThe boolean value to write.
Returns
The boolean value that was written.

◆ WriteBoolean()

bool WriteBoolean ( bool  value)

Writes a boolean value to the stream.

Parameters
valueThe boolean value to write.
Returns
The boolean value that was written.

◆ WriteByte() [1/2]

void WriteByte ( byte  value)

Writes a byte value to the stream.

Parameters
valueThe byte value to write.

◆ WriteByte() [2/2]

void WriteByte ( byte  value,
int  bits 
)

Writes a byte value to the stream with a specified number of bits.

Parameters
valueThe byte value to write.
bitsThe number of bits to write.

◆ WriteByteArray() [1/3]

void WriteByteArray ( byte[]  from)

Writes a byte array to the stream.

Parameters
fromThe byte array to write.

◆ WriteByteArray() [2/3]

void WriteByteArray ( byte[]  from,
int  count 
)

Writes a specified number of bytes from a byte array to the stream.

Parameters
fromThe byte array to write from.
countThe number of bytes to write.

◆ WriteByteArray() [3/3]

void WriteByteArray ( byte[]  from,
int  offset,
int  count 
)

Writes a specified number of bytes from a byte array to the stream starting at a given offset.

Parameters
fromThe byte array to write from.
offsetThe starting offset in the byte array.
countThe number of bytes to write.

◆ WriteByteArrayLengthPrefixed() [1/2]

void WriteByteArrayLengthPrefixed ( byte[]  array)

Writes a byte array to the stream with a length prefix.

Parameters
arrayThe byte array to write.

◆ WriteByteArrayLengthPrefixed() [2/2]

void WriteByteArrayLengthPrefixed ( byte[]  array,
int  maxLength 
)

Writes a byte array to the stream with a length prefix and a specified maximum length.

Parameters
arrayThe byte array to write.
maxLengthThe maximum length of the byte array to write.

◆ WriteByteAt()

static void WriteByteAt ( byte[]  data,
int  ptr,
int  bits,
byte  value 
)
static

Writes a byte value at a specified bit position in a byte array.

Parameters
dataThe byte array to write to.
ptrThe bit position to start writing at.
bitsThe number of bits to write.
valueThe byte value to write.

◆ WriteChar()

void WriteChar ( Char  value)

Writes a character value to the stream.

Parameters
valueThe character value to write.

◆ WriteDouble()

void WriteDouble ( double  value)

Writes a 64-bit floating point value to the stream.

Parameters
valueThe 64-bit floating point value to write.

◆ WriteFloat()

void WriteFloat ( float  value)

Writes a 32-bit floating point value to the stream.

Parameters
valueThe 32-bit floating point value to write.

◆ WriteGuid()

void WriteGuid ( Guid  guid)

Writes a GUID to the stream.

Parameters
guidThe GUID to write.

◆ WriteInt() [1/2]

void WriteInt ( int  value)

Writes a 32-bit integer value to the stream.

Parameters
valueThe 32-bit integer value to write.

◆ WriteInt() [2/2]

void WriteInt ( int  value,
int  bits 
)

Writes a 32-bit integer value to the stream with a specified number of bits.

Parameters
valueThe 32-bit integer value to write.
bitsThe number of bits to write.

◆ WriteInt_Shifted()

void WriteInt_Shifted ( int  value,
int  bits,
int  shift 
)

Writes a shifted 32-bit integer value to the stream with a specified number of bits.

Parameters
valueThe 32-bit integer value to write.
bitsThe number of bits to write.
shiftThe number of bits to shift.

◆ WriteLong() [1/2]

void WriteLong ( long  value)

Writes a signed 64-bit integer value to the stream.

Parameters
valueThe signed 64-bit integer value to write.

◆ WriteLong() [2/2]

void WriteLong ( long  value,
int  bits 
)

Writes a signed 64-bit integer value to the stream with a specified number of bits.

Parameters
valueThe signed 64-bit integer value to write.
bitsThe number of bits to write.

◆ WriteSByte()

void WriteSByte ( sbyte  value)

Writes a signed byte value to the stream.

Parameters
valueThe signed byte value to write.

◆ WriteShort() [1/2]

void WriteShort ( short  value)

Writes a short value to the stream.

Parameters
valueThe short value to write.

◆ WriteShort() [2/2]

void WriteShort ( short  value,
int  bits 
)

Writes a short value to the stream with a specified number of bits.

Parameters
valueThe short value to write.
bitsThe number of bits to write.

◆ WriteString() [1/2]

void WriteString ( string  value)

Writes a string to the stream using UTF-8 encoding.

Parameters
valueThe string to write.

◆ WriteString() [2/2]

void WriteString ( string  value,
Encoding  encoding 
)

Writes a string to the stream using the specified encoding.

Parameters
valueThe string to write.
encodingThe encoding to use for the string.

◆ WriteUInt() [1/2]

void WriteUInt ( uint  value)

Writes an unsigned 32-bit integer value to the stream.

Parameters
valueThe unsigned 32-bit integer value to write.

◆ WriteUInt() [2/2]

void WriteUInt ( uint  value,
int  bits 
)

Writes an unsigned 32-bit integer value to the stream with a specified number of bits.

Parameters
valueThe unsigned 32-bit integer value to write.
bitsThe number of bits to write.

◆ WriteULong() [1/2]

void WriteULong ( ulong  value)

Writes an unsigned 64-bit integer value to the stream.

Parameters
valueThe unsigned 64-bit integer value to write.

◆ WriteULong() [2/2]

void WriteULong ( ulong  value,
int  bits 
)

Writes an unsigned 64-bit integer value to the stream with a specified number of bits.

Parameters
valueThe unsigned 64-bit integer value to write.
bitsThe number of bits to write.

◆ WriteUShort() [1/2]

void WriteUShort ( ushort  value)

Writes an unsigned short value to the stream.

Parameters
valueThe unsigned short value to write.

◆ WriteUShort() [2/2]

void WriteUShort ( ushort  value,
int  bits 
)

Writes an unsigned short value to the stream with a specified number of bits.

Parameters
valueThe unsigned short value to write.
bitsThe number of bits to write.

Property Documentation

◆ BytesRequired

int BytesRequired
get

Size of written buffer in BYTES Ammount of bytes required considering the total of written bytes

◆ Capacity

int Capacity
get

Total Size in BYTES of the Buffer

◆ Data

Byte [] Data
get

Internal Byte Array

◆ Done

bool Done
get

Signal if the buffer was completely written

◆ IsEvenBytes

bool IsEvenBytes
get

Gets a value indicating whether the current position is at an even byte boundary.

◆ Overflowing

bool Overflowing
get

Signal if the buffer is overflowing

◆ Position

int Position
getset

Current read/write position in BITS inside the Buffer

◆ Reading

bool Reading
getset

Signal if the Buffer is in Read Mode

◆ Size

int Size
getset

Total size in BITS of the buffer

◆ Writing

bool Writing
getset

Signal if the Buffer is in Write Mode