Bodu.Text.Ini.Writer Namespace
- Package
-
Bodu.Text.Ini 1.0.0
Purpose
Bodu.Text.Ini.Writer is the emitting counterpart of Bodu.Text.Ini.Reader in Bodu.Text.Ini: a forward-only writer that produces INI text as UTF-8 into an IBufferWriter<byte> or a Stream, one line per call. The IniSerializer and the comment-preserving IniNode DOM (WriteTo) emit through it.
Key types
- Utf8IniWriter - the
ref structwriter:WriteSectionHeaderfor a[name]line,WritePropertyNamefollowed byWriteStringfor onekey=valueline,WriteCommentfor a comment line, plusFlush,Dispose,BytesCommitted, andBytesPending. - IniWriterOptions -
CommentPrefix, the character (;by default) placed before comment text.
Example
using System.Buffers;
using Bodu.Text.Ini.Writer;
var buffer = new ArrayBufferWriter<byte>();
var writer = new Utf8IniWriter(buffer, new IniWriterOptions { CommentPrefix = '#' });
writer.WriteComment("generated by deploy");
writer.WriteSectionHeader("server");
writer.WritePropertyName("host");
writer.WriteString("localhost");
writer.WritePropertyName("port");
writer.WriteString("8080");
writer.Flush();
// # generated by deploy
// [server]
// host=localhost
// port=8080
Notes
- Global entries first. Any
WritePropertyName/WriteStringpair before the firstWriteSectionHeaderlands in the global (section-less) area. - Literal values. Values are written verbatim to end of line - there is no quoting layer in the INI dialect, so a value must not contain a line break.
- Flush to commit. Bytes are staged until
Flush(orDispose). - See also: the line-formats introduction and the INI guide.
Structs
- IniWriterOptions
Provides configuration for a Utf8IniWriter, controlling the comment prefix.
- Utf8IniWriter
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.