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

◆ WriteCommentOrPiNoFlush()

unsafe int System.Xml.XmlUtf8RawTextWriter.WriteCommentOrPiNoFlush ( string text,
int index,
int count,
int stopChar,
out bool needWriteNewLine )
inlineprotectedinherited

Definition at line 2531 of file XmlUtf8RawTextWriter.cs.

2532 {
2533 needWriteNewLine = false;
2534 if (count == 0)
2535 {
2536 return -1;
2537 }
2538 fixed (char* ptr = text)
2539 {
2540 char* ptr2 = ptr + index;
2541 byte[] bufBytes = _bufBytes;
2542 fixed (byte[] array = bufBytes)
2543 {
2544 byte* ptr3 = (byte*)((bufBytes != null && array.Length != 0) ? Unsafe.AsPointer(ref array[0]) : null);
2545 char* ptr4 = ptr2;
2546 char* ptr5 = ptr4;
2547 char* ptr6 = ptr2 + count;
2548 byte* ptr7 = ptr3 + _bufPos;
2549 int num = 0;
2550 while (true)
2551 {
2552 byte* ptr8 = ptr7 + (ptr6 - ptr4);
2553 if (ptr8 > ptr3 + _bufLen)
2554 {
2555 ptr8 = ptr3 + _bufLen;
2556 }
2557 while (ptr7 < ptr8 && XmlCharType.IsTextChar((char)(num = *ptr4)) && num != stopChar && num <= 127)
2558 {
2559 *ptr7 = (byte)num;
2560 ptr7++;
2561 ptr4++;
2562 }
2563 if (ptr4 >= ptr6)
2564 {
2565 break;
2566 }
2567 if (ptr7 >= ptr8)
2568 {
2569 _bufPos = (int)(ptr7 - ptr3);
2570 return (int)(ptr4 - ptr5);
2571 }
2572 switch (num)
2573 {
2574 case 45:
2575 *ptr7 = 45;
2576 ptr7++;
2577 if (num == stopChar && (ptr4 + 1 == ptr6 || ptr4[1] == '-'))
2578 {
2579 *ptr7 = 32;
2580 ptr7++;
2581 }
2582 break;
2583 case 63:
2584 *ptr7 = 63;
2585 ptr7++;
2586 if (num == stopChar && ptr4 + 1 < ptr6 && ptr4[1] == '>')
2587 {
2588 *ptr7 = 32;
2589 ptr7++;
2590 }
2591 break;
2592 case 93:
2593 *ptr7 = 93;
2594 ptr7++;
2595 break;
2596 case 13:
2597 if (_newLineHandling == NewLineHandling.Replace)
2598 {
2599 if (ptr4 + 1 < ptr6 && ptr4[1] == '\n')
2600 {
2601 ptr4++;
2602 }
2603 _bufPos = (int)(ptr7 - ptr3);
2604 needWriteNewLine = true;
2605 return (int)(ptr4 - ptr5);
2606 }
2607 *ptr7 = (byte)num;
2608 ptr7++;
2609 break;
2610 case 10:
2611 if (_newLineHandling == NewLineHandling.Replace)
2612 {
2613 _bufPos = (int)(ptr7 - ptr3);
2614 needWriteNewLine = true;
2615 return (int)(ptr4 - ptr5);
2616 }
2617 *ptr7 = (byte)num;
2618 ptr7++;
2619 break;
2620 case 9:
2621 case 38:
2622 case 60:
2623 *ptr7 = (byte)num;
2624 ptr7++;
2625 break;
2626 default:
2627 if (XmlCharType.IsSurrogate(num))
2628 {
2630 ptr4 += 2;
2631 }
2632 else if (num <= 127 || num >= 65534)
2633 {
2635 ptr4++;
2636 }
2637 else
2638 {
2640 ptr4++;
2641 }
2642 continue;
2643 }
2644 ptr4++;
2645 }
2646 _bufPos = (int)(ptr7 - ptr3);
2647 }
2648 return -1;
2649 }
2650 }
unsafe byte * InvalidXmlChar(int ch, byte *pDst, bool entitize)
static unsafe byte * EncodeMultibyteUTF8(int ch, byte *pDst)
static unsafe byte * EncodeSurrogate(char *pSrc, char *pSrcEnd, byte *pDst)

References System.Xml.XmlUtf8RawTextWriter._bufBytes, System.Xml.XmlUtf8RawTextWriter._bufLen, System.Xml.XmlUtf8RawTextWriter._bufPos, System.Xml.XmlUtf8RawTextWriter._newLineHandling, System.array, System.count, System.Xml.Dictionary, System.Xml.XmlUtf8RawTextWriter.EncodeMultibyteUTF8(), System.Xml.XmlUtf8RawTextWriter.EncodeSurrogate(), System.index, System.Xml.XmlUtf8RawTextWriter.InvalidXmlChar(), System.Xml.XmlCharType.IsSurrogate(), System.Xml.XmlCharType.IsTextChar(), and System.text.

Referenced by System.Xml.XmlUtf8RawTextWriter.WriteCommentOrPiAsync().