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>, ICsvBufferReader<T>, CancellationToken)

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

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

Parameters

options CsvOptions<T>

Options to use for reading

reader ICsvBufferReader<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.

Headers

Returns the headers in the CSV. If headers have not been read, or HasHeader is false, returns default.

protected ImmutableArray<string> Headers { get; set; }

Property Value

ImmutableArray<string>

Exceptions

NotSupportedException

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

headers ImmutableArray<string>

Returns

IMaterializer<T, TValue>

GetHeader()

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

protected override ImmutableArray<string> GetHeader()

Returns

ImmutableArray<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()