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

◆ ConsumeStringNextSegment()

bool System.Text.Json.Utf8JsonReader.ConsumeStringNextSegment ( )
inlineprivate

Definition at line 2519 of file Utf8JsonReader.cs.

2520 {
2521 PartialStateForRollback state = CaptureState();
2522 HasValueSequence = true;
2523 int num = _buffer.Length - _consumed;
2524 ReadOnlySpan<byte> buffer;
2525 int num2;
2526 while (true)
2527 {
2528 if (!GetNextSpan())
2529 {
2530 if (IsLastSpan)
2531 {
2532 _bytePositionInLine += num;
2534 ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.EndOfStringNotFound, 0);
2535 }
2537 return false;
2538 }
2539 buffer = _buffer;
2540 num2 = buffer.IndexOfQuoteOrAnyControlOrBackSlash();
2541 if (num2 >= 0)
2542 {
2543 break;
2544 }
2545 _totalConsumed += buffer.Length;
2546 _bytePositionInLine += buffer.Length;
2547 }
2548 byte b = buffer[num2];
2549 SequencePosition end;
2550 if (b == 34)
2551 {
2552 end = new SequencePosition(_currentPosition.GetObject(), _currentPosition.GetInteger() + num2);
2553 _bytePositionInLine += num + num2 + 1;
2554 _totalConsumed += num;
2555 _consumed = num2 + 1;
2556 _stringHasEscaping = false;
2557 }
2558 else
2559 {
2560 _bytePositionInLine += num + num2;
2561 _stringHasEscaping = true;
2562 bool flag = false;
2563 while (true)
2564 {
2565 if (num2 < buffer.Length)
2566 {
2567 byte b2 = buffer[num2];
2568 if (b2 == 34)
2569 {
2570 if (!flag)
2571 {
2572 break;
2573 }
2574 flag = false;
2575 }
2576 else if (b2 == 92)
2577 {
2578 flag = !flag;
2579 }
2580 else if (flag)
2581 {
2582 int num3 = JsonConstants.EscapableChars.IndexOf(b2);
2583 if (num3 == -1)
2584 {
2586 ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.InvalidCharacterAfterEscapeWithinString, b2);
2587 }
2588 if (b2 == 117)
2589 {
2591 int num4 = 0;
2592 int num5 = num2 + 1;
2593 while (true)
2594 {
2595 if (num5 < buffer.Length)
2596 {
2597 byte nextByte = buffer[num5];
2598 if (!JsonReaderHelper.IsHexDigit(nextByte))
2599 {
2601 ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.InvalidHexCharacterWithinString, nextByte);
2602 }
2603 num4++;
2605 if (num4 >= 4)
2606 {
2607 break;
2608 }
2609 num5++;
2610 continue;
2611 }
2612 if (!GetNextSpan())
2613 {
2614 if (IsLastSpan)
2615 {
2617 ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.EndOfStringNotFound, 0);
2618 }
2620 return false;
2621 }
2622 _totalConsumed += buffer.Length;
2623 buffer = _buffer;
2624 num5 = 0;
2625 }
2626 flag = false;
2627 num2 = num5 + 1;
2628 continue;
2629 }
2630 flag = false;
2631 }
2632 else if (b2 < 32)
2633 {
2635 ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.InvalidCharacterWithinString, b2);
2636 }
2638 num2++;
2639 continue;
2640 }
2641 if (!GetNextSpan())
2642 {
2643 if (IsLastSpan)
2644 {
2646 ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.EndOfStringNotFound, 0);
2647 }
2649 return false;
2650 }
2651 _totalConsumed += buffer.Length;
2652 buffer = _buffer;
2653 num2 = 0;
2654 }
2656 _consumed = num2 + 1;
2657 _totalConsumed += num;
2658 end = new SequencePosition(_currentPosition.GetObject(), _currentPosition.GetInteger() + num2);
2659 }
2660 SequencePosition startPosition = state.GetStartPosition(1);
2662 _tokenType = JsonTokenType.String;
2663 return true;
2664 }
ReadOnlySequence< T > Slice(long start, long length)
PartialStateForRollback CaptureState()
readonly ReadOnlySequence< byte > _sequence
void RollBackState(in PartialStateForRollback state, bool isError=false)
ReadOnlySequence< byte > ValueSequence

References System.Text.Json.Utf8JsonReader._buffer, System.Text.Json.Utf8JsonReader._bytePositionInLine, System.Text.Json.Utf8JsonReader._consumed, System.Text.Json.Utf8JsonReader._currentPosition, System.Text.Json.Utf8JsonReader._sequence, System.Text.Json.Utf8JsonReader._stringHasEscaping, System.Text.Json.Utf8JsonReader._tokenType, System.Text.Json.Utf8JsonReader._totalConsumed, System.buffer, System.Text.Json.Utf8JsonReader.CaptureState(), System.Text.Json.Dictionary, System.Text.Json.JsonConstants.EscapableChars, System.SequencePosition.GetInteger(), System.Text.Json.Utf8JsonReader.GetNextSpan(), System.SequencePosition.GetObject(), System.Text.Json.Utf8JsonReader.HasValueSequence, System.Text.Json.JsonReaderHelper.IsHexDigit(), System.Text.Json.Utf8JsonReader.IsLastSpan, System.Text.Json.Utf8JsonReader.RollBackState(), System.Buffers.ReadOnlySequence< T >.Slice(), System.state, System.Text.Json.ThrowHelper.ThrowJsonReaderException(), and System.Text.Json.Utf8JsonReader.ValueSequence.

Referenced by System.Text.Json.Utf8JsonReader.ConsumeStringMultiSegment().