Renamed EndianExtensions to NumberExtensions, included SNBT-related methods.
The Tag class no longer used Regex to identify if a name needs quoted or not.
This commit is contained in:
parent
95af348ddc
commit
5d974eeeb4
|
@ -8,7 +8,7 @@ namespace SharpNBT;
|
|||
/// Contains extension methods dealing with endianness of numeric types.
|
||||
/// </summary>
|
||||
[PublicAPI]
|
||||
public static class EndianExtensions
|
||||
public static class NumberExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Swap the endian of the given <paramref name="value"/>.
|
||||
|
@ -71,4 +71,13 @@ public static class EndianExtensions
|
|||
var n = BitConverter.DoubleToInt64Bits(value);
|
||||
return BitConverter.Int64BitsToDouble(n.SwapEndian());
|
||||
}
|
||||
|
||||
public static bool IsValidUnquoted(this char c)
|
||||
{
|
||||
return c == '_' || c == '-' ||
|
||||
c == '.' || c == '+' ||
|
||||
c >= '0' && c <= '9' ||
|
||||
c >= 'A' && c <= 'Z' ||
|
||||
c >= 'a' && c <= 'z';
|
||||
}
|
||||
}
|
|
@ -175,7 +175,7 @@ public static class StringNbt
|
|||
var start = scanner.Position;
|
||||
for (var length = 0; scanner.MoveNext(false, true); length++)
|
||||
{
|
||||
if (AllowedInUnquoted(scanner.Current))
|
||||
if (scanner.Current.IsValidUnquoted())
|
||||
continue;
|
||||
|
||||
// Step back one character so not to consume the one that failed the permission check.
|
||||
|
@ -365,15 +365,6 @@ public static class StringNbt
|
|||
return values;
|
||||
}
|
||||
|
||||
private static bool AllowedInUnquoted(char c)
|
||||
{
|
||||
return c == '_' || c == '-' ||
|
||||
c == '.' || c == '+' ||
|
||||
c >= '0' && c <= '9' ||
|
||||
c >= 'A' && c <= 'Z' ||
|
||||
c >= 'a' && c <= 'z';
|
||||
}
|
||||
|
||||
private const StringSplitOptions SplitOpts = StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries;
|
||||
private static readonly char[] SplitSeparators = new[] { ',', 'b', 'B', 'l', 'L' };
|
||||
}
|
Loading…
Reference in New Issue