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

◆ ParseComponent()

static ComponentParseResult System.Buffers.Text.Utf8Parser.TimeSpanSplitter.ParseComponent ( ReadOnlySpan< byte > source,
bool neverParseAsFraction,
ref int srcIndex,
out uint value )
inlinestaticprivate

Definition at line 128 of file Utf8Parser.cs.

129 {
130 if (srcIndex == source.Length)
131 {
132 value = 0u;
133 return ComponentParseResult.NoMoreData;
134 }
135 byte b = source[srcIndex];
136 if (b == 58 || (b == 46 && neverParseAsFraction))
137 {
138 srcIndex++;
139 if (!TryParseUInt32D(source.Slice(srcIndex), out value, out var bytesConsumed))
140 {
141 value = 0u;
142 return ComponentParseResult.ParseFailure;
143 }
144 srcIndex += bytesConsumed;
145 if (b != 58)
146 {
147 return ComponentParseResult.Period;
148 }
149 return ComponentParseResult.Colon;
150 }
151 if (b == 46)
152 {
153 srcIndex++;
154 if (!TryParseTimeSpanFraction(source.Slice(srcIndex), out value, out var bytesConsumed2))
155 {
156 value = 0u;
157 return ComponentParseResult.ParseFailure;
158 }
159 srcIndex += bytesConsumed2;
160 return ComponentParseResult.Period;
161 }
162 value = 0u;
163 return ComponentParseResult.NoMoreData;
164 }
static bool TryParseTimeSpanFraction(ReadOnlySpan< byte > source, out uint value, out int bytesConsumed)
static bool TryParseUInt32D(ReadOnlySpan< byte > source, out uint value, out int bytesConsumed)

References System.source, System.Buffers.Text.Utf8Parser.TryParseTimeSpanFraction(), System.Buffers.Text.Utf8Parser.TryParseUInt32D(), and System.value.

Referenced by System.Buffers.Text.Utf8Parser.TimeSpanSplitter.TrySplitTimeSpan().