1 // =================================
 2 // Copyright (c) 2024 Seppo Laakko
 3 // Distributed under the MIT license
 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.processingInstructionNodespan_fileIndex_"processing_instruction")
13         {
14         }
15         public ProcessingInstruction(const System.Lex.Span& span_int fileIndex_const string& target_const string& data_) : 
16             base(NodeKind.processingInstructionNodespan_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()targetdata);
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& targetconst string& data)
50     {
51         return new ProcessingInstruction(System.Lex.Span()-1targetdata);
52     }
53 }