8#if TOML_ENABLE_FORMATTERS
16 struct formatter_constants {
20 std::string_view float_pos_inf;
21 std::string_view float_neg_inf;
22 std::string_view float_nan;
24 std::string_view bool_true;
25 std::string_view bool_false;
28 struct formatter_config {
30 std::string_view indent;
36#if TOML_ENABLE_PARSER && !TOML_EXCEPTIONS
39 const formatter_constants* constants_;
40 formatter_config config_;
41 size_t indent_columns_;
43 std::ostream* stream_;
49 const node& source() const noexcept {
return *source_; }
52 std::ostream&
stream() const noexcept {
return *stream_; }
55 int indent() const noexcept {
return indent_; }
57 void indent(
int level)
noexcept { indent_ = level; }
59 void increase_indent() noexcept { indent_++; }
61 void decrease_indent() noexcept { indent_--; }
64 size_t indent_columns() const noexcept {
return indent_columns_; }
68 return !!(config_.flags & format_flags::indent_array_elements);
73 return !!(config_.flags & format_flags::indent_sub_tables);
77 bool literal_strings_allowed() const noexcept {
78 return !!(config_.flags & format_flags::allow_literal_strings);
82 bool multi_line_strings_allowed() const noexcept {
83 return !!(config_.flags & format_flags::allow_multi_line_strings);
87 bool real_tabs_in_strings_allowed() const noexcept {
88 return !!(config_.flags & format_flags::allow_real_tabs_in_strings);
92 bool unicode_strings_allowed() const noexcept {
93 return !!(config_.flags & format_flags::allow_unicode_strings);
97 bool terse_kvps() const noexcept {
98 return !!(config_.flags & format_flags::terse_key_value_pairs);
102 void attach(std::ostream&
stream)
noexcept;
105 void detach() noexcept;
108 void print_newline(
bool force =
false);
114 void print_unformatted(
char);
117 void print_unformatted(
std::string_view);
120 void print_string(
std::string_view
str,
bool allow_multi_line =
true,
bool allow_bare =
false,
121 bool allow_literal_whitespace =
true);
145 void print_value(const node&, node_type);
149 bool dump_failed_parse_result();
153 formatter(const node*, const
parse_result*, const formatter_constants&,
154 const formatter_config&) noexcept;
160#include "header_end.hpp"
The result of a parsing operation.
enum TOML_CLOSED_FLAGS_ENUM format_flags
Format flags for modifying how TOML data is printed to streams.
enum TOML_CLOSED_FLAGS_ENUM indent_sub_tables
Apply indentation to tables nested within other tables/arrays.
enum TOML_CLOSED_FLAGS_ENUM indent_array_elements
Apply indentation to array elements when the array is forced to wrap over multiple lines.
#define TOML_EXPORTED_CLASS
An 'export' annotation to add to classes. \detail Not defined by default.
#define TOML_EXPORTED_MEMBER_FUNCTION
An 'export' annotation to add to non-static class member functions. \detail Not defined by default.
#define TOML_NODISCARD_CTOR
#define TOML_PURE_INLINE_GETTER
#define TOML_IMPL_NAMESPACE_END
#define TOML_IMPL_NAMESPACE_START