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 CDataSection : Text
11     {
12         public CDataSection(const System.Lex.Span& span_int fileIndex_) : base(NodeKind.cdataSectionNodespan_fileIndex_"cdata_section")
13         {
14         }
15         public CDataSection(const System.Lex.Span& span_int fileIndex_const string& text_) : base(NodeKind.cdataSectionNodespan_fileIndex_"cdata_section"text_)
16         {
17         }
18         public override void Accept(Visitor& visitor)
19         {
20             visitor.Visit(*this);
21         }
22         [nodiscard]
23         public override Result<bool> Write(System.Text.CodeFormatter& formatter)
24         {
25             if (formatter.Error())
26             {
27                 return Result<bool>(ErrorId(formatter.GetErrorId()));
28             }
29             auto result = formatter.Write("<![CDATA[");
30             if (result.Error()) return result;
31             result = formatter.Write(Data());
32             if (result.Error()) return result;
33             result = formatter.Write("]]>");
34             if (result.Error()) return result;
35             return Result<bool>(true);
36         }
37         public override Node* Clone(bool deep) const
38         {
39             return new CDataSection(Span()FileIndex()Data());
40         }
41     }
42 
43     public CDataSection* MakeCDataSection(const string& text)
44     {
45         return new CDataSection(System.Lex.Span()-1text);
46     }
47 }