mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 20:48:24 +01:00
92 lines
3.9 KiB
C#
92 lines
3.9 KiB
C#
// <auto-generated /> - edit Vector.format.tt to modify
|
|
#nullable enable
|
|
|
|
namespace Brutal.Numerics;
|
|
|
|
public partial struct ulong2 : ISpanFormattable, IUtf8SpanFormattable, ISpanParsable<ulong2>
|
|
{
|
|
/// <inheritdoc />
|
|
public readonly override string ToString()
|
|
{
|
|
return ToString("G", CultureInfo.CurrentCulture);
|
|
}
|
|
|
|
/// <inheritdoc cref="Vector2.ToString(string?)" />
|
|
public readonly string ToString(string? format)
|
|
{
|
|
return ToString(format, CultureInfo.CurrentCulture);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
|
{
|
|
var separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
|
return $"<{X.ToString(format, formatProvider)}{separator} {Y.ToString(format, formatProvider)}>";
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
|
{
|
|
return StringHelpers.TryFormat<ulong2, ulong>(this, destination, out charsWritten, format, provider);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public readonly bool TryFormat(Span<byte> destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
|
{
|
|
return StringHelpers.TryFormat<ulong2, ulong>(this, destination, out bytesWritten, format, provider);
|
|
}
|
|
|
|
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
|
public static ulong2 Parse(string s, IFormatProvider? provider)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(s);
|
|
return Parse(s.AsSpan(), NumberStyles.Integer, provider);
|
|
}
|
|
|
|
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
|
public static ulong2 Parse(ReadOnlySpan<char> s, IFormatProvider? provider = null)
|
|
{
|
|
return Parse(s, NumberStyles.Integer, provider);
|
|
}
|
|
|
|
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
|
public static ulong2 Parse(string s, NumberStyles style, IFormatProvider? provider)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(s);
|
|
return Parse(s.AsSpan(), style, provider);
|
|
}
|
|
|
|
/// <summary>Parses from the <see cref="ToString()" /> format, <c><1, 2, 3></c>.</summary>
|
|
/// <exception cref="FormatException">The input is not in a valid format, or a component fails to parse.</exception>
|
|
public static ulong2 Parse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider)
|
|
{
|
|
if (!TryParse(s, style, provider, out var result))
|
|
throw new FormatException($"'{s}' is not in a valid ulong2 format.");
|
|
return result;
|
|
}
|
|
|
|
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out ulong2)" />
|
|
public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out ulong2 result)
|
|
{
|
|
return TryParse(s.AsSpan(), NumberStyles.Integer, provider, out result);
|
|
}
|
|
|
|
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out ulong2)" />
|
|
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out ulong2 result)
|
|
{
|
|
return TryParse(s, NumberStyles.Integer, provider, out result);
|
|
}
|
|
|
|
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out ulong2)" />
|
|
public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out ulong2 result)
|
|
{
|
|
return TryParse(s.AsSpan(), style, provider, out result);
|
|
}
|
|
|
|
/// <summary>Parses from the <see cref="ToString()" /> format, <c><1, 2, 3></c>.</summary>
|
|
/// <returns>true if the input parsed as a ulong2.</returns>
|
|
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out ulong2 result)
|
|
{
|
|
return StringHelpers.TryParse<ulong2, ulong>(s, style, provider, out result);
|
|
}
|
|
}
|