Photon Quantum 3.0.0

Public Member Functions | Properties | List of all members
Quantum.ByteStream Class Reference

The byte stream is a class to serialize and deserialize byte-wise data. It's mostly used by Quantum asset serialization and deserialization. The data is stored inside a byte array internally. More...

Inherits IDisposable.

Public Member Functions

 ByteStream ()
 Create a byte stream with the default buffer length and default size. More...
 
 ByteStream (Byte[] data)
 Create a byte stream with a given data array. More...
 
 ByteStream (int capacity)
 Create a byte stream with a given capacity. More...
 
void Dispose ()
 Dispose the byte stream. More...
 
ByteStream Duplicate ()
 Duplicate the stream. More...
 
int Read7BitEncodedInt ()
 Read an integer in compressed format from the byte stream. More...
 
Boolean ReadBool ()
 Reads and returns a bool from the byte stream. More...
 
Byte ReadByte ()
 Read a byte from the byte stream. More...
 
Byte[] ReadByteArray ()
 Read a byte array from the byte stream. More...
 
Char ReadChar ()
 Read a char from the byte stream. More...
 
Guid ReadGuid ()
 Read a Guid from the byte stream. More...
 
Int32 ReadInt ()
 Read an integer from the byte stream. More...
 
Int64 ReadLong ()
 Read a long from the byte stream. More...
 
SByte ReadSByte ()
 Read a signed byte from the byte stream. More...
 
Int16 ReadShort ()
 Read a short from the byte stream. More...
 
UInt32 ReadUInt ()
 Read an unsigned short from the byte stream. More...
 
UInt64 ReadULong ()
 Read an unsigned long from the byte stream. More...
 
UInt16 ReadUShort ()
 Read an unsigned short from the byte stream. More...
 
void Reset ()
 Reset the stream and clear More...
 
Byte[] ToArray ()
 Create a copy of the underlying data array. More...
 
void Write7BitEncodedInt (int value)
 Writes an integer in a compressed format to the byte stream. More...
 
Boolean WriteBool (Boolean value)
 Write a bool to the byte stream. More...
 
void WriteByte (Byte value)
 Write a byte to the byte stream. More...
 
void WriteByteArray (Byte[] bytes)
 Write a byte array to the byte stream. More...
 
void WriteByteArray (Byte[] bytes, Int32 offset, Int32 count)
 Write a byte array to the byte stream. More...
 
void WriteChar (Char value)
 Write a char to the byte stream. More...
 
void WriteGuid (Guid guid)
 Write a Guid to the byte stream. More...
 
void WriteInt (Int32 value)
 Write an integer to the byte stream. More...
 
void WriteLong (Int64 value)
 Write a long to the byte stream. More...
 
void WriteSByte (SByte value)
 Write a singed byte to the byte stream. More...
 
void WriteShort (Int16 value)
 Write a short to the byte stream. More...
 
void WriteUInt (UInt32 value)
 Write an unsigned integer to the byte stream. More...
 
void WriteULong (UInt64 value)
 Write an unsigned long to the byte stream. More...
 
void WriteUShort (UInt16 value)
 Write a unsigned short to the byte stream. More...
 

Properties

Byte[] Data [get, set]
 Get or set the underlying data array. More...
 
Int32 Position [get, set]
 Get or set the current position in the stream. More...
 

Detailed Description

The byte stream is a class to serialize and deserialize byte-wise data. It's mostly used by Quantum asset serialization and deserialization. The data is stored inside a byte array internally.

Constructor & Destructor Documentation

◆ ByteStream() [1/3]

Quantum.ByteStream.ByteStream ( Byte[]  data)
inline

Create a byte stream with a given data array.

Parameters
dataData to read from or write to

◆ ByteStream() [2/3]

Quantum.ByteStream.ByteStream ( int  capacity)
inline

Create a byte stream with a given capacity.

Parameters
capacityThe initial size of the underlying buffer.

◆ ByteStream() [3/3]

Quantum.ByteStream.ByteStream ( )
inline

Create a byte stream with the default buffer length and default size.

Member Function Documentation

◆ Reset()

void Quantum.ByteStream.Reset ( )
inline

Reset the stream and clear

◆ Duplicate()

ByteStream Quantum.ByteStream.Duplicate ( )
inline

Duplicate the stream.

Returns
A copy of the stream with a copied buffer.

◆ ToArray()

Byte [] Quantum.ByteStream.ToArray ( )
inline

Create a copy of the underlying data array.

Returns
A copy of the internal data array

◆ WriteBool()

Boolean Quantum.ByteStream.WriteBool ( Boolean  value)
inline

Write a bool to the byte stream.

Parameters
valueBool
Returns
return the input value.

◆ ReadBool()

Boolean Quantum.ByteStream.ReadBool ( )
inline

Reads and returns a bool from the byte stream.

Returns
Bool that was read from the stream

◆ WriteSByte()

