diff options
author | Brett Stottlemyer <bstottle@ford.com> | 2021-08-10 10:53:03 -0400 |
---|---|---|
committer | Brett Stottlemyer <bstottle@ford.com> | 2021-08-10 11:52:57 -0400 |
commit | 1e771002440b3d6dee2cbfad1b42c888b037b860 (patch) | |
tree | 0c94b2a6428d8486406d2044a1e5f08f94b8869f /tools/repc/repcodegenerator.cpp | |
parent | e0e361b4b8551b35cb04eeb069fa02142ecfb758 (diff) |
Generate a qDebug output for PODs
We have one for dynamic PODs, we should have one for compiled code too.
Pick-to: 6.2
Change-Id: I7909f8e04e896e97d8d6a6f2fe7c1177682561b4
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'tools/repc/repcodegenerator.cpp')
-rw-r--r-- | tools/repc/repcodegenerator.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/repc/repcodegenerator.cpp b/tools/repc/repcodegenerator.cpp index ff4fbd1..33b025c 100644 --- a/tools/repc/repcodegenerator.cpp +++ b/tools/repc/repcodegenerator.cpp @@ -385,6 +385,21 @@ QString RepCodeGenerator::formatDataMembers(const POD &pod) return out; } +QString RepCodeGenerator::formatDebugOperator(const POD &pod) +{ + QString props; + int count = 0; + for (const PODAttribute &attribute : pod.attributes) { + if (count++ > 0) + props.append(QLatin1String(" << \", \"")); + props.append(QLatin1String(" << \"%1: \" << obj.%1()").arg(attribute.name)); + } + + return QLatin1String("inline QDebug operator<<(QDebug dbg, const %1 &obj) {\n" \ + " dbg.nospace() << \"%1(\" %2 << \")\";\n" \ + " return dbg.maybeSpace();\n}\n\n").arg(pod.name, props); +} + QString RepCodeGenerator::formatMarshallingOperators(const POD &pod) { return QLatin1String("inline QDataStream &operator<<(QDataStream &ds, const ") + pod.name + QLatin1String(" &obj) {\n" @@ -464,6 +479,7 @@ void RepCodeGenerator::generatePOD(QTextStream &out, const POD &pod) << " return !(left == right);\n" << "}\n" << "\n" + << formatDebugOperator(pod) << formatMarshallingOperators(pod) << "\n" "\n" |