Photon Fusion 2.0.4

Static Public Member Functions | List of all members
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. More...
 
static int GetStringHashCode (string value, int maxLength)
 
static int GetWordCountString (int capacity, bool withCaching)
 Gets the word count of a string with optional caching. More...
 
static bool ReadBoolean (int *data)
 Reads a boolean value from the provided memory location. More...
 
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. More...
 
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. More...
 
static int ReadStringUtf8NoHash (void *source, out string result)
 Reads a string from the provided memory location in UTF8 format without a hash. More...
 
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. More...
 
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. More...
 
static void WriteBoolean (int *data, bool value)
 Writes a boolean value to the provided memory location. More...
 
static unsafe int WriteStringUtf32NoHash (int *ptr, int maxLength, string value)
 Writes a string to the provided memory location in UTF32 format without a hash. More...
 
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. More...
 
static int WriteStringUtf8NoHash (void *destination, string str)
 Writes a string to the provided memory location in UTF8 format without a hash. More...
 

Detailed Description

Provides utility methods for reading and writing data.

Member Function Documentation

◆ GetByteArrayHashCode()

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

Parameters
ptr
length
Returns

◆ GetByteCountUtf8NoHash()

static 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()

static int GetStringHashCode ( string  value,
int  maxLength 
)
static

Parameters
value
maxLength
Returns

◆ GetWordCountString()

static 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()

static 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()

static 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.

◆ ReadStringUtf32WithHash()

static 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.

◆ ReadStringUtf8NoHash()

static 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 >()

static 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 >()

static 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()

static 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()

static 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.

◆ WriteStringUtf32WithHash()

static 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.

◆ WriteStringUtf8NoHash()

static 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.