toml::toml_formatter class

A wrapper for printing TOML objects out to a stream as formatted TOML.

auto tbl = toml::table{
    { "description", "This is some TOML, yo." },
    { "fruit", toml::array{ "apple", "orange", "pear" } },
    { "numbers", toml::array{ 1, 2, 3, 4, 5 } },
    { "table", toml::table{ { "foo", "bar" } } }
};

// these two lines are equivalent:
std::cout << toml::toml_formatter{ tbl } << "\n";
std::cout << tbl << "\n";
description = "This is some TOML, yo."
fruit = ["apple", "orange", "pear"]
numbers = [1, 2, 3, 4, 5]

[table]
foo = "bar"

Public static variables

static format_flags default_flags constexpr
The default flags for a toml_formatter.

Constructors, destructors, conversion operators

toml_formatter(const toml::node& source, format_flags flags = default_flags) explicit noexcept
Constructs a TOML formatter and binds it to a TOML object.
toml_formatter(const toml::parse_result& result, format_flags flags = default_flags) explicit noexcept
Constructs a TOML formatter and binds it to a toml::parse_result.

Friends

auto operator<<(std::ostream& lhs, toml_formatter& rhs) →  std::ostream&
Prints the bound TOML object out to the stream as formatted TOML.
auto operator<<(std::ostream& lhs, toml_formatter&& rhs) →  std::ostream&
Prints the bound TOML object out to the stream as formatted TOML (rvalue overload).

Function documentation

toml::toml_formatter::toml_formatter(const toml::node& source, format_flags flags = default_flags) explicit noexcept

Constructs a TOML formatter and binds it to a TOML object.

Parameters
source The source TOML object.
flags Format option flags.

toml::toml_formatter::toml_formatter(const toml::parse_result& result, format_flags flags = default_flags) explicit noexcept

Constructs a TOML formatter and binds it to a toml::parse_result.

Parameters
result The parse result.
flags Format option flags.