Photon Quantum 3.0.0

Static Public Member Functions | List of all members
Photon.Deterministic.ByteUtils Class Reference

Utility class for working with bytes. More...

Static Public Member Functions

static int AddByteBlock (byte[] block, byte[] buffer, int offset)
 
static int AddValueBlock (int value, byte[] buffer, int offset)
 Adds a value block to a byte array. More...
 
static int AddValueBlock (long value, byte[] buffer, int offset)
 Adds a value block to the specified byte array at the given offset. More...
 
static int AddValueBlock (ulong value, byte[] buffer, int offset)
 Adds a value block to the specified byte array at the given offset. More...
 
static byte[] Base64Decode (string data)
 Decodes a Base64 encoded string into a byte array. More...
 
static string Base64DecodeString (string data, Encoding encoding)
 Decodes a Base64-encoded string to its original string representation using the specified encoding. More...
 
static string Base64Encode (byte[] data)
 Encodes a byte array to a Base64 string. More...
 
static string Base64EncodeString (string data, Encoding encoding)
 Base64 encodes a string using the specified encoding. More...
 
static int BeginByteBlockHeader (byte[] buffer, int offset, out int blockStart)
 Begins a byte block header in the given buffer at the specified offset. More...
 
static GZipStream CreateGZipCompressStream (Stream output)
 Decompresses a byte array using GZip. More...
 
static GZipStream CreateGZipDecompressStream (Stream output)
 Decompresses a byte array using GZip. More...
 
static int EndByteBlockHeader (byte[] buffer, int blockStart, int bytesWritten)
 Ends the byte block header by updating the block size in the byte array. More...
 
static Byte[] GZipCompressBytes (Byte[] data)
 Compresses a byte array using GZip. More...
 
static void GZipCompressBytes (Byte[] data, int offset, int size, Stream output)
 Compresses a byte array using GZip. More...
 
static void GZipCompressBytes (Stream input, Stream output)
 Compresses a byte array using GZip. More...
 
static Byte[] GZipCompressString (String data, Encoding encoding)
 Compresses a byte array using GZip. More...
 
static Byte[] GZipDecompressBytes (Byte[] data)
 Decompresses a byte array using GZip. More...
 
static String GZipDecompressString (Byte[] data, Encoding encoding)
 Decompresses a byte array using GZip. More...
 
static String GZipDecompressString (Byte[] data, int offset, int size, Encoding encoding)
 Decompresses a byte array using GZip. More...
 
static Byte[] MergeByteBlocks (params Byte[][] blocks)
 Merges multiple byte blocks into a single byte array. More...
 
static Byte[] PackByteBlocks (params Byte[][] blocks)
 Takes multiple byte blocks and packs them into a single byte array. More...
 
static String PrintBits (Array array, Int32 offset, Int32 length)
 Print the bits of an array starting at the specified offset and for the given length. More...
 
static IEnumerable< Byte[]> ReadByteBlocks (Byte[] data)
 Read byte blocks from a byte array. More...
 
static unsafe Byte[] ToByteArray (byte *ptr, int length)
 Convert a pointer to a byte array. More...
 
static unsafe int WriteBytes (int value, byte[] array, int offset)
 Writes an integer value to a byte array at the specified offset. More...
 
static unsafe int WriteBytes (long value, byte[] array, int offset)
 Writes a long value to a byte array at the specified offset. More...
 
static int WriteBytes (ulong value, byte[] array, int offset)
 Writes an unsigned long value to a byte array at the specified offset. More...
 

Detailed Description

Utility class for working with bytes.

Member Function Documentation

◆ ToByteArray()

static unsafe Byte [] Photon.Deterministic.ByteUtils.ToByteArray ( byte *  ptr,
int  length 
)
inlinestatic

Convert a pointer to a byte array.

Parameters
ptrThe pointer to convert.
lengthThe length of the byte array.
Returns
The byte array.

◆ MergeByteBlocks()

static Byte [] Photon.Deterministic.ByteUtils.MergeByteBlocks ( params Byte  blocks[][])
inlinestatic

Merges multiple byte blocks into a single byte array.

Parameters
blocksThe byte blocks to merge.
Returns
The merged byte array.

◆ AddValueBlock() [1/3]