void Quantum.ByteStream.WriteSByte ( SByte  value)
inline

Write a singed byte to the byte stream.

Parameters
valueSinged byte

◆ ReadSByte()

SByte Quantum.ByteStream.ReadSByte ( )
inline

Read a signed byte from the byte stream.

Returns
Signed by that was read from the stream

◆ WriteByte()

void Quantum.ByteStream.WriteByte ( Byte  value)
inline

Write a byte to the byte stream.

Parameters
valueThe value to write

◆ ReadByte()

Byte Quantum.ByteStream.ReadByte ( )
inline

Read a byte from the byte stream.

Returns
The byte value that was read from the stream.

◆ WriteShort()

void Quantum.ByteStream.WriteShort ( Int16  value)
inline

Write a short to the byte stream.

Parameters
valueThe value to write to the stream.

◆ ReadShort()

Int16 Quantum.ByteStream.ReadShort ( )
inline

Read a short from the byte stream.

Returns
Value read from the byte stream

◆ WriteChar()

void Quantum.ByteStream.WriteChar ( Char  value)
inline

Write a char to the byte stream.

Parameters
valueThe value to write to the stream.

◆ ReadChar()

Char Quantum.ByteStream.ReadChar ( )
inline

Read a char from the byte stream.

Returns
Value read from the byte stream

◆ WriteUShort()

void Quantum.ByteStream.WriteUShort ( UInt16  value)
inline

Write a unsigned short to the byte stream.

Parameters
valueThe value to write to the stream.

◆ ReadUShort()

UInt16 Quantum.ByteStream.ReadUShort ( )
inline

Read an unsigned short from the byte stream.

Returns
Value read from the byte stream

◆ Write7BitEncodedInt()

void Quantum.ByteStream.Write7BitEncodedInt ( int  value)
inline

Writes an integer in a compressed format to the byte stream.

Parameters
value

◆ WriteInt()

void Quantum.ByteStream.WriteInt ( Int32  value)
inline

Write an integer to the byte stream.

Parameters
valueThe value to write to the stream.

◆ Read7BitEncodedInt()

int Quantum.ByteStream.Read7BitEncodedInt ( )
inline

Read an integer in compressed format from the byte stream.

Returns
Exceptions
FormatExceptionIs raised when the stream is corrupted

◆ ReadInt()

Int32 Quantum.ByteStream.ReadInt ( )
inline

Read an integer from the byte stream.

Returns
Value read from the byte stream

◆ WriteUInt()

void Quantum.ByteStream.WriteUInt ( UInt32  value)
inline

Write an unsigned integer to the byte stream.

Parameters
valueThe value to write to the stream.

◆ ReadUInt()

UInt32 Quantum.ByteStream.ReadUInt ( )
inline

Read an unsigned short from the byte stream.

Returns
Value read from the byte stream

◆ WriteULong()

void Quantum.ByteStream.WriteULong ( UInt64  value)
inline

Write an unsigned long to the byte stream.

Parameters
valueThe value to write to the stream.

◆ ReadULong()

UInt64 Quantum.ByteStream.ReadULong ( )
inline

Read an unsigned long from the byte stream.

Returns
Value read from the byte stream

◆ WriteLong()

void Quantum.ByteStream.WriteLong ( Int64  value)
inline

Write a long to the byte stream.

Parameters
valueThe value to write to the stream.

◆ ReadLong()

Int64 Quantum.ByteStream.ReadLong ( )
inline

Read a long from the byte stream.

Returns
Value read from the byte stream

◆ WriteByteArray() [1/2]

void Quantum.ByteStream.WriteByteArray ( Byte[]  bytes)
inline

Write a byte array to the byte stream.

Parameters
bytesThe array to write to the stream.

◆ WriteByteArray() [2/2]

void Quantum.ByteStream.WriteByteArray ( Byte[]  bytes,
Int32  offset,
Int32  count 
)
inline

Write a byte array to the byte stream.

Parameters
bytesThe input array
offsetThe offset of the input array
countThe length of the input array to write

◆ ReadByteArray()

Byte [] Quantum.ByteStream.ReadByteArray ( )
inline

Read a byte array from the byte stream.

Returns
A new array that was read from the byte stream

◆ WriteGuid()

void Quantum.ByteStream.WriteGuid ( Guid  guid)
inline

Write a Guid to the byte stream.

Parameters
guidThe Guid to write to stream.

◆ ReadGuid()

Guid Quantum.ByteStream.ReadGuid ( )
inline

Read a Guid from the byte stream.

Returns
Value read from the byte stream

◆ Dispose()

void Quantum.ByteStream.Dispose ( )
inline

Dispose the byte stream.

Property Documentation

◆ Position

Int32 Quantum.ByteStream.Position
getset

Get or set the current position in the stream.

◆ Data

Byte [] Quantum.ByteStream.Data
getset

Get or set the underlying data array.