sexp: allow for some prettified string output

Allow for adding newlines between list items
This commit is contained in:
Dirk-Jan C. Binnema
2022-05-06 22:07:15 +03:00
parent 2a5c1e239c
commit da8489d0f6
5 changed files with 86 additions and 27 deletions

View File

@ -188,6 +188,9 @@ Sexp::to_sexp_string() const
first = false;
}
sstrm << ')';
if (any_of(formatting_opts & FormattingOptions::SplitList))
sstrm << '\n';
break;
}
case Type::String:
@ -225,6 +228,8 @@ Sexp::to_json_string() const
first = false;
}
sstrm << "}";
if (any_of(formatting_opts & FormattingOptions::SplitList))
sstrm << '\n';
} else { // other lists become arrays.
sstrm << '[';
bool first{true};
@ -233,6 +238,8 @@ Sexp::to_json_string() const
first = false;
}
sstrm << ']';
if (any_of(formatting_opts & FormattingOptions::SplitList))
sstrm << '\n';
}
break;
}