SpringCard LibCs for .NET  18.10.10
A set of utilities to simplify the development of .NET application
SpringCard.LibCs.BinUtils Class Reference

Utilities to manipulate raw arrays and binary values. More...

Public Types

enum  Endianness { BigEndian, LittleEndian }
 Select the endianness for convertion functions.
 

Static Public Member Functions

static byte [] Copy (byte[] a, int offset=0, int length=0)
 Create a copy of an array.
 
static byte [] Copy (byte[] a, int offset, int length, bool ensureSize)
 Create a copy of an array. If ensureSize is true, resize the destination array if the source array was to small.
 
static byte [] Copy (byte[] a, uint offset=0, uint length=0)
 
static byte [] Concat (byte[] a, byte[] b)
 Concatenate two arrays.
 
static bool Equals (byte[] a1, byte[] a2)
 Check whether two arrays are equals.
 
static bool Equals (byte[] a1, byte[] a2, int length)
 Check whether two arrays are equals, at least until the specified length.
 
static bool Equals (byte[] a1, int offset1, byte[] a2, int offset2, int length)
 Check whether two arrays are equals, at least from the specified offsets and until the specified length.
 
static byte [] EnsureSize (byte[] buffer, int minsize, int maxsize)
 Provide an array with the given size (truncate / padd with 00)
 
static UInt16 ToWord (byte[] value, Endianness endianness=Endianness.BigEndian)
 Convert an array of 2 bytes to the corresponding WORD.
 
static UInt16 BytesToUInt16 (byte[] value)
 Convert an array of 2 bytes to the corresponding DWORD. More...
 
static byte [] FromWord (UInt16 value, Endianness endianness=Endianness.BigEndian)
 Convert a WORD into an array of 2 bytes.
 
static byte [] UInt16ToBytes (UInt16 value)
 Convert a WORD into an array of 2 bytes. More...
 
static UInt32 ToDword (byte[] value, Endianness endianness=Endianness.BigEndian)
 Convert an array of 4 bytes to the corresponding DWORD.
 
static UInt32 BytesToUInt32 (byte[] value)
 Convert an array of 4 bytes to the corresponding DWORD. More...
 
static byte [] FromDword (UInt32 value, Endianness endianness=Endianness.BigEndian)
 Convert a DWORD into an array of 4 bytes.
 
static byte [] UInt32ToBytes (UInt32 value)
 Convert a DWORD into an array of 4 bytes. More...
 
static int CountOnes (byte[] buffer)
 Count the number of bits set to 1 in the buffer.
 
static int GetOnePositionRight (byte[] buffer)
 Get the index of the first 1 bit, starting from the right.
 
static int GetOnePositionLeft (byte[] buffer)
 Get the index of the first 1 bit, starting from the left.
 
static int CountConsecutiveOnes (byte[] buffer)
 
static byte [] INVERT (byte[] buffer)
 Logical INVERT of one array: result = ~buffer.
 
static byte [] AND (byte[] buffer1, byte[] buffer2)
 Logical AND of two arrays: result = buffer1 AND buffer2. The length of the resulting array is set to the shortest of both.
 
static byte [] AND (byte[] buffer1, byte[] buffer2, bool expand)
 Logical AND of two arrays: result = buffer1 AND buffer2. If expand is false, the length of the resulting array is set to the shortest of both. If expand is true, to the longest.
 
static byte [] OR (byte[] buffer1, byte[] buffer2)
 Logical OR of two arrays: result = buffer1 OR buffer2. The length of the resulting array is set to the shortest of both.
 
static byte [] OR (byte[] buffer1, byte[] buffer2, bool expand)
 Logical OR of two arrays: result = buffer1 OR buffer2. If expand is false, the length of the resulting array is set to the shortest of both. If expand is true, to the longest.
 
static byte [] XOR (byte[] buffer1, byte[] buffer2)
 Logical XOR of two arrays: result = buffer1 XOR buffer2. The length of the resulting array is set to the shortest of both.
 
static byte [] XOR (byte[] buffer1, byte[] buffer2, bool expand)
 Logical XOR of two arrays: result = buffer1 XOR buffer2. If expand is false, the length of the resulting array is set to the shortest of both. If expand is true, to the longest.
 
static byte [] CLEAR (byte[] buffer1, byte[] buffer2)
 Clear bits from one array with the other: result = buffer1 AND ~buffer2. The length of the resulting array is set to the shortest of both.
 
static byte [] CLEAR (byte[] buffer1, byte[] buffer2, bool expand)
 Clear bits from one array with the other: result = buffer1 AND ~buffer2. If expand is false, the length of the resulting array is set to the shortest of both. If expand is true, to the longest.
 
static byte [] ReplaceFromRight (byte[] buffer, byte[] replace, int offset_from_right, int length_bits)
 Replace a bit pattern, looking up from the right.
 
static byte [] ExtractBitsRight (byte[] buffer, int offset_from_right, int length_bits)
 Extract some bits, starting from the right.
 
static byte [] ExtractBitsLeft (byte[] buffer, int offset_from_left, int length_bits)
 Extract some bits, starting from the left.
 
static byte [] SetBitAt (byte[] buffer, int offset, bool value)
 Set a bit to 1 in the buffer.
 
static bool GetBitAt (byte[] buffer, int offset)
 Get the value of one bit from the buffer.
 

Detailed Description

Utilities to manipulate raw arrays and binary values.

Member Function Documentation

◆ BytesToUInt16()

static UInt16 SpringCard.LibCs.BinUtils.BytesToUInt16 ( byte []  value)
static

Convert an array of 2 bytes to the corresponding DWORD.

◆ BytesToUInt32()

static UInt32 SpringCard.LibCs.BinUtils.BytesToUInt32 ( byte []  value)
static

Convert an array of 4 bytes to the corresponding DWORD.

◆ UInt16ToBytes()

static byte [] SpringCard.LibCs.BinUtils.UInt16ToBytes ( UInt16  value)
static

Convert a WORD into an array of 2 bytes.

◆ UInt32ToBytes()

static byte [] SpringCard.LibCs.BinUtils.UInt32ToBytes ( UInt32  value)
static

Convert a DWORD into an array of 4 bytes.


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