From 832cce033c6df98433d0770bea38d038285be3e6 Mon Sep 17 00:00:00 2001 From: Nathan McRae Date: Thu, 15 Feb 2024 20:24:01 -0800 Subject: [PATCH] Add Line field to SaneTsvRecord So extending formats can have line information --- SaneTsv.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/SaneTsv.cs b/SaneTsv.cs index f8c8f00..7de96a4 100644 --- a/SaneTsv.cs +++ b/SaneTsv.cs @@ -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; } } }