mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-31 14:01:59 +00:00
Refactor JSON::writeNext
This commit is contained in:
parent
dfa7d414f5
commit
3dde66ddcd
@ -338,7 +338,6 @@ class JSON
|
||||
static std::string encode_string(std::string const& utf8);
|
||||
static void
|
||||
writeClose(Pipeline* p, bool first, size_t depth, char const* delimeter);
|
||||
static void writeIndent(Pipeline* p, size_t depth);
|
||||
|
||||
struct JSON_value
|
||||
{
|
||||
|
@ -41,24 +41,19 @@ JSON::writeClose(Pipeline* p, bool first, size_t depth, char const* delimiter)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
JSON::writeIndent(Pipeline* p, size_t depth)
|
||||
{
|
||||
for (size_t i = 0; i < depth; ++i) {
|
||||
*p << " ";
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
JSON::writeNext(Pipeline* p, bool& first, size_t depth)
|
||||
{
|
||||
if (first) {
|
||||
first = false;
|
||||
std::string s{"\n"};
|
||||
s.append(2 * depth, ' ');
|
||||
*p << s;
|
||||
} else {
|
||||
*p << ",";
|
||||
std::string s{",\n"};
|
||||
s.append(2 * depth, ' ');
|
||||
*p << s;
|
||||
}
|
||||
*p << "\n";
|
||||
writeIndent(p, depth);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user