diff --git a/ArrayIsEmpty.cs b/ArrayIsEmpty.cs index 087955f3c..11688c667 100644 --- a/ArrayIsEmpty.cs +++ b/ArrayIsEmpty.cs @@ -34,6 +34,9 @@ using System.Linq; namespace Aaru.Helpers { + /// + /// Helper operations to work with arrays + /// public static partial class ArrayHelpers { /// Checks if an array is null, filled with the NULL byte (0x00) or ASCII whitespace (0x20) diff --git a/BigEndianBitConverter.cs b/BigEndianBitConverter.cs index b7b20b083..54b2b4e30 100644 --- a/BigEndianBitConverter.cs +++ b/BigEndianBitConverter.cs @@ -305,6 +305,12 @@ namespace Aaru.Helpers public static ulong ToUInt64(byte[] value, int startIndex) => BitConverter.ToUInt64(value.Reverse().ToArray(), value.Length - sizeof(ulong) - startIndex); + /// + /// Converts a big endian byte array representation of a GUID into the .NET Guid structure + /// + /// Byte array containing a GUID in big endian + /// Start of the byte array to process + /// Processed Guid public static Guid ToGuid(byte[] value, int startIndex) => new Guid(ToUInt32(value, 0 + startIndex), ToUInt16(value, 4 + startIndex), ToUInt16(value, 6 + startIndex), diff --git a/CHS.cs b/CHS.cs index 448c73e4e..85600e3f9 100644 --- a/CHS.cs +++ b/CHS.cs @@ -32,6 +32,9 @@ namespace Aaru.Helpers { + /// + /// Helper operations to work with CHS values + /// public static class CHS { /// Converts a CHS position to a LBA one diff --git a/CountBits.cs b/CountBits.cs index 92bac63c1..e8dfcdb02 100644 --- a/CountBits.cs +++ b/CountBits.cs @@ -32,6 +32,9 @@ namespace Aaru.Helpers { + /// + /// Helper operations to count bits + /// public static class CountBits { /// Counts the number of bits set to true in a number diff --git a/DateHandlers.cs b/DateHandlers.cs index 58e963c18..e3ec874bc 100644 --- a/DateHandlers.cs +++ b/DateHandlers.cs @@ -36,6 +36,9 @@ using Aaru.Console; namespace Aaru.Helpers { + /// + /// Helper operations for timestamp management (date and time) + /// public static class DateHandlers { static readonly DateTime _lisaEpoch = new DateTime(1901, 1, 1, 0, 0, 0); diff --git a/Marshal.cs b/Marshal.cs index 8b3c3a0ae..db2739589 100644 --- a/Marshal.cs +++ b/Marshal.cs @@ -360,6 +360,11 @@ namespace Aaru.Helpers return str; } + /// + /// Swaps all fields in an structure considering them to follow PDP endian conventions + /// + /// Source structure + /// Resulting structure [MethodImpl(MethodImplOptions.AggressiveInlining)] public static object SwapStructureMembersEndianPdp(object str) { @@ -428,6 +433,12 @@ namespace Aaru.Helpers public static byte[] StructureToByteArrayBigEndian(T str) where T : struct => StructureToByteArrayLittleEndian((T)SwapStructureMembersEndian(str)); + /// + /// Converts a hexadecimal string into a byte array + /// + /// Hexadecimal string + /// Resulting byte array + /// Number of output bytes processed public static int ConvertFromHexAscii(string hex, out byte[] outBuf) { outBuf = null; diff --git a/PrintHex.cs b/PrintHex.cs index 08b242acf..943399704 100644 --- a/PrintHex.cs +++ b/PrintHex.cs @@ -35,6 +35,9 @@ using Aaru.Console; namespace Aaru.Helpers { + /// + /// Helper operations to get hexadecimal representations of byte arrays + /// public static class PrintHex { /// Prints a byte array as hexadecimal values to the console diff --git a/StringHandlers.cs b/StringHandlers.cs index d9abc45b5..85fd2bddf 100644 --- a/StringHandlers.cs +++ b/StringHandlers.cs @@ -35,6 +35,9 @@ using System.Text; namespace Aaru.Helpers { + /// + /// Helper operations to work with strings + /// public static class StringHandlers { /// Converts a null-terminated (aka C string) ASCII byte array to a C# string diff --git a/Swapping.cs b/Swapping.cs index 8b0e4b636..71ff96848 100644 --- a/Swapping.cs +++ b/Swapping.cs @@ -34,20 +34,48 @@ using System.Runtime.CompilerServices; namespace Aaru.Helpers { + /// + /// Helper operations to work with swapping endians + /// public static class Swapping { + /// + /// Gets the PDP endian equivalent of the given little endian unsigned integer + /// + /// Little endian unsigned integer + /// PDP unsigned integer [MethodImpl(MethodImplOptions.AggressiveInlining)] public static uint PDPFromLittleEndian(uint x) => ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16); + /// + /// Gets the PDP endian equivalent of the given big endian unsigned integer + /// + /// Big endian unsigned integer + /// PDP unsigned integer [MethodImpl(MethodImplOptions.AggressiveInlining)] public static uint PDPFromBigEndian(uint x) => ((x & 0xff00ff) << 8) | ((x & 0xff00ff00) >> 8); + /// + /// Swaps the endian of the specified unsigned short integer + /// + /// Unsigned short integer + /// Swapped unsigned short integer [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ushort Swap(ushort x) => (ushort)((x << 8) | (x >> 8)); + /// + /// Swaps the endian of the specified signed short integer + /// + /// Signed short integer + /// Swapped signed short integer [MethodImpl(MethodImplOptions.AggressiveInlining)] public static short Swap(short x) => (short)((x << 8) | ((x >> 8) & 0xFF)); + /// + /// Swaps the endian of the specified unsigned integer + /// + /// Unsigned integer + /// Swapped unsigned integer [MethodImpl(MethodImplOptions.AggressiveInlining)] public static uint Swap(uint x) { @@ -56,6 +84,11 @@ namespace Aaru.Helpers return (x << 16) | (x >> 16); } + /// + /// Swaps the endian of the specified signed integer + /// + /// Signed integer + /// Swapped signed integer [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Swap(int x) { @@ -64,6 +97,11 @@ namespace Aaru.Helpers return (int)(((uint)x << 16) | (((uint)x >> 16) & 0xFFFF)); } + /// + /// Swaps the endian of the specified unsigned long integer + /// + /// Unsigned long integer + /// Swapped unsigned long integer [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ulong Swap(ulong x) { @@ -74,6 +112,11 @@ namespace Aaru.Helpers return x; } + /// + /// Swaps the endian of the specified signed long integer + /// + /// Signed long integer + /// Swapped signed long integer [MethodImpl(MethodImplOptions.AggressiveInlining)] public static long Swap(long x) {