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

◆ TrySplitTimeSpan()

bool System.Buffers.Text.Utf8Parser.TimeSpanSplitter.TrySplitTimeSpan ( ReadOnlySpan< byte > source,
bool periodUsedToSeparateDay,
out int bytesConsumed )
inline

Definition at line 38 of file Utf8Parser.cs.

39 {
40 int i = 0;
41 byte b = 0;
42 for (; i != source.Length; i++)
43 {
44 b = source[i];
45 if (b != 32 && b != 9)
46 {
47 break;
48 }
49 }
50 if (i == source.Length)
51 {
52 bytesConsumed = 0;
53 return false;
54 }
55 if (b == 45)
56 {
57 IsNegative = true;
58 i++;
59 if (i == source.Length)
60 {
61 bytesConsumed = 0;
62 return false;
63 }
64 }
65 if (!TryParseUInt32D(source.Slice(i), out V1, out var bytesConsumed2))
66 {
67 bytesConsumed = 0;
68 return false;
69 }
70 i += bytesConsumed2;
71 ComponentParseResult componentParseResult = ParseComponent(source, periodUsedToSeparateDay, ref i, out V2);
72 switch (componentParseResult)
73 {
74 case ComponentParseResult.ParseFailure:
75 bytesConsumed = 0;
76 return false;
77 case ComponentParseResult.NoMoreData:
78 bytesConsumed = i;
79 return true;
80 default:
81 Separators |= (uint)componentParseResult << 24;
82 componentParseResult = ParseComponent(source, neverParseAsFraction: false, ref i, out V3);
83 switch (componentParseResult)
84 {
85 case ComponentParseResult.ParseFailure:
86 bytesConsumed = 0;
87 return false;
88 case ComponentParseResult.NoMoreData:
89 bytesConsumed = i;
90 return true;
91 default:
92 Separators |= (uint)componentParseResult << 16;
93 componentParseResult = ParseComponent(source, neverParseAsFraction: false, ref i, out V4);
94 switch (componentParseResult)
95 {
96 case ComponentParseResult.ParseFailure:
97 bytesConsumed = 0;
98 return false;
99 case ComponentParseResult.NoMoreData:
100 bytesConsumed = i;
101 return true;
102 default:
103 Separators |= (uint)componentParseResult << 8;
104 componentParseResult = ParseComponent(source, neverParseAsFraction: false, ref i, out V5);
105 switch (componentParseResult)
106 {
107 case ComponentParseResult.ParseFailure:
108 bytesConsumed = 0;
109 return false;
110 case ComponentParseResult.NoMoreData:
111 bytesConsumed = i;
112 return true;
113 default:
114 Separators |= (uint)componentParseResult;
115 if (i != source.Length && (source[i] == 46 || source[i] == 58))
116 {
117 bytesConsumed = 0;
118 return false;
119 }
120 bytesConsumed = i;
121 return true;
122 }
123 }
124 }
125 }
126 }
static bool TryParseUInt32D(ReadOnlySpan< byte > source, out uint value, out int bytesConsumed)
static ComponentParseResult ParseComponent(ReadOnlySpan< byte > source, bool neverParseAsFraction, ref int srcIndex, out uint value)

References System.Buffers.Text.Utf8Parser.TimeSpanSplitter.IsNegative, System.Buffers.Text.Utf8Parser.TimeSpanSplitter.ParseComponent(), System.Buffers.Text.Utf8Parser.TimeSpanSplitter.Separators, System.source, System.Buffers.Text.Utf8Parser.TryParseUInt32D(), System.Buffers.Text.Utf8Parser.TimeSpanSplitter.V1, System.Buffers.Text.Utf8Parser.TimeSpanSplitter.V2, System.Buffers.Text.Utf8Parser.TimeSpanSplitter.V3, System.Buffers.Text.Utf8Parser.TimeSpanSplitter.V4, and System.Buffers.Text.Utf8Parser.TimeSpanSplitter.V5.

Referenced by System.Buffers.Text.Utf8Parser.TryParseTimeSpanC(), and System.Buffers.Text.Utf8Parser.TryParseTimeSpanLittleG().