Utf8IniReader Struct
Definition
Provides a high-performance, forward-only, source-order reader for INI bytes. The reader is a
ref struct, so it lives on the stack and cannot be boxed or captured.
public ref struct Utf8IniReader
- Inherited Members
Remarks
A call to Read() advances to the next token and reports it through TokenType: a SectionHeader begins a section, each entry surfaces a PropertyName followed by a String value, and comment lines appear as Comment tokens. Keys read before the first section header belong to the global section.
The reader surfaces raw text in source order; it does not resolve duplicate sections/keys, apply case rules, or strip inline comments. A value retains everything after the assignment to the end of the line.
Constructors
Utf8IniReader(ReadOnlySpan<byte>)
Initializes a new instance of the Utf8IniReader struct over the supplied bytes.
public Utf8IniReader(ReadOnlySpan<byte> data)
Parameters
dataReadOnlySpan<byte>The INI source bytes.
Utf8IniReader(ReadOnlySpan<byte>, IniReaderOptions)
Initializes a new instance of the Utf8IniReader struct over the supplied bytes using the supplied options.
public Utf8IniReader(ReadOnlySpan<byte> data, IniReaderOptions options)
Parameters
dataReadOnlySpan<byte>The INI source bytes.
optionsIniReaderOptionsThe reader options.
Properties
BytesConsumed
Gets the number of bytes consumed so far.
public readonly int BytesConsumed { get; }
Property Value
- int
The read position.
LineNumber
Gets the 1-based line number at which the current token begins.
public readonly int LineNumber { get; }
Property Value
- int
The current line number.
TokenType
Gets the kind of the current token.
public readonly IniTokenType TokenType { get; }
Property Value
- IniTokenType
The current token kind.
Methods
GetString()
Gets the decoded text of the current token - a section name, key name, string value, or comment.
public readonly string GetString()
Returns
- string
The token text.
Exceptions
- InvalidOperationException
Thrown when the current token has no text.
Read()
Advances the reader to the next token.
public bool Read()
Returns
Exceptions
- IniFormatException
Thrown when the bytes are not valid INI.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |