Class CsvEnumeratorBase<T>
- Namespace
- FlameCsv.Enumeration
- Assembly
- FlameCsv.Core.dll
Base class for synchronous enumerators.
public abstract class CsvEnumeratorBase<T> : IDisposable, IAsyncDisposable where T : unmanaged, IBinaryInteger<T>
Type Parameters
T
- Inheritance
-
CsvEnumeratorBase<T>
- Implements
- Derived
Constructors
CsvEnumeratorBase(CsvOptions<T>, ICsvPipeReader<T>, CancellationToken)
Creates a new instance of the enumerator.
protected CsvEnumeratorBase(CsvOptions<T> options, ICsvPipeReader<T> reader, CancellationToken cancellationToken)
Parameters
options
CsvOptions<T>Options to use for reading
reader
ICsvPipeReader<T>Data source
cancellationToken
CancellationTokenToken to cancel asynchronous enumeration
Properties
Line
The 1-based line index of the current record.
public int Line { get; }
Property Value
Options
The options used.
public CsvOptions<T> Options { get; }
Property Value
- CsvOptions<T>
Parser
The CSV parser.
protected CsvParser<T> Parser { get; }
Property Value
- CsvParser<T>
Position
The position of the reader in CSV data. This is the end position of the current record (including possible trailing newline), or 0 if the enumeration has not started.
public long Position { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
When overridden, disposes the underlying data source and internal states.
protected virtual void Dispose(bool disposing)
Parameters
disposing
bool
Remarks
The default implementation does nothing. Override both this and DisposeAsyncCore()
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
DisposeAsyncCore()
Disposes resources for inheriting classes.
protected virtual ValueTask DisposeAsyncCore()
Returns
Remarks
The default implementation does nothing. Override both this and Dispose(bool)
GetHeader()
Returns the header record's fields, or empty if none is read.
protected abstract ReadOnlySpan<string> GetHeader()
Returns
MoveNext()
Advances the enumerator to the next element of the collection.
public bool MoveNext()
Returns
- bool
true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
Exceptions
- InvalidOperationException
The collection was modified after the enumerator was created.
MoveNextAsync()
Advances the enumerator asynchronously to the next element of the collection.
public ValueTask<bool> MoveNextAsync()
Returns
- ValueTask<bool>
A ValueTask<TResult> that will complete with a result of
true
if the enumerator was successfully advanced to the next element, orfalse
if the enumerator has passed the end of the collection.
MoveNextCore(ref readonly CsvFields<T>)
Attempts to read the next CSV record from the inner parser.
protected abstract 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.
ResetCore()
Attempts to reset the enumerator to the beginning of the data source.
protected void ResetCore()
Exceptions
- NotSupportedException
The internal reader does not support rewinding
ResetHeader()
Resets the header. No-op if the header is not read.
protected abstract void ResetHeader()