Table of Contents

Utf8IniReader Struct

Definition

Namespace
Bodu.Text.Ini.Reader
Assembly
Bodu.Text.Ini.dll
Package
Bodu.Text.Ini 1.0.0
Source
Utf8IniReader.cs

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

data ReadOnlySpan<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

data ReadOnlySpan<byte>

The INI source bytes.

options IniReaderOptions

The 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

bool

true when a token was read; false at the end of the document.

Exceptions

IniFormatException

Thrown when the bytes are not valid INI.

Applies to

ProductVersions
.NET8, 10