Skip to content

Toml Serializer

Spice
import "std/text/toml-serializer";

TomlSerializer struct

Serializer for TOML output.

By default sub-tables are emitted as [table] sections and arrays that only contain tables as [[array of table]] sections, which is how TOML documents are usually written. With inlineTables enabled everything is emitted as key = value lines instead, using inline tables for nested structures.

Either way the result round-trips through parseToml from "std/text/toml-parser".

Constructors

ctor

Spice
public p TomlSerializer.ctor(bool inlineTables = false)

Construct a TOML serializer

Parameters

Name Type Description
inlineTables bool Emit nested tables inline instead of as separate sections (default: false)

Methods

serialize

Spice
public f<String> TomlSerializer.serialize(TomlValue& root)

Serializes a TOML table into a TOML document

Parameters

Name Type Description
root TomlValue& Root table to serialize

Returns: String — TOML representation

serialize

Spice
public f<String> TomlSerializer.serialize(TomlValue* root)

Serializes a TOML table into a TOML document

Parameters

Name Type Description
root TomlValue* Root table to serialize

Returns: String — TOML representation

serializeValue

Spice
public f<String> TomlSerializer.serializeValue(TomlValue* value)

Serializes a single TOML value in its inline form, as it would appear on the right hand side of a key = value pair

Parameters

Name Type Description
value TomlValue* Value to serialize

Returns: String — TOML representation