Table of Contents

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

T
TValue
Inheritance
CsvValueEnumeratorBase<T, TValue>
Implements
IEnumerator<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>, ICsvPipeReader<T>, CancellationToken)

Initializes a new instance of CsvValueEnumeratorBase<T, TValue>.

protected CsvValueEnumeratorBase(CsvOptions<T> options, ICsvPipeReader<T> reader, CancellationToken cancellationToken)

Parameters

options CsvOptions<T>

Options to use for reading

reader ICsvPipeReader<T>

Data source

cancellationToken CancellationToken

Token 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

CsvExceptionHandler<T>

Remarks

CsvFormatException is not handled as it represents structurally invalid CSV.

Methods

BindToHeaderless()

Returns a materializer bound to field indexes.

protected abstract IMaterializer<T, TValue> BindToHeaderless()

Returns

IMaterializer<T, TValue>

BindToHeaders(ReadOnlySpan<string>)

Returns a materializer bound to headers.

protected abstract IMaterializer<T, TValue> BindToHeaders(ReadOnlySpan<string> headers)

Parameters

headers ReadOnlySpan<string>

Returns

IMaterializer<T, TValue>

GetHeader()

Returns the header record's fields, or empty if none is read.

protected override ReadOnlySpan<string> GetHeader()

Returns

ReadOnlySpan<string>

MoveNextCore(ref readonly CsvFields<T>)

Attempts to read the next CSV record from the inner parser.

protected override bool MoveNextCore(ref readonly CsvFields<T> fields)

Parameters

fields CsvFields<T>

Current CSV record

Returns

bool

true if the enumerator produced the next value, false if the record was a header record, or was skipped.

Remarks

When this method is called, Position points to the start of the record.

ResetHeader()

Resets the header. No-op if the header is not read.

protected override void ResetHeader()