fCraft  0.638
Custom Minecraft Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events
fCraft.BufferUtil Class Reference

Provides utility methods for working with byte arrays and pointers. More...

Static Public Member Functions

static void MemSet ([NotNull] this byte[] array, byte value)
 Fills the entire given byte array with a specified byte value, as efficiently as possible.
 
static void MemSet ([NotNull] this byte[] array, byte value, int startIndex, int length)
 Fills a section of the given byte array with a specified byte value, as efficiently as possible.
 
static void MemCpy ([NotNull] byte *src,[NotNull] byte *dest, int len)
 Copies contents of src buffer to dest buffer, as efficiently as possible.
 
static bool MemCmp ([NotNull] byte[] data, int offset,[NotNull] string value)
 Checks whether the sequence of bytes in data at the given offset matches the sequence of ASCII characters in value. Basically, checks whether the byte array contains the string at this offset.
 
static void ReadAll ([NotNull] Stream source,[NotNull] byte[] destination)
 Reads a number of bytes from source that matches the length of destination byte array.
 

Detailed Description

Provides utility methods for working with byte arrays and pointers.

Member Function Documentation

static bool fCraft.BufferUtil.MemCmp ( [NotNull] byte[]  data,
int  offset,
[NotNull] string  value 
)
static

Checks whether the sequence of bytes in data at the given offset matches the sequence of ASCII characters in value. Basically, checks whether the byte array contains the string at this offset.

Parameters
dataByte array to search.
offsetOffset, in bytes, from the start of data.
valueValue to search for. Must contain only ASCII characters.
Returns
Whether the pattern was found.
Exceptions
ArgumentNullExceptiondata or value is null.
ArgumentOutOfRangeExceptionoffset is less than 0 or greater than data.Length.
static void fCraft.BufferUtil.MemCpy ( [NotNull] byte *  src,
[NotNull] byte *  dest,
int  len 
)
static

Copies contents of src buffer to dest buffer, as efficiently as possible.

Parameters
srcSource array/pointer.
destDestination array/pointer.
lenNumber of bytes to copy.
static void fCraft.BufferUtil.MemSet ( [NotNull] this byte[]  array,
byte  value 
)
static

Fills the entire given byte array with a specified byte value, as efficiently as possible.

Parameters
arrayArray to work with.
valueValue to assign to each byte of the array.
Exceptions
ArgumentNullExceptionarray is null.
static void fCraft.BufferUtil.MemSet ( [NotNull] this byte[]  array,
byte  value,
int  startIndex,
int  length 
)
static

Fills a section of the given byte array with a specified byte value, as efficiently as possible.

Parameters
arrayArray to work with.
valueValue to assign to each byte of the array.
startIndexIndex of the first byte that should be set.
lengthNumber of bytes of the array to set.
Exceptions
ArgumentNullExceptionarray is null.
ArgumentOutOfRangeExceptionlength is negative; startIndex is negative; or if (length+startIndex) is greater than array length.
static void fCraft.BufferUtil.ReadAll ( [NotNull] Stream  source,
[NotNull] byte[]  destination 
)
static

Reads a number of bytes from source that matches the length of destination byte array.

Parameters
sourceStream to read from.
destinationByte array to write to. Length of this array is used.
Exceptions
ArgumentNullExceptionsource or destination is null.
EndOfStreamExceptionThe end of stream is reached before destination array was filled.

The documentation for this class was generated from the following file: