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

◆ ParseCDataOrCommentTupleAsync()

async Task<(int, int, bool)> System.Xml.XmlTextReaderImpl.ParseCDataOrCommentTupleAsync ( XmlNodeType type)
inlineprivate

Definition at line 11988 of file XmlTextReaderImpl.cs.

11989 {
11990 if (_ps.charsUsed - _ps.charPos < 3 && await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0)
11991 {
11992 Throw(System.SR.Xml_UnexpectedEOF, (type == XmlNodeType.Comment) ? "Comment" : "CDATA");
11993 }
11994 int num = _ps.charPos;
11995 char[] chars = _ps.chars;
11996 int num2 = 0;
11997 int num3 = -1;
11998 char c = ((type == XmlNodeType.Comment) ? '-' : ']');
11999 int item;
12000 int charPos;
12001 while (true)
12002 {
12003 char c2;
12004 if (XmlCharType.IsTextChar(c2 = chars[num]) && c2 != c)
12005 {
12006 num++;
12007 continue;
12008 }
12009 if (chars[num] == c)
12010 {
12011 if (chars[num + 1] == c)
12012 {
12013 if (chars[num + 2] == '>')
12014 {
12015 if (num2 > 0)
12016 {
12017 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
12018 item = num - num2;
12019 }
12020 else
12021 {
12022 item = num;
12023 }
12024 charPos = _ps.charPos;
12025 _ps.charPos = num + 3;
12026 return (charPos, item, true);
12027 }
12028 if (num + 2 == _ps.charsUsed)
12029 {
12030 break;
12031 }
12032 if (type == XmlNodeType.Comment)
12033 {
12035 }
12036 }
12037 else if (num + 1 == _ps.charsUsed)
12038 {
12039 break;
12040 }
12041 num++;
12042 continue;
12043 }
12044 switch (chars[num])
12045 {
12046 case '\n':
12047 num++;
12048 OnNewLine(num);
12049 continue;
12050 case '\r':
12051 if (chars[num + 1] == '\n')
12052 {
12053 if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full)
12054 {
12055 if (num - _ps.charPos > 0)
12056 {
12057 if (num2 == 0)
12058 {
12059 num2 = 1;
12060 num3 = num;
12061 }
12062 else
12063 {
12064 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
12065 num3 = num - num2;
12066 num2++;
12067 }
12068 }
12069 else
12070 {
12071 _ps.charPos++;
12072 }
12073 }
12074 num += 2;
12075 }
12076 else
12077 {
12078 if (num + 1 >= _ps.charsUsed && !_ps.isEof)
12079 {
12080 break;
12081 }
12082 if (!_ps.eolNormalized)
12083 {
12084 chars[num] = '\n';
12085 }
12086 num++;
12087 }
12088 OnNewLine(num);
12089 continue;
12090 case '\t':
12091 case '&':
12092 case '<':
12093 case ']':
12094 num++;
12095 continue;
12096 default:
12097 {
12098 if (num == _ps.charsUsed)
12099 {
12100 break;
12101 }
12102 char ch = chars[num];
12103 if (XmlCharType.IsHighSurrogate(ch))
12104 {
12105 if (num + 1 == _ps.charsUsed)
12106 {
12107 break;
12108 }
12109 num++;
12110 if (XmlCharType.IsLowSurrogate(chars[num]))
12111 {
12112 num++;
12113 continue;
12114 }
12115 }
12117 break;
12118 }
12119 }
12120 break;
12121 }
12122 if (num2 > 0)
12123 {
12124 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
12125 item = num - num2;
12126 }
12127 else
12128 {
12129 item = num;
12130 }
12131 charPos = _ps.charPos;
12132 _ps.charPos = num;
12133 return (charPos, item, false);
12134 }
static string Xml_InvalidCommentChars
Definition SR.cs:288
static string Xml_UnexpectedEOF
Definition SR.cs:36
Definition SR.cs:7
void ThrowInvalidChar(char[] data, int length, int invCharPos)
void Throw(int pos, string res, string arg)
void ShiftBuffer(int sourcePos, int destPos, int count)

References System.Xml.XmlTextReaderImpl._parsingMode, System.Xml.XmlTextReaderImpl._ps, System.ch, System.Xml.XmlTextReaderImpl.ParsingState.charPos, System.chars, System.Xml.XmlTextReaderImpl.ParsingState.chars, System.Xml.XmlTextReaderImpl.ParsingState.charsUsed, System.Xml.Dictionary, System.Xml.XmlTextReaderImpl.ParsingState.eolNormalized, System.Xml.XmlTextReaderImpl.ParsingState.isEof, System.Xml.XmlCharType.IsHighSurrogate(), System.Xml.XmlCharType.IsLowSurrogate(), System.Xml.XmlCharType.IsTextChar(), System.item, System.Xml.XmlTextReaderImpl.OnNewLine(), System.Xml.XmlTextReaderImpl.ReadDataAsync(), System.Xml.XmlTextReaderImpl.ShiftBuffer(), System.Xml.XmlTextReaderImpl.Throw(), System.Xml.XmlTextReaderImpl.ThrowInvalidChar(), System.type, System.SR.Xml_InvalidCommentChars, and System.SR.Xml_UnexpectedEOF.

Referenced by System.Xml.XmlTextReaderImpl.ParseCDataOrCommentAsync().