mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add XML comments to public entities.
This commit is contained in:
@@ -34,6 +34,9 @@ using System.Linq;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper operations to work with arrays
|
||||
/// </summary>
|
||||
public static partial class ArrayHelpers
|
||||
{
|
||||
/// <summary>Checks if an array is null, filled with the NULL byte (0x00) or ASCII whitespace (0x20)</summary>
|
||||
|
||||
@@ -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);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a big endian byte array representation of a GUID into the .NET Guid structure
|
||||
/// </summary>
|
||||
/// <param name="value">Byte array containing a GUID in big endian</param>
|
||||
/// <param name="startIndex">Start of the byte array to process</param>
|
||||
/// <returns>Processed Guid</returns>
|
||||
public static Guid ToGuid(byte[] value, int startIndex) => new Guid(ToUInt32(value, 0 + startIndex),
|
||||
ToUInt16(value, 4 + startIndex),
|
||||
ToUInt16(value, 6 + startIndex),
|
||||
|
||||
3
CHS.cs
3
CHS.cs
@@ -32,6 +32,9 @@
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper operations to work with CHS values
|
||||
/// </summary>
|
||||
public static class CHS
|
||||
{
|
||||
/// <summary>Converts a CHS position to a LBA one</summary>
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper operations to count bits
|
||||
/// </summary>
|
||||
public static class CountBits
|
||||
{
|
||||
/// <summary>Counts the number of bits set to <c>true</c> in a number</summary>
|
||||
|
||||
@@ -36,6 +36,9 @@ using Aaru.Console;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper operations for timestamp management (date and time)
|
||||
/// </summary>
|
||||
public static class DateHandlers
|
||||
{
|
||||
static readonly DateTime _lisaEpoch = new DateTime(1901, 1, 1, 0, 0, 0);
|
||||
|
||||
11
Marshal.cs
11
Marshal.cs
@@ -360,6 +360,11 @@ namespace Aaru.Helpers
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swaps all fields in an structure considering them to follow PDP endian conventions
|
||||
/// </summary>
|
||||
/// <param name="str">Source structure</param>
|
||||
/// <returns>Resulting structure</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static object SwapStructureMembersEndianPdp(object str)
|
||||
{
|
||||
@@ -428,6 +433,12 @@ namespace Aaru.Helpers
|
||||
public static byte[] StructureToByteArrayBigEndian<T>(T str) where T : struct =>
|
||||
StructureToByteArrayLittleEndian((T)SwapStructureMembersEndian(str));
|
||||
|
||||
/// <summary>
|
||||
/// Converts a hexadecimal string into a byte array
|
||||
/// </summary>
|
||||
/// <param name="hex">Hexadecimal string</param>
|
||||
/// <param name="outBuf">Resulting byte array</param>
|
||||
/// <returns>Number of output bytes processed</returns>
|
||||
public static int ConvertFromHexAscii(string hex, out byte[] outBuf)
|
||||
{
|
||||
outBuf = null;
|
||||
|
||||
@@ -35,6 +35,9 @@ using Aaru.Console;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper operations to get hexadecimal representations of byte arrays
|
||||
/// </summary>
|
||||
public static class PrintHex
|
||||
{
|
||||
/// <summary>Prints a byte array as hexadecimal values to the console</summary>
|
||||
|
||||
@@ -35,6 +35,9 @@ using System.Text;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper operations to work with strings
|
||||
/// </summary>
|
||||
public static class StringHandlers
|
||||
{
|
||||
/// <summary>Converts a null-terminated (aka C string) ASCII byte array to a C# string</summary>
|
||||
|
||||
43
Swapping.cs
43
Swapping.cs
@@ -34,20 +34,48 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Aaru.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper operations to work with swapping endians
|
||||
/// </summary>
|
||||
public static class Swapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the PDP endian equivalent of the given little endian unsigned integer
|
||||
/// </summary>
|
||||
/// <param name="x">Little endian unsigned integer</param>
|
||||
/// <returns>PDP unsigned integer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static uint PDPFromLittleEndian(uint x) => ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the PDP endian equivalent of the given big endian unsigned integer
|
||||
/// </summary>
|
||||
/// <param name="x">Big endian unsigned integer</param>
|
||||
/// <returns>PDP unsigned integer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static uint PDPFromBigEndian(uint x) => ((x & 0xff00ff) << 8) | ((x & 0xff00ff00) >> 8);
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the endian of the specified unsigned short integer
|
||||
/// </summary>
|
||||
/// <param name="x">Unsigned short integer</param>
|
||||
/// <returns>Swapped unsigned short integer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ushort Swap(ushort x) => (ushort)((x << 8) | (x >> 8));
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the endian of the specified signed short integer
|
||||
/// </summary>
|
||||
/// <param name="x">Signed short integer</param>
|
||||
/// <returns>Swapped signed short integer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short Swap(short x) => (short)((x << 8) | ((x >> 8) & 0xFF));
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the endian of the specified unsigned integer
|
||||
/// </summary>
|
||||
/// <param name="x">Unsigned integer</param>
|
||||
/// <returns>Swapped unsigned integer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static uint Swap(uint x)
|
||||
{
|
||||
@@ -56,6 +84,11 @@ namespace Aaru.Helpers
|
||||
return (x << 16) | (x >> 16);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the endian of the specified signed integer
|
||||
/// </summary>
|
||||
/// <param name="x">Signed integer</param>
|
||||
/// <returns>Swapped signed integer</returns>
|
||||
[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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the endian of the specified unsigned long integer
|
||||
/// </summary>
|
||||
/// <param name="x">Unsigned long integer</param>
|
||||
/// <returns>Swapped unsigned long integer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong Swap(ulong x)
|
||||
{
|
||||
@@ -74,6 +112,11 @@ namespace Aaru.Helpers
|
||||
return x;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the endian of the specified signed long integer
|
||||
/// </summary>
|
||||
/// <param name="x">Signed long integer</param>
|
||||
/// <returns>Swapped signed long integer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static long Swap(long x)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user