Class CsvValueEnumeratorBase<T, TValue>
- Namespace
- FlameCsv.Enumeration
- Assembly
- FlameCsv.Core.dll
An enumerator that parses CSV records as TValue.
public abstract class CsvValueEnumeratorBase<T, TValue> : CsvEnumeratorBase<T>, IEnumerator<TValue>, IEnumerator, IDisposable, IAsyncEnumerator<TValue>, IAsyncDisposable where T : unmanaged, IBinaryInteger<T>
Type Parameters
TTValue
- Inheritance
-
objectCsvValueEnumeratorBase<T, TValue>
- Implements
-
IEnumerator<TValue>IAsyncEnumerator<TValue>
- Derived
- Inherited Members
Remarks
If the options are configured to read a header record, it will be processed first before any records are yielded.
This class is not thread-safe, and should not be used concurrently.
The enumerator should always be disposed after use, either explicitly or using foreach.
Constructors
CsvValueEnumeratorBase(CsvOptions<T>, ICsvBufferReader<T>, CancellationToken)
Initializes a new instance of CsvValueEnumeratorBase<T, TValue>.
protected CsvValueEnumeratorBase(CsvOptions<T> options, ICsvBufferReader<T> reader, CancellationToken cancellationToken)
Parameters
optionsCsvOptions<T>Options to use for reading
readerICsvBufferReader<T>Data source
cancellationTokenCancellationTokenToken to cancel asynchronous enumeration
Properties
Current
Value parsed from the current CSV record.
public TValue Current { get; }
Property Value
- TValue
ExceptionHandler
Delegate that is called when an exception is thrown while parsing class records.
If the delegate returns true, the faulty record is skipped.
public CsvExceptionHandler<T>? ExceptionHandler { get; init; }
Property Value
Remarks
CsvFormatException is not handled as it represents structurally invalid CSV.
Headers
Returns the headers in the CSV. If headers have not been read, or HasHeader
is false, returns default.
protected ImmutableArray<string> Headers { get; }
Property Value
Exceptions
- NotSupportedException
A non-null value is set when HasHeader is
false.
Methods
BindToHeaderless()
Returns a materializer bound to field indexes.
protected abstract IMaterializer<T, TValue> BindToHeaderless()
Returns
- IMaterializer<T, TValue>
BindToHeaders(ImmutableArray<string>)
Returns a materializer bound to headers.
protected abstract IMaterializer<T, TValue> BindToHeaders(ImmutableArray<string> headers)
Parameters
headersImmutableArray<string>
Returns
- IMaterializer<T, TValue>
GetHeader()
Returns the header record's fields, or empty if none is read.
protected override ImmutableArray<string> GetHeader()
Returns
ResetHeader()
Resets the header. No-op if the header is not read.
protected override void ResetHeader()