mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Add Slice functions to U8Strings
This commit is contained in:
parent
a6161e693c
commit
ac70990fa0
4 changed files with 40 additions and 0 deletions
|
@ -27,6 +27,16 @@ namespace LibHac.Common
|
||||||
_buffer = Encoding.UTF8.GetBytes(value);
|
_buffer = Encoding.UTF8.GetBytes(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public U8Span Slice(int start)
|
||||||
|
{
|
||||||
|
return new U8Span(_buffer.Slice(start));
|
||||||
|
}
|
||||||
|
|
||||||
|
public U8Span Slice(int start, int length)
|
||||||
|
{
|
||||||
|
return new U8Span(_buffer.Slice(start, length));
|
||||||
|
}
|
||||||
|
|
||||||
public static implicit operator ReadOnlySpan<byte>(U8Span value) => value.Value;
|
public static implicit operator ReadOnlySpan<byte>(U8Span value) => value.Value;
|
||||||
|
|
||||||
public static explicit operator string(U8Span value) => value.ToString();
|
public static explicit operator string(U8Span value) => value.ToString();
|
||||||
|
|
|
@ -28,6 +28,16 @@ namespace LibHac.Common
|
||||||
_buffer = Encoding.UTF8.GetBytes(value);
|
_buffer = Encoding.UTF8.GetBytes(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public U8SpanMutable Slice(int start)
|
||||||
|
{
|
||||||
|
return new U8SpanMutable(_buffer.Slice(start));
|
||||||
|
}
|
||||||
|
|
||||||
|
public U8SpanMutable Slice(int start, int length)
|
||||||
|
{
|
||||||
|
return new U8SpanMutable(_buffer.Slice(start, length));
|
||||||
|
}
|
||||||
|
|
||||||
public static implicit operator U8Span(U8SpanMutable value) => new U8Span(value._buffer);
|
public static implicit operator U8Span(U8SpanMutable value) => new U8Span(value._buffer);
|
||||||
|
|
||||||
public static implicit operator ReadOnlySpan<byte>(U8SpanMutable value) => value.Value;
|
public static implicit operator ReadOnlySpan<byte>(U8SpanMutable value) => value.Value;
|
||||||
|
|
|
@ -24,6 +24,16 @@ namespace LibHac.Common
|
||||||
_buffer = Encoding.UTF8.GetBytes(value);
|
_buffer = Encoding.UTF8.GetBytes(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public U8String Slice(int start)
|
||||||
|
{
|
||||||
|
return new U8String(_buffer.AsSpan(start).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
public U8String Slice(int start, int length)
|
||||||
|
{
|
||||||
|
return new U8String(_buffer.AsSpan(start, length).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
public static implicit operator U8Span(U8String value) => new U8Span(value._buffer);
|
public static implicit operator U8Span(U8String value) => new U8Span(value._buffer);
|
||||||
|
|
||||||
public static implicit operator ReadOnlySpan<byte>(U8String value) => value.Value;
|
public static implicit operator ReadOnlySpan<byte>(U8String value) => value.Value;
|
||||||
|
|
|
@ -28,6 +28,16 @@ namespace LibHac.Common
|
||||||
_buffer = Encoding.UTF8.GetBytes(value);
|
_buffer = Encoding.UTF8.GetBytes(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public U8StringMutable Slice(int start)
|
||||||
|
{
|
||||||
|
return new U8StringMutable(_buffer.AsSpan(start).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
public U8StringMutable Slice(int start, int length)
|
||||||
|
{
|
||||||
|
return new U8StringMutable(_buffer.AsSpan(start, length).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
public static implicit operator U8String(U8StringMutable value) => new U8String(value._buffer);
|
public static implicit operator U8String(U8StringMutable value) => new U8String(value._buffer);
|
||||||
public static implicit operator U8SpanMutable(U8StringMutable value) => new U8SpanMutable(value._buffer);
|
public static implicit operator U8SpanMutable(U8StringMutable value) => new U8SpanMutable(value._buffer);
|
||||||
public static implicit operator U8Span(U8StringMutable value) => new U8Span(value._buffer);
|
public static implicit operator U8Span(U8StringMutable value) => new U8Span(value._buffer);
|
||||||
|
|
Loading…
Reference in a new issue