Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
QueryOutputWriter.cs
Go to the documentation of this file.
2
3namespace System.Xml;
4
5internal sealed class QueryOutputWriter : XmlRawWriter
6{
7 private readonly XmlRawWriter _wrapped;
8
9 private bool _inCDataSection;
10
12
13 private readonly BitStack _bitsCData;
14
15 private readonly XmlQualifiedName _qnameCData;
16
17 private bool _outputDocType;
18
19 private readonly bool _checkWellFormedDoc;
20
21 private bool _hasDocElem;
22
23 private bool _inAttr;
24
25 private readonly string _systemId;
26
27 private readonly string _publicId;
28
29 private int _depth;
30
32 {
33 set
34 {
37 }
38 }
39
41 {
42 get
43 {
45 settings.ReadOnly = false;
48 settings.ReadOnly = true;
49 return settings;
50 }
51 }
52
54
56 {
58 _systemId = settings.DocTypeSystem;
59 _publicId = settings.DocTypePublic;
60 if (settings.OutputMethod == XmlOutputMethod.Xml)
61 {
62 if (_systemId != null)
63 {
64 _outputDocType = true;
66 }
67 if (settings.AutoXmlDeclaration && settings.Standalone == XmlStandalone.Yes)
68 {
70 }
71 if (settings.CDataSectionElements.Count <= 0)
72 {
73 return;
74 }
75 _bitsCData = new BitStack();
79 {
81 }
82 _bitsCData.PushBit(bit: false);
83 }
84 else if (settings.OutputMethod == XmlOutputMethod.Html && (_systemId != null || _publicId != null))
85 {
86 _outputDocType = true;
87 }
88 }
89
94
95 internal override void WriteXmlDeclaration(string xmldecl)
96 {
98 }
99
100 public override void WriteDocType(string name, string pubid, string sysid, string subset)
101 {
102 if (_publicId == null && _systemId == null)
103 {
105 }
106 }
107
108 public override void WriteStartElement(string prefix, string localName, string ns)
109 {
112 {
113 if (_depth == 0 && _hasDocElem)
114 {
115 throw new XmlException(System.SR.Xml_NoMultipleRoots, string.Empty);
116 }
117 _depth++;
118 _hasDocElem = true;
119 }
120 if (_outputDocType)
121 {
122 _wrapped.WriteDocType(string.IsNullOrEmpty(prefix) ? localName : (prefix + ":" + localName), _publicId, _systemId, null);
123 _outputDocType = false;
124 }
125 _wrapped.WriteStartElement(prefix, localName, ns);
126 if (_lookupCDataElems != null)
127 {
128 _qnameCData.Init(localName, ns);
130 }
131 }
132
133 internal override void WriteEndElement(string prefix, string localName, string ns)
134 {
136 _wrapped.WriteEndElement(prefix, localName, ns);
138 {
139 _depth--;
140 }
141 if (_lookupCDataElems != null)
142 {
144 }
145 }
146
147 internal override void WriteFullEndElement(string prefix, string localName, string ns)
148 {
150 _wrapped.WriteFullEndElement(prefix, localName, ns);
152 {
153 _depth--;
154 }
155 if (_lookupCDataElems != null)
156 {
158 }
159 }
160
161 internal override void StartElementContent()
162 {
164 }
165
166 public override void WriteStartAttribute(string prefix, string localName, string ns)
167 {
168 _inAttr = true;
169 _wrapped.WriteStartAttribute(prefix, localName, ns);
170 }
171
172 public override void WriteEndAttribute()
173 {
174 _inAttr = false;
176 }
177
178 internal override void WriteNamespaceDeclaration(string prefix, string ns)
179 {
181 }
182
187
188 internal override void WriteEndNamespaceDeclaration()
189 {
191 }
192
193 public override void WriteCData(string text)
194 {
196 }
197
198 public override void WriteComment(string text)
199 {
202 }
203
204 public override void WriteProcessingInstruction(string name, string text)
205 {
208 }
209
210 public override void WriteWhitespace(string ws)
211 {
213 {
215 }
216 else
217 {
219 }
220 }
221
222 public override void WriteString(string text)
223 {
225 {
227 }
228 else
229 {
231 }
232 }
233
234 public override void WriteChars(char[] buffer, int index, int count)
235 {
237 {
238 _wrapped.WriteCData(new string(buffer, index, count));
239 }
240 else
241 {
243 }
244 }
245
246 public override void WriteEntityRef(string name)
247 {
250 }
251
252 public override void WriteCharEntity(char ch)
253 {
256 }
257
263
264 public override void WriteRaw(char[] buffer, int index, int count)
265 {
267 {
268 _wrapped.WriteCData(new string(buffer, index, count));
269 }
270 else
271 {
273 }
274 }
275
276 public override void WriteRaw(string data)
277 {
279 {
280 _wrapped.WriteCData(data);
281 }
282 else
283 {
284 _wrapped.WriteRaw(data);
285 }
286 }
287
288 public override void Close()
289 {
290 _wrapped.Close();
292 {
293 throw new XmlException(System.SR.Xml_NoRoot, string.Empty);
294 }
295 }
296
297 public override void Flush()
298 {
299 _wrapped.Flush();
300 }
301
302 private bool StartCDataSection()
303 {
304 if (_lookupCDataElems != null && _bitsCData.PeekBit())
305 {
306 _inCDataSection = true;
307 return true;
308 }
309 return false;
310 }
311
312 private void EndCDataSection()
313 {
314 _inCDataSection = false;
315 }
316}
static string Xml_NoMultipleRoots
Definition SR.cs:362
static string Xml_NoRoot
Definition SR.cs:316
Definition SR.cs:7
void PushBit(bool bit)
Definition BitStack.cs:16
QueryOutputWriter(XmlRawWriter writer, XmlWriterSettings settings)
readonly Dictionary< XmlQualifiedName, int > _lookupCDataElems
override void WriteFullEndElement(string prefix, string localName, string ns)
override void WriteNamespaceDeclaration(string prefix, string ns)
readonly XmlRawWriter _wrapped
override void WriteSurrogateCharEntity(char lowChar, char highChar)
override bool SupportsNamespaceDeclarationInChunks
override void WriteWhitespace(string ws)
override void WriteCharEntity(char ch)
override void WriteRaw(string data)
override void WriteProcessingInstruction(string name, string text)
override XmlWriterSettings Settings
override void WriteEntityRef(string name)
override void WriteStartNamespaceDeclaration(string prefix)
override void WriteXmlDeclaration(XmlStandalone standalone)
override void WriteStartAttribute(string prefix, string localName, string ns)
readonly XmlQualifiedName _qnameCData
override void WriteStartElement(string prefix, string localName, string ns)
override IXmlNamespaceResolver NamespaceResolver
override void WriteString(string text)
override void WriteChars(char[] buffer, int index, int count)
override void WriteDocType(string name, string pubid, string sysid, string subset)
override void WriteRaw(char[] buffer, int index, int count)
override void WriteXmlDeclaration(string xmldecl)
override void WriteComment(string text)
override void WriteEndElement(string prefix, string localName, string ns)
override void WriteCData(string text)
override void WriteEndNamespaceDeclaration()
void Init(string name, string ns)
virtual void Close(WriteState currentState)
override void WriteCData(string text)
virtual bool SupportsNamespaceDeclarationInChunks
IXmlNamespaceResolver _resolver
override void WriteEndElement()
override void WriteCharEntity(char ch)
override void WriteRaw(char[] buffer, int index, int count)
override void WriteFullEndElement()
void WriteNamespaceDeclaration(string prefix, string ns)
override void WriteWhitespace(string ws)
virtual void WriteEndNamespaceDeclaration()
override void WriteSurrogateCharEntity(char lowChar, char highChar)
override void WriteChars(char[] buffer, int index, int count)
virtual void WriteStartNamespaceDeclaration(string prefix)
override void WriteDocType(string name, string pubid, string sysid, string subset)
virtual void WriteXmlDeclaration(XmlStandalone standalone)
List< XmlQualifiedName > CDataSectionElements
void WriteComment(string? text)
void WriteProcessingInstruction(string name, string? text)
void WriteEntityRef(string name)
void WriteString(string? text)
void WriteStartAttribute(string localName, string? ns)
Definition XmlWriter.cs:67
virtual ? XmlWriterSettings Settings
Definition XmlWriter.cs:14
void WriteStartElement(string localName, string? ns)
Definition XmlWriter.cs:30