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

◆ TryParseGuidN()

static bool System.Buffers.Text.Utf8Parser.TryParseGuidN ( ReadOnlySpan< byte > text,
out Guid value,
out int bytesConsumed )
inlinestaticprivate

Definition at line 1132 of file Utf8Parser.cs.

1133 {
1134 if (text.Length < 32)
1135 {
1136 value = default(Guid);
1137 bytesConsumed = 0;
1138 return false;
1139 }
1140 if (!TryParseUInt32X(text.Slice(0, 8), out var value2, out var bytesConsumed2) || bytesConsumed2 != 8)
1141 {
1142 value = default(Guid);
1143 bytesConsumed = 0;
1144 return false;
1145 }
1146 if (!TryParseUInt16X(text.Slice(8, 4), out var value3, out bytesConsumed2) || bytesConsumed2 != 4)
1147 {
1148 value = default(Guid);
1149 bytesConsumed = 0;
1150 return false;
1151 }
1152 if (!TryParseUInt16X(text.Slice(12, 4), out var value4, out bytesConsumed2) || bytesConsumed2 != 4)
1153 {
1154 value = default(Guid);
1155 bytesConsumed = 0;
1156 return false;
1157 }
1158 if (!TryParseUInt16X(text.Slice(16, 4), out var value5, out bytesConsumed2) || bytesConsumed2 != 4)
1159 {
1160 value = default(Guid);
1161 bytesConsumed = 0;
1162 return false;
1163 }
1164 if (!TryParseUInt64X(text.Slice(20), out var value6, out bytesConsumed2) || bytesConsumed2 != 12)
1165 {
1166 value = default(Guid);
1167 bytesConsumed = 0;
1168 return false;
1169 }
1170 bytesConsumed = 32;
1171 value = new Guid((int)value2, (short)value3, (short)value4, (byte)(value5 >> 8), (byte)value5, (byte)(value6 >> 40), (byte)(value6 >> 32), (byte)(value6 >> 24), (byte)(value6 >> 16), (byte)(value6 >> 8), (byte)value6);
1172 return true;
1173 }
static bool TryParseUInt16X(ReadOnlySpan< byte > source, out ushort value, out int bytesConsumed)
static bool TryParseUInt32X(ReadOnlySpan< byte > source, out uint value, out int bytesConsumed)
static bool TryParseUInt64X(ReadOnlySpan< byte > source, out ulong value, out int bytesConsumed)

References System.text, System.Buffers.Text.Utf8Parser.TryParseUInt16X(), System.Buffers.Text.Utf8Parser.TryParseUInt32X(), System.Buffers.Text.Utf8Parser.TryParseUInt64X(), and System.value.

Referenced by System.Buffers.Text.Utf8Parser.TryParse().