static int Photon.Deterministic.ByteUtils.AddValueBlock ( int  value,
byte[]  buffer,
int  offset 
)
inlinestatic

Adds a value block to a byte array.

Parameters
valueThe value to add to the byte array.
bufferThe byte array to add the value block to.
offsetThe offset in the byte array to start adding the value block.
Returns
The new offset in the byte array after adding the value block.

◆ AddValueBlock() [2/3]

static int Photon.Deterministic.ByteUtils.AddValueBlock ( long  value,
byte[]  buffer,
int  offset 
)
inlinestatic

Adds a value block to the specified byte array at the given offset.

Parameters
valueThe value to add to the byte array.
bufferThe byte array.
offsetThe offset at which to add the value block.
Returns
The updated offset after adding the value block.

◆ AddValueBlock() [3/3]

static int Photon.Deterministic.ByteUtils.AddValueBlock ( ulong  value,
byte[]  buffer,
int  offset 
)
inlinestatic

Adds a value block to the specified byte array at the given offset.

Parameters
valueThe value to add to the byte array.
bufferThe byte array.
offsetThe offset at which to add the value block.
Returns
The updated offset after adding the value block.

◆ AddByteBlock()

static int Photon.Deterministic.ByteUtils.AddByteBlock ( byte[]  block,
byte[]  buffer,
int  offset 
)
inlinestatic

Parameters
block
buffer
offset
Returns

◆ BeginByteBlockHeader()

static int Photon.Deterministic.ByteUtils.BeginByteBlockHeader ( byte[]  buffer,
int  offset,
out int  blockStart 
)
inlinestatic

Begins a byte block header in the given buffer at the specified offset.

Parameters
bufferThe byte array buffer.
offsetThe offset at which to begin the byte block header.
blockStartThe starting index of the byte block.
Returns
The new offset after the byte block header is initialized.

◆ EndByteBlockHeader()

static int Photon.Deterministic.ByteUtils.EndByteBlockHeader ( byte[]  buffer,
int  blockStart,
int  bytesWritten 
)
inlinestatic

Ends the byte block header by updating the block size in the byte array.

Parameters
bufferThe byte array containing the block header.
blockStartThe start index of the block header.
bytesWrittenThe number of bytes written in the block.
Returns
The updated index after updating the block size in the byte array.

◆ PackByteBlocks()

static Byte [] Photon.Deterministic.ByteUtils.PackByteBlocks ( params Byte  blocks[][])
inlinestatic

Takes multiple byte blocks and packs them into a single byte array.

Parameters
blocksThe byte blocks to pack.
Returns
The packed byte array.

◆ ReadByteBlocks()

static IEnumerable<Byte[]> Photon.Deterministic.ByteUtils.ReadByteBlocks ( Byte[]  data)
inlinestatic

Read byte blocks from a byte array.

Parameters
dataThe byte array containing the byte blocks.
Returns
An enumerable collection of byte arrays, each representing a byte block.

◆ PrintBits()

static String Photon.Deterministic.ByteUtils.PrintBits ( Array  array,
Int32  offset,
Int32  length 
)
inlinestatic

Print the bits of an array starting at the specified offset and for the given length.

Parameters
arrayThe array to print the bits from.
offsetThe offset within the array to start printing from.
lengthThe length of the bits to print.
Returns
A string representation of the bits.

◆ Base64EncodeString()

static string Photon.Deterministic.ByteUtils.Base64EncodeString ( string  data,
Encoding  encoding 
)
inlinestatic

Base64 encodes a string using the specified encoding.

Parameters
dataThe string to be encoded.
encodingThe encoding to be used.
Returns
The encoded string.

◆ Base64DecodeString()

static string Photon.Deterministic.ByteUtils.Base64DecodeString ( string  data,
Encoding  encoding 
)
inlinestatic

Decodes a Base64-encoded string to its original string representation using the specified encoding.

Parameters
dataThe Base64-encoded string to decode.
encodingThe encoding to use for the decoded string.
Returns
The decoded string.

◆ Base64Encode()

static string Photon.Deterministic.ByteUtils.Base64Encode ( byte[]  data)
inlinestatic

Encodes a byte array to a Base64 string.

Parameters
dataThe byte array to encode.
Returns
The Base64 encoded string.

◆ Base64Decode()

static byte [] Photon.Deterministic.ByteUtils.Base64Decode ( string  data)
inlinestatic

Decodes a Base64 encoded string into a byte array.

Parameters
dataThe Base64 encoded string to decode.
Returns
The decoded byte array.

◆ GZipCompressBytes() [1/3]

static Byte [] Photon.Deterministic.ByteUtils.GZipCompressBytes ( Byte[]  data)
inlinestatic

Compresses a byte array using GZip.

Parameters
dataThe data to compress.
Returns

◆ GZipCompressBytes() [2/3]

static void Photon.Deterministic.ByteUtils.GZipCompressBytes ( Byte[]  data,
int  offset,
int  size,
Stream  output 
)
inlinestatic

Compresses a byte array using GZip.

Parameters
dataThe data to compress.
offsetThe offset in the data array to start compressing from.
sizeThe size of the data to compress.
outputThe stream to write the data to.

◆ GZipCompressBytes() [3/3]

static void Photon.Deterministic.ByteUtils.GZipCompressBytes ( Stream  input,
Stream  output 
)
inlinestatic

Compresses a byte array using GZip.

Parameters
inputThe stream to read the data from.
outputThe stream to write the compressed data to.

◆ CreateGZipCompressStream()

static GZipStream Photon.Deterministic.ByteUtils.CreateGZipCompressStream ( Stream  output)
inlinestatic

Decompresses a byte array using GZip.

Parameters
outputThe stream to write the data to.
Returns
The compressed stream.

◆ CreateGZipDecompressStream()

static GZipStream Photon.Deterministic.ByteUtils.CreateGZipDecompressStream ( Stream  output)
inlinestatic

Decompresses a byte array using GZip.

Parameters
outputThe stream to write the data to.
Returns
The decompressed stream.

◆ GZipDecompressBytes()

static Byte [] Photon.Deterministic.ByteUtils.GZipDecompressBytes ( Byte[]  data)
inlinestatic

Decompresses a byte array using GZip.

Parameters
dataThe data to decompress
Returns
The decompressed data.

◆ GZipCompressString()

static Byte [] Photon.Deterministic.ByteUtils.GZipCompressString ( String  data,
Encoding  encoding 
)
inlinestatic

Compresses a byte array using GZip.

Parameters
dataThe string data to decompress.
encodingThe encoding to use.
Returns
The compressed string.

◆ GZipDecompressString() [1/2]

static String Photon.Deterministic.ByteUtils.GZipDecompressString ( Byte[]  data,
Encoding  encoding 
)
inlinestatic

Decompresses a byte array using GZip.

Parameters
dataThe string data to decompress.
encodingThe encoding to use.
Returns
The decompressed string.

◆ GZipDecompressString() [2/2]

static String Photon.Deterministic.ByteUtils.GZipDecompressString ( Byte[]  data,
int  offset,
int  size,
Encoding  encoding 
)
inlinestatic

Decompresses a byte array using GZip.

Parameters
dataThe string data to decompress.
offsetThe offset in the data array to start decompressing from.
sizeThe size of the data to decompress.
encodingThe encoding to use.
Returns
The decompressed string.

◆ WriteBytes() [1/3]

static unsafe int Photon.Deterministic.ByteUtils.WriteBytes ( long  value,
byte[]  array,
int  offset 
)
inlinestatic

Writes a long value to a byte array at the specified offset.

Parameters
valueThe long value to write.
arrayThe byte array to write the value to.
offsetThe offset in the byte array to write the value to.
Returns
The length written in bytes.

◆ WriteBytes() [2/3]

static int Photon.Deterministic.ByteUtils.WriteBytes ( ulong  value,
byte[]  array,
int  offset 
)
inlinestatic

Writes an unsigned long value to a byte array at the specified offset.

Parameters
valueThe unsigned long value to write.
arrayThe byte array to write the value to.
offsetThe offset in the byte array to write the value to.

◆ WriteBytes() [3/3]

static unsafe int Photon.Deterministic.ByteUtils.WriteBytes ( int  value,
byte[]  array,
int  offset 
)
inlinestatic

Writes an integer value to a byte array at the specified offset.

Parameters
valueThe integer value to write.
arrayThe byte array to write the value to.
offsetThe offset in the byte array to write the value to.