template <typename Char = char>
json_formatter class final
A wrapper for printing TOML objects out to a stream as formatted JSON.
Template parameters | |
---|---|
Char | The underlying character type of the output stream. Must be 1 byte in size. |
auto some_toml = toml::parse(R"( [fruit] apple.color = "red" apple.taste.sweet = true [fruit.apple.texture] smooth = true )"sv); std::cout << toml::json_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 json_
formatter.
Constructors, destructors, conversion operators
-
json_formatter(const toml::
node& source, format_ flags flags = default_ flags) explicit noexcept - Constructs a JSON formatter and binds it to a TOML object.
-
json_formatter(const toml::
parse_result& result, format_ flags flags = default_ flags) explicit noexcept - Constructs a JSON formatter and binds it to a toml::
parse_result.
Friends
-
template <typename T, typename U>auto operator<<(std::
basic_ostream<T>&, json_ formatter<U>&) → std:: basic_ostream<T>& - Prints the bound TOML object out to the stream as JSON.
-
template <typename T, typename U>auto operator<<(std::
basic_ostream<T>&, json_ formatter<U>&&) → std:: basic_ostream<T>& - Prints the bound TOML object out to the stream as JSON (rvalue overload).
Function documentation
template <typename Char>
toml::json_formatter::json_formatter(const toml:: node& source,
format_ flags flags = default_ flags) explicit noexcept
Constructs a JSON formatter and binds it to a TOML object.
Parameters | |
---|---|
source | The source TOML object. |
flags | Format option flags. |
template <typename Char>
toml::json_formatter::json_formatter(const toml:: parse_result& result,
format_ flags flags = default_ flags) explicit noexcept
Constructs a JSON formatter and binds it to a toml::
Parameters | |
---|---|
result | The parse result. |
flags | Format option flags. |