1
2
3
4
5
6 using System;
7
8 namespace System.Xml
9 {
10 public class ProcessingInstruction : Node
11 {
12 public ProcessingInstruction(const System.Lex.Span& span_, int fileIndex_) : base(NodeKind.processingInstructionNode, span_, fileIndex_, "processing_instruction")
13 {
14 }
15 public ProcessingInstruction(const System.Lex.Span& span_, int fileIndex_, const string& target_, const string& data_) :
16 base(NodeKind.processingInstructionNode, span_, fileIndex_, "processing_instruction"), target(target_), data(data_)
17 {
18 }
19 public override void Accept(Visitor& visitor)
20 {
21 visitor.Visit(*this);
22 }
23 [nodiscard]
24 public override Result<bool> Write(System.Text.CodeFormatter& formatter)
25 {
26 if (formatter.Error())
27 {
28 return Result<bool>(ErrorId(formatter.GetErrorId()));
29 }
30 formatter << "<?" << target << " " << data << "?>" << endl();
31 return Result<bool>(true);
32 }
33 public override Node* Clone(bool deep) const
34 {
35 return new ProcessingInstruction(Span(), FileIndex(), target, data);
36 }
37 public inline const string& Target() const
38 {
39 return target;
40 }
41 public inline const string& Data() const
42 {
43 return data;
44 }
45 private string target;
46 private string data;
47 }
48
49 public ProcessingInstruction* MakeProcessingInstruction(const string& target, const string& data)
50 {
51 return new ProcessingInstruction(System.Lex.Span(), -1, target, data);
52 }
53 }