Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ TryParse() [5/16]

static unsafe bool System.Buffers.Text.Utf8Parser.TryParse ( ReadOnlySpan< byte > source,
out decimal value,
out int bytesConsumed,
char standardFormat = '\0' )
inlinestatic

Definition at line 963 of file Utf8Parser.cs.

964 {
966 switch (standardFormat)
967 {
968 case '\0':
969 case 'E':
970 case 'G':
971 case 'e':
972 case 'g':
973 options = ParseNumberOptions.AllowExponent;
974 break;
975 case 'F':
976 case 'f':
978 break;
979 default:
980 return ParserHelpers.TryParseThrowFormatException<decimal>(out value, out bytesConsumed);
981 }
982 byte* digits = stackalloc byte[31];
983 Number.NumberBuffer number = new Number.NumberBuffer(Number.NumberBufferKind.Decimal, digits, 31);
984 if (!TryParseNumber(source, ref number, out bytesConsumed, options, out var textUsedExponentNotation))
985 {
986 value = default(decimal);
987 return false;
988 }
989 if (!textUsedExponentNotation && (standardFormat == 'E' || standardFormat == 'e'))
990 {
991 value = default(decimal);
992 bytesConsumed = 0;
993 return false;
994 }
995 value = default(decimal);
996 if (!Number.TryNumberToDecimal(ref number, ref value))
997 {
998 value = default(decimal);
999 bytesConsumed = 0;
1000 return false;
1001 }
1002 return true;
1003 }
static bool TryParseNumber(ReadOnlySpan< byte > source, ref Number.NumberBuffer number, out int bytesConsumed, ParseNumberOptions options, out bool textUsedExponentNotation)

References System.options, System.source, System.Number.TryNumberToDecimal(), System.Buffers.Text.Utf8Parser.TryParseNumber(), System.Buffers.Text.ParserHelpers.TryParseThrowFormatException(), and System.value.