Table of Contents

Utf8IniWriter Struct

Definition

Namespace
Bodu.Text.Ini.Writer
Assembly
Bodu.Text.Ini.dll
Package
Bodu.Text.Ini 1.0.0
Source
Utf8IniWriter.cs

Provides a forward-only writer that emits INI text as UTF-8 bytes to an IBufferWriter<T> or a Stream. The writer is a ref struct.

public ref struct Utf8IniWriter
Inherited Members

Remarks

INI is line-oriented, so the writer emits progressively: WriteSectionHeader(string) produces a [name] line, WritePropertyName(string) followed by WriteString(string) produces one key=value line, and WriteComment(string) produces one comment line.

Constructors

Utf8IniWriter(IBufferWriter<byte>)

Initializes a new instance of the Utf8IniWriter struct that writes to the supplied buffer.

public Utf8IniWriter(IBufferWriter<byte> output)

Parameters

output IBufferWriter<byte>

The destination buffer writer.

Exceptions

ArgumentNullException

Thrown when output is null.

Utf8IniWriter(IBufferWriter<byte>, IniWriterOptions)

Initializes a new instance of the Utf8IniWriter struct that writes to the supplied buffer using the supplied options.

public Utf8IniWriter(IBufferWriter<byte> output, IniWriterOptions options)

Parameters

output IBufferWriter<byte>

The destination buffer writer.

options IniWriterOptions

The writer options.

Exceptions

ArgumentNullException

Thrown when output is null.

Utf8IniWriter(Stream)

Initializes a new instance of the Utf8IniWriter struct that writes to the supplied stream.

public Utf8IniWriter(Stream stream)

Parameters

stream Stream

The destination stream.

Exceptions

ArgumentNullException

Thrown when stream is null.

Utf8IniWriter(Stream, IniWriterOptions)

Initializes a new instance of the Utf8IniWriter struct that writes to the supplied stream using the supplied options.

public Utf8IniWriter(Stream stream, IniWriterOptions options)

Parameters

stream Stream

The destination stream.

options IniWriterOptions

The writer options.

Exceptions

ArgumentNullException

Thrown when stream is null.

Properties

BytesCommitted

Gets the number of bytes flushed to the destination.

public readonly long BytesCommitted { get; }

Property Value

long

The committed byte count.

BytesPending

Gets the number of bytes written but not yet flushed to the destination.

public readonly long BytesPending { get; }

Property Value

long

The pending byte count; always zero in direct buffer-writer mode.

Methods

Dispose()

Flushes any buffered bytes and releases the writer.

public void Dispose()

Flush()

Flushes any buffered bytes to the destination stream. This method is a no-op in direct buffer-writer mode.

public void Flush()

WriteComment(string)

Writes a comment line prefixed with the configured comment character, followed by a line feed.

public void WriteComment(string text)

Parameters

text string

The comment text, without the leading prefix.

Exceptions

ArgumentNullException

Thrown when text is null.

WritePropertyName(string)

Writes a key name, followed by the = assignment. Call WriteString(string) next to write the value.

public void WritePropertyName(string name)

Parameters

name string

The key name.

Exceptions

ArgumentNullException

Thrown when name is null.

WriteSectionHeader(string)

Writes a section header line ([name]).

public void WriteSectionHeader(string name)

Parameters

name string

The section name.

Exceptions

ArgumentNullException

Thrown when name is null.

WriteString(string)

Writes a string value, followed by a line feed.

public void WriteString(string value)

Parameters

value string

The value to write.

Exceptions

ArgumentNullException

Thrown when value is null.

Applies to

ProductVersions
.NET8, 10