Photon Fusion 2.1.1

ReadWriteUtilsForWeaver Class Reference

Provides utility methods for reading and writing data. More...

Static Public Member Functions

static unsafe int GetByteArrayHashCode (byte *ptr, int length)
static int GetByteCountUtf8NoHash (string value)
 Gets the byte count of a string in UTF8 format without a hash.
static int GetStringHashCode (string value, int maxLength)
static int GetWordCountString (int capacity, bool withCaching)
 Gets the word count of a string with optional caching.
static bool ReadBoolean (int *data)
 Reads a boolean value from the provided memory location.
static unsafe int ReadStringUtf32NoHash (int *ptr, int maxLength, out string result)
 Reads a string from the provided memory location in UTF32 format without a hash.
static unsafe int ReadStringUtf32NoHash (ReadOnlySpan< int > ptr, out string result)
 Reads a string from the provided memory location in UTF32 format without a hash.
static unsafe int ReadStringUtf32WithHash (int *ptr, int maxLength, ref string cache)
 Reads a string from the provided memory location in UTF32 format with a hash.
static unsafe int ReadStringUtf32WithHash (ReadOnlySpan< int > ptr, ref string cache)
 Reads a string from the provided memory location in UTF32 format with a hash.
static int ReadStringUtf8NoHash (void *source, out string result)
 Reads a string from the provided memory location in UTF8 format without a hash.
static int VerifyRawNetworkUnwrap< T > (int actual, int maxBytes)
 Verifies the byte count of a network unwrapped object. Throws an exception if the actual byte count exceeds the maximum allowed byte count.
static int VerifyRawNetworkWrap< T > (int actual, int maxBytes)
 Verifies the byte count of a network wrapped object. Throws an exception if the actual byte count exceeds the maximum allowed byte count.
static void WriteBoolean (int *data, bool value)
 Writes a boolean value to the provided memory location.
static unsafe int WriteStringUtf32NoHash (int *ptr, int maxLength, string value)
 Writes a string to the provided memory location in UTF32 format without a hash.
static unsafe int WriteStringUtf32NoHash (Span< int > ptr, string value)
 Writes a string to the provided memory location in UTF32 format without a hash.
static unsafe int WriteStringUtf32WithHash (int *ptr, int maxLength, string value, ref string cache)
 Writes a string to the provided memory location in UTF32 format with a hash.
static unsafe int WriteStringUtf32WithHash (Span< int > ptr, string value, ref string cache)
 Writes a string to the provided memory location in UTF32 format with a hash.
static int WriteStringUtf8NoHash (void *destination, string str)
 Writes a string to the provided memory location in UTF8 format without a hash.

Detailed Description

Provides utility methods for reading and writing data.

Member Function Documentation

◆ GetByteArrayHashCode()

unsafe int GetByteArrayHashCode ( byte * ptr,
int length )
static
Parameters
ptr
length
Returns

◆ GetByteCountUtf8NoHash()

int GetByteCountUtf8NoHash ( string value)
static

Gets the byte count of a string in UTF8 format without a hash.

Parameters
valueThe string to get the byte count of.
Returns
The byte count of the string in UTF8 format.

◆ GetStringHashCode()

int GetStringHashCode ( string value,
int maxLength )
static
Parameters
value
maxLength
Returns

◆ GetWordCountString()

int GetWordCountString ( int capacity,
bool withCaching )
static

Gets the word count of a string with optional caching.

Parameters
capacityThe capacity of the string.
withCachingIndicates whether caching is used.
Returns
The word count of the string.

◆ ReadBoolean()

bool ReadBoolean ( int * data)
static

Reads a boolean value from the provided memory location.

Parameters
dataThe memory location to read from.
Returns
The boolean value read from the memory location.

◆ ReadStringUtf32NoHash() [1/2]

unsafe int ReadStringUtf32NoHash ( int * ptr,
int maxLength,
out string result )
static

Reads a string from the provided memory location in UTF32 format without a hash.

Parameters
ptrThe memory location to read from.
maxLengthThe maximum length of the string.
resultThe string read from the memory location.
Returns
The number of bytes read.

◆ ReadStringUtf32NoHash() [2/2]

unsafe int ReadStringUtf32NoHash ( ReadOnlySpan< int > ptr,
out string result )
static

