Chlumsky/json-cpp-gen

Format multi-statement API commands

Chlumsky opened this issue · 0 comments

Some of the API commands, especially iteration for the serializer, tend to result in a long string of commands on a single line (example below). This is not only ugly but also inconsistent with the format of the rest of the generated code, which is formatted very strictly. Simply adding newlines would not be a solution because the indentation would still be messed up. I think it would be best if newlines and indentation would be added as a post-process step to pattern fill.

api.iterateElements = "for (const std::pair<$U, $T> &$I : $S) { $U const &$K = $I.first; $T const &$V = $I.second; $F }";

for (const std::pair<std::string, float> &i : value) { std::string const &key = i.first; float const &elem = i.second; if (prev) write(','); prev = true; serializeStdString(key); write(':'); serializeFloat(elem); }