8#if TOML_ENABLE_FORMATTERS
17 struct formatter_constants
22 std::string_view float_pos_inf;
23 std::string_view float_neg_inf;
24 std::string_view float_nan;
26 std::string_view bool_true;
27 std::string_view bool_false;
30 struct formatter_config
33 std::string_view indent;
40#if TOML_ENABLE_PARSER && !TOML_EXCEPTIONS
43 const formatter_constants* constants_;
44 formatter_config config_;
45 size_t indent_columns_;
47 std::ostream* stream_;
53 const node& source() const noexcept
59 std::ostream& stream() const noexcept
65 int indent() const noexcept
70 void indent(
int level)
noexcept
75 void increase_indent() noexcept
80 void decrease_indent() noexcept
86 size_t indent_columns() const noexcept
88 return indent_columns_;
94 return !!(config_.flags & format_flags::indent_array_elements);
100 return !!(config_.flags & format_flags::indent_sub_tables);
104 bool literal_strings_allowed() const noexcept
106 return !!(config_.flags & format_flags::allow_literal_strings);
110 bool multi_line_strings_allowed() const noexcept
112 return !!(config_.flags & format_flags::allow_multi_line_strings);
116 bool real_tabs_in_strings_allowed() const noexcept
118 return !!(config_.flags & format_flags::allow_real_tabs_in_strings);
122 bool unicode_strings_allowed() const noexcept
124 return !!(config_.flags & format_flags::allow_unicode_strings);
128 bool terse_kvps() const noexcept
130 return !!(config_.flags & format_flags::terse_key_value_pairs);
134 void attach(std::ostream& stream)
noexcept;
137 void detach() noexcept;
140 void print_newline(
bool force = false);
146 void print_unformatted(
char);
149 void print_unformatted(
std::string_view);
152 void print_string(
std::string_view str,
153 bool allow_multi_line = true,
154 bool allow_bare = false,
155 bool allow_literal_whitespace = true);
158 void print(const value<
std::
string>&);
161 void print(const value<int64_t>&);
164 void print(const value<
double>&);
167 void print(const value<
bool>&);
170 void print(const value<date>&);
173 void print(const value<
time>&);
179 void print_value(const node&, node_type);
183 bool dump_failed_parse_result();
187 formatter(const node*, const
parse_result*, const formatter_constants&, const formatter_config&) noexcept;
193#include "header_end.hpp"
The result of a parsing operation.
Definition parse_result.hpp:53
enum TOML_CLOSED_FLAGS_ENUM format_flags
Format flags for modifying how TOML data is printed to streams.
Definition forward_declarations.hpp:297
enum TOML_CLOSED_FLAGS_ENUM indent_sub_tables
Apply indentation to tables nested within other tables/arrays.
Definition forward_declarations.hpp:330
enum TOML_CLOSED_FLAGS_ENUM indent_array_elements
Apply indentation to array elements when the array is forced to wrap over multiple lines.
Definition forward_declarations.hpp:333
#define TOML_EXPORTED_CLASS
An 'export' annotation to add to classes. \detail Not defined by default.
Definition preprocessor.hpp:979
#define TOML_EXPORTED_MEMBER_FUNCTION
An 'export' annotation to add to non-static class member functions. \detail Not defined by default.
Definition preprocessor.hpp:982
#define TOML_NODISCARD_CTOR
Definition preprocessor.hpp:446
#define TOML_NODISCARD
Definition preprocessor.hpp:439
#define TOML_PURE_INLINE_GETTER
Definition preprocessor.hpp:479
#define TOML_IMPL_NAMESPACE_END
Definition preprocessor.hpp:1334
#define TOML_IMPL_NAMESPACE_START
Definition preprocessor.hpp:1333
A date-time.
Definition date_time.hpp:327
A local time-of-day.
Definition date_time.hpp:113