mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 20:48:24 +01:00
92 lines
4 KiB
C#
92 lines
4 KiB
C#
// <auto-generated /> - edit Vector.format.tt to modify
|
|
#nullable enable
|
|
|
|
namespace Brutal.Numerics;
|
|
|
|
public partial struct float4 : ISpanFormattable, IUtf8SpanFormattable, ISpanParsable<float4>
|
|
{
|
|
/// <inheritdoc />
|
|
public readonly override string ToString()
|
|
{
|
|
return ToString("G", CultureInfo.CurrentCulture);
|
|
}
|
|
|
|
/// <inheritdoc cref="Vector4.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)}{separator} {Z.ToString(format, formatProvider)}{separator} {W.ToString(format, formatProvider)}>";
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
|
{
|
|
return StringHelpers.TryFormat<float4, float>(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<float4, float>(this, destination, out bytesWritten, format, provider);
|
|
}
|
|
|
|
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
|
public static float4 Parse(string s, IFormatProvider? provider)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(s);
|
|
return Parse(s.AsSpan(), NumberStyles.Float, provider);
|
|
}
|
|
|
|
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
|
public static float4 Parse(ReadOnlySpan<char> s, IFormatProvider? provider = null)
|
|
{
|
|
return Parse(s, NumberStyles.Float, provider);
|
|
}
|
|
|
|
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
|
public static float4 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 float4 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 float4 format.");
|
|
return result;
|
|
}
|
|
|
|
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out float4)" />
|
|
public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out float4 result)
|
|
{
|
|
return TryParse(s.AsSpan(), NumberStyles.Float, provider, out result);
|
|
}
|
|
|
|
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out float4)" />
|
|
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out float4 result)
|
|
{
|
|
return TryParse(s, NumberStyles.Float, provider, out result);
|
|
}
|
|
|
|
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out float4)" />
|
|
public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out float4 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 float4.</returns>
|
|
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out float4 result)
|
|
{
|
|
return StringHelpers.TryParse<float4, float>(s, style, provider, out result);
|
|
}
|
|
}
|