diff options
| author | RafaĆ <91rafalc@gmail.com> | 2025-08-30 10:23:55 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-30 11:23:55 +0300 |
| commit | e7aaccca3fa3dbde9818ab8313250f3da4976e37 (patch) | |
| tree | 3f95dc77e48d7d254d5b4a8578994491e4fc081c /include/toml++/impl | |
| parent | bf869b0e075c65aa0f81d148b42a90dcce2f95c5 (diff) | |
| download | Project-Tick-e7aaccca3fa3dbde9818ab8313250f3da4976e37.tar.gz Project-Tick-e7aaccca3fa3dbde9818ab8313250f3da4976e37.zip | |
Formatter flag to force multi-line arrays (#282)
Diffstat (limited to 'include/toml++/impl')
| -rw-r--r-- | include/toml++/impl/formatter.hpp | 6 | ||||
| -rw-r--r-- | include/toml++/impl/forward_declarations.hpp | 3 | ||||
| -rw-r--r-- | include/toml++/impl/toml_formatter.inl | 9 |
3 files changed, 14 insertions, 4 deletions
diff --git a/include/toml++/impl/formatter.hpp b/include/toml++/impl/formatter.hpp index 0c97833f29..65005b124e 100644 --- a/include/toml++/impl/formatter.hpp +++ b/include/toml++/impl/formatter.hpp @@ -130,6 +130,12 @@ TOML_IMPL_NAMESPACE_START return !!(config_.flags & format_flags::terse_key_value_pairs); } + TOML_PURE_INLINE_GETTER + bool force_multiline_arrays() const noexcept + { + return !!(config_.flags & format_flags::force_multiline_arrays); + } + TOML_EXPORTED_MEMBER_FUNCTION void attach(std::ostream& stream) noexcept; diff --git a/include/toml++/impl/forward_declarations.hpp b/include/toml++/impl/forward_declarations.hpp index 386a9e0688..f4dfe4ffd2 100644 --- a/include/toml++/impl/forward_declarations.hpp +++ b/include/toml++/impl/forward_declarations.hpp @@ -343,6 +343,9 @@ TOML_NAMESPACE_START // abi namespace /// \brief Avoids the use of whitespace around key-value pairs. terse_key_value_pairs = (1ull << 12), + + /// \brief Always print multiline arrays (one element per line). + force_multiline_arrays = (1ull << 13), }; TOML_MAKE_FLAGS(format_flags); diff --git a/include/toml++/impl/toml_formatter.inl b/include/toml++/impl/toml_formatter.inl index 8b4f633dca..bc8303248b 100644 --- a/include/toml++/impl/toml_formatter.inl +++ b/include/toml++/impl/toml_formatter.inl @@ -179,10 +179,11 @@ TOML_NAMESPACE_START } const auto original_indent = indent(); - const auto multiline = TOML_ANON_NAMESPACE::toml_formatter_forces_multiline( - arr, - 120u, - indent_columns() * static_cast<size_t>(original_indent < 0 ? 0 : original_indent)); + const auto multiline = force_multiline_arrays() + || TOML_ANON_NAMESPACE::toml_formatter_forces_multiline( + arr, + 120u, + indent_columns() * static_cast<size_t>(original_indent < 0 ? 0 : original_indent)); print_unformatted("["sv); |
