mirror of https://github.com/qpdf/qpdf.git
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 std::string encode_string(std::string const& utf8);
|
||||||
static void
|
static void
|
||||||
writeClose(Pipeline* p, bool first, size_t depth, char const* delimeter);
|
writeClose(Pipeline* p, bool first, size_t depth, char const* delimeter);
|
||||||
static void writeIndent(Pipeline* p, size_t depth);
|
|
||||||
|
|
||||||
struct JSON_value
|
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
|
void
|
||||||
JSON::writeNext(Pipeline* p, bool& first, size_t depth)
|
JSON::writeNext(Pipeline* p, bool& first, size_t depth)
|
||||||
{
|
{
|
||||||
if (first) {
|
if (first) {
|
||||||
first = false;
|
first = false;
|
||||||
|
std::string s{"\n"};
|
||||||
|
s.append(2 * depth, ' ');
|
||||||
|
*p << s;
|
||||||
} else {
|
} else {
|
||||||
*p << ",";
|
std::string s{",\n"};
|
||||||
|
s.append(2 * depth, ' ');
|
||||||
|
*p << s;
|
||||||
}
|
}
|
||||||
*p << "\n";
|
|
||||||
writeIndent(p, depth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue