diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2015-01-23 14:25:07 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-02-17 00:42:26 +0000 |
commit | 51b7bd1e4faa5111489c4376a02969ad8197fadf (patch) | |
tree | c760aa6dde8c302c1bb7b32b9800478b708b5030 /src/tools/moc/generator.cpp | |
parent | b584648df169bb9c8b67b24b4504b0fea82b093d (diff) |
Output the JSON binary data with printable characters
This makes it easier to debug QJsonDocument binary bugs.
Note that the last character is never printed as printable, but by way
of construction it's always binary data anyway (the offsets table is at
the end after parsing JSON sources).
Change-Id: I8a7a116f51864cecb52fffff13bc24ad01ad8a49
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/tools/moc/generator.cpp')
-rw-r--r-- | src/tools/moc/generator.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index bd9a002d5b..46acbc608b 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1530,7 +1530,13 @@ static void writePluginMetaData(FILE *out, const QJsonObject &data) const QByteArray binary = doc.toBinaryData(); const int last = binary.size() - 1; for (int i = 0; i < last; ++i) { - fprintf(out, " 0x%02x,", (uchar)binary.at(i)); + uchar c = (uchar)binary.at(i); + if (c < 0x20 || c >= 0x7f) + fprintf(out, " 0x%02x,", c); + else if (c == '\'' || c == '\\') + fprintf(out, " '\\%c',", c); + else + fprintf(out, " '%c', ", c); if (!((i + 1) % 8)) fputs("\n ", out); } |