Struct CsvRecordRef<T>
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
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
indexintZero-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
LineNumber
Returns the 1-based line number of the record in the source data.
public int LineNumber { get; }
Property Value
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
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
indexintZero-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
indexintZero-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
indexintZero-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
GetRecordLength()
Returns length of the raw record, not including possible trailing newline.
public int GetRecordLength()
Returns
ToString()
Returns a diagnostic string representation of the current instance.
public override string ToString()
Returns
Remarks
See Raw to get the actual record span.
ValidateAllFields()
Validates quotes in all fields.
[EditorBrowsable(EditorBrowsableState.Never)]
public void ValidateAllFields()
Exceptions
ValidateFieldsUnsafe(params ReadOnlySpan<int>)
Validates quotes in the fields at the specified indexes.
[EditorBrowsable(EditorBrowsableState.Never)]
public void ValidateFieldsUnsafe(params ReadOnlySpan<int> indexes)
Parameters
indexesReadOnlySpan<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.