Table of Contents

Struct CsvRecordRef<T>

Namespace
FlameCsv.Reading
Assembly
FlameCsv.Core.dll

Internal implementation detail. This type should be used with care.

[EditorBrowsable(EditorBrowsableState.Never)]
public readonly ref struct CsvRecordRef<T> where T : unmanaged, IBinaryInteger<T>

Type Parameters

T

Properties

FieldCount

Gets the number of fields in the record.

public int FieldCount { get; }

Property Value

int

Remarks

For a valid record, this is never zero.

this[int]

Returns the field at index, unescaping and trimming it as per the current dialect settings.

public ReadOnlySpan<T> this[int index] { get; }

Parameters

index int

Zero-based index of the field to get.

Property Value

ReadOnlySpan<T>

Remarks

The returned span is only guaranteed to be valid until another field or the next record is read.

Exceptions

IndexOutOfRangeException

LineNumber

Returns the 1-based line number of the record in the source data.

public int LineNumber { get; }

Property Value

int

Remarks

Lines are counted as CSV records; newlines inside quoted fields are not counted.

Position

Returns the 0-based position of the start of the first field of the record in the source data.

public long Position { get; }

Property Value

long

Remarks

If T is char, this is the character position, even if the data is from a byte stream.

Raw

Data of the raw record, not including possible trailing newline.

public ReadOnlySpan<T> Raw { get; }

Property Value

ReadOnlySpan<T>

Methods

GetFieldUnsafe(int)

Returns the field at index without bounds checks, unescaping and trimming it as per the current dialect settings.

[EditorBrowsable(EditorBrowsableState.Never)]
public ReadOnlySpan<T> GetFieldUnsafe(int index)

Parameters

index int

Zero-based index of the field to get.

Returns

ReadOnlySpan<T>

Remarks

The returned span is only guaranteed to be valid until another field or the next record is read.
This method does not perform any bounds checking on index, and is only intended to be used by internal code and the source generator, or after validating FieldCount.

GetMetadata(int)

Returns metadata about the field at index.

public CsvFieldMetadata GetMetadata(int index)

Parameters

index int

Zero-based index of the field to get.

Returns

CsvFieldMetadata

The raw length of the field, whether it has quotes, and whether it needs unescaping.

GetRawSpan(int)

Returns the raw unescaped field at index.

public ReadOnlySpan<T> GetRawSpan(int index)

Parameters

index int

Zero-based index of the field to get.

Returns

ReadOnlySpan<T>

Remarks

The returned span is only guaranteed to be valid until the next record is read.

Exceptions

IndexOutOfRangeException

GetRecordLength()

Returns length of the raw record, not including possible trailing newline.

public int GetRecordLength()

Returns

int

ToString()

Returns a diagnostic string representation of the current instance.

public override string ToString()

Returns

string

Remarks

See Raw to get the actual record span.

ValidateAllFields()

Validates quotes in all fields.

[EditorBrowsable(EditorBrowsableState.Never)]
public void ValidateAllFields()

Exceptions

CsvFormatException

ValidateFieldsUnsafe(params ReadOnlySpan<int>)

Validates quotes in the fields at the specified indexes.

[EditorBrowsable(EditorBrowsableState.Never)]
public void ValidateFieldsUnsafe(params ReadOnlySpan<int> indexes)

Parameters

indexes ReadOnlySpan<int>

Zero-based indexes of the fields to validate.

Remarks

This method does not perform any bounds checking on indexes, and is only intended to be used by internal code and the source generator, or after validating FieldCount.

Exceptions

CsvFormatException