toml::yaml_formatter class

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

auto some_toml = toml::parse(R"(
    [fruit]
    apple.color = "red"
    apple.taste.sweet = true

    [fruit.apple.texture]
    smooth = true
)"sv);
std::cout << toml::yaml_formatter{ some_toml } << "\n";
fruit:
  apple:
    color: red
    taste:
      sweet: true
    texture:
      smooth: true

Public static variables

static format_flags default_flags constexpr
The default flags for a yaml_formatter.

Constructors, destructors, conversion operators

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

Friends

auto operator<<(std::ostream& lhs, yaml_formatter& rhs) -> std::ostream&
Prints the bound TOML object out to the stream as YAML.
auto operator<<(std::ostream& lhs, yaml_formatter&& rhs) -> std::ostream&
Prints the bound TOML object out to the stream as YAML (rvalue overload).

Function documentation

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

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

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

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

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

Parameters
result The parse result.
flags Format option flags.