Add Line field to SaneTsvRecord

So extending formats can have line information
This commit is contained in:
Nathan McRae 2024-02-15 20:24:01 -08:00
parent 2dd6b1e25b
commit 832cce033c

View File

@ -214,7 +214,7 @@ public class SaneTsv
comment = currentComment.ToString();
currentComment.Clear();
}
parsed.Records.Add(new SaneTsvRecord(parsed, ParseCurrentRecord(parsed, fields, line), comment));
parsed.Records.Add(new SaneTsvRecord(parsed, ParseCurrentRecord(parsed, fields, line), comment, line));
fields.Clear();
}
@ -271,7 +271,7 @@ public class SaneTsv
comment = currentComment.ToString();
currentComment.Clear();
}
parsed.Records.Add(new SaneTsvRecord(parsed, ParseCurrentRecord(parsed, fields, line), comment));
parsed.Records.Add(new SaneTsvRecord(parsed, ParseCurrentRecord(parsed, fields, line), comment, line));
fields.Clear();
}
@ -491,14 +491,18 @@ public class SaneTsv
public SaneTsv Parent { get; }
public string Comment { get; }
public object[] Fields { get; }
public int Line { get; }
public object this[string columnName] => Fields[Array.IndexOf(Parent.ColumnNames, columnName)];
public SaneTsvRecord(SaneTsv parent, object[] fields, string comment)
public object this[int columnIndex] => Fields[columnIndex];
public SaneTsvRecord(SaneTsv parent, object[] fields, string comment, int line)
{
Parent = parent;
Fields = fields;
Comment = comment;
Line = line;
}
}
}