Reads a string from the provided memory location in UTF32 format without a hash.

Parameters
ptrThe memory location to read from.
resultThe string read from the memory location.
Returns
The number of bytes read.

◆ ReadStringUtf32WithHash() [1/2]

unsafe int ReadStringUtf32WithHash ( int * ptr,
int maxLength,
ref string cache )
static

Reads a string from the provided memory location in UTF32 format with a hash.

Parameters
ptrThe memory location to read from.
maxLengthThe maximum length of the string.
cacheA reference to a cache string. This will be updated with the read string if it matches the cached hashcode.
Returns
The number of bytes read.

◆ ReadStringUtf32WithHash() [2/2]

unsafe int ReadStringUtf32WithHash ( ReadOnlySpan< int > ptr,
ref string cache )
static

Reads a string from the provided memory location in UTF32 format with a hash.

Parameters
ptrThe memory location to read from.
cacheA reference to a cache string. This will be updated with the read string if it matches the cached hashcode.
Returns
The number of bytes read.

◆ ReadStringUtf8NoHash()

int ReadStringUtf8NoHash ( void * source,
out string result )
static

Reads a string from the provided memory location in UTF8 format without a hash.

Parameters
sourceThe memory location to read from.
resultThe string read from the memory location.
Returns
The number of bytes read.

◆ VerifyRawNetworkUnwrap< T >()

int VerifyRawNetworkUnwrap< T > ( int actual,
int maxBytes )
static

Verifies the byte count of a network unwrapped object. Throws an exception if the actual byte count exceeds the maximum allowed byte count.

Template Parameters
TThe type of the network unwrapped object.
Parameters
actualThe actual byte count.
maxBytesThe maximum allowed byte count.
Returns
The actual byte count if it does not exceed the maximum allowed byte count.

◆ VerifyRawNetworkWrap< T >()

int VerifyRawNetworkWrap< T > ( int actual,
int maxBytes )
static

Verifies the byte count of a network wrapped object. Throws an exception if the actual byte count exceeds the maximum allowed byte count.

Template Parameters
TThe type of the network wrapped object.
Parameters
actualThe actual byte count.
maxBytesThe maximum allowed byte count.
Returns
The actual byte count if it does not exceed the maximum allowed byte count.

◆ WriteBoolean()

void WriteBoolean ( int * data,
bool value )
static

Writes a boolean value to the provided memory location.

Parameters
dataThe memory location to write to.
valueThe boolean value to write.

◆ WriteStringUtf32NoHash() [1/2]

unsafe int WriteStringUtf32NoHash ( int * ptr,
int maxLength,
string value )
static

Writes a string to the provided memory location in UTF32 format without a hash.

Parameters
ptrThe memory location to write to.
maxLengthThe maximum length of the string.
valueThe string to write.
Returns
The number of bytes written.

◆ WriteStringUtf32NoHash() [2/2]

unsafe int WriteStringUtf32NoHash ( Span< int > ptr,
string value )
static

Writes a string to the provided memory location in UTF32 format without a hash.

Parameters
ptrThe memory location to write to.
valueThe string to write.
Returns
The number of bytes written.

◆ WriteStringUtf32WithHash() [1/2]

unsafe int WriteStringUtf32WithHash ( int * ptr,
int maxLength,
string value,
ref string cache )
static

Writes a string to the provided memory location in UTF32 format with a hash.

Parameters
ptrThe memory location to write to.
maxLengthThe maximum length of the string.
valueThe string to write.
cacheA reference to a cache string. This will be updated with the trimmed value of the input string.
Returns
The number of bytes written.

◆ WriteStringUtf32WithHash() [2/2]

unsafe int WriteStringUtf32WithHash ( Span< int > ptr,
string value,
ref string cache )
static

Writes a string to the provided memory location in UTF32 format with a hash.

Parameters
ptrThe memory location to write to.
valueThe string to write.
cacheA reference to a cache string. This will be updated with the trimmed value of the input string.
Returns
The number of bytes written.

◆ WriteStringUtf8NoHash()

int WriteStringUtf8NoHash ( void * destination,
string str )
static

Writes a string to the provided memory location in UTF8 format without a hash.

Parameters
destinationThe memory location to write to.
strThe string to write.
Returns
The number of bytes written.