Moving codegen tools to another project

This commit is contained in:
2025-06-03 12:09:32 +03:00
parent fa0565e699
commit 745def1365
27 changed files with 640 additions and 22 deletions
@@ -0,0 +1,41 @@
using System;
namespace mROA.CodegenTools.Reading
{
public abstract class LeadingTextSectionReader : ISectionReader
{
private readonly string _tagLeading;
protected int _currentCaretPosition;
protected LeadingTextSectionReader(string tagLeading)
{
_tagLeading = tagLeading + " ";
}
public string TemplateText { get; set; }
public int GetNextSectionIndex(int currentIndex)
{
_currentCaretPosition = Math.Max(currentIndex, _currentCaretPosition);
var index = TemplateText.IndexOf(_tagLeading, _currentCaretPosition, StringComparison.Ordinal);
_currentCaretPosition = index;
return index;
}
public abstract ITemplateSection ExtractSection(ref int index, TemplateDocument document);
protected int PassCaretToCloseSymbol()
{
_currentCaretPosition = TemplateText.IndexOf(">", _currentCaretPosition, StringComparison.Ordinal) + 1;
return _currentCaretPosition;
}
protected string GetTagValue(int from, int to)
{
var realStart = from + 4;
var span = TemplateText.AsSpan();
var slice = span.Slice(realStart, to - realStart);
return new string(slice.ToArray());
}
}
}