2024-11-18 14:31:39 -07:00

98 lines
2.4 KiB
C#

using System.Collections.Generic;
namespace Adaptation.FileHandlers.QS408M;
#nullable enable
public class Body
{
public Body(List<Site> sites, string waferMeanThickness, string stdDev, string passFail)
{
Sites = sites;
WaferMeanThickness = waferMeanThickness;
StdDev = stdDev;
PassFail = passFail;
}
public List<Site> Sites { get; }
public string WaferMeanThickness { get; }
public string StdDev { get; }
public string PassFail { get; }
private static bool IsNullOrWhiteSpace(string text)
{
bool flag;
int num = 0;
while (true)
{
if (num >= text.Length)
{
flag = true;
break;
}
else if (char.IsWhiteSpace(text[num]))
{
num++;
}
else
{
flag = false;
break;
}
}
return flag;
}
private static string GetToken(string text, int[] i)
{
while (true)
{
if (i[0] >= text.Length || !IsNullOrWhiteSpace(text.Substring(i[0], 1)))
{
break;
}
i[0]++;
}
int num = i[0];
while (true)
{
if (num >= text.Length || IsNullOrWhiteSpace(text.Substring(num, 1)))
{
break;
}
num++;
}
string str = text.Substring(i[0], num - i[0]);
i[0] = num;
return str.Trim();
}
internal static Body? Get(string text, int[] i)
{
Body? result;
Site site;
string thickness;
List<Site> sites = new();
string position = GetToken(text, i);
while (true)
{
if (string.IsNullOrEmpty(position) || !char.IsDigit(position[0]))
break;
thickness = GetToken(text, i);
site = new(position, thickness);
sites.Add(site);
position = GetToken(text, i);
}
i[0] = Complete.ScanPast(text, i, "mean thickness =");
string meanThickness = Complete.GetBefore(text, i, ", std. dev =");
string stdDev = GetToken(text, i);
string passFail = Complete.GetToEOL(text, i);
result = new(sites,
meanThickness,
stdDev,
passFail);
return result;
}
}