summaryrefslogtreecommitdiffstats
path: root/qmake/propertyprinter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qmake/propertyprinter.cpp')
-rw-r--r--qmake/propertyprinter.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/qmake/propertyprinter.cpp b/qmake/propertyprinter.cpp
new file mode 100644
index 0000000000..52a790e2c8
--- /dev/null
+++ b/qmake/propertyprinter.cpp
@@ -0,0 +1,37 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include "propertyprinter.h"
+
+#include <iostream>
+
+#include <QJsonDocument>
+#include <QJsonObject>
+#include <QJsonValue>
+
+QT_BEGIN_NAMESPACE
+
+void qmakePropertyPrinter(const QList<QPair<QString, QString>> &values)
+{
+ // Assume single property request
+ if (values.size() == 1) {
+ std::cout << qPrintable(values.at(0).second) << std::endl;
+ return;
+ }
+
+ for (const auto &val : values) {
+ std::cout << qPrintable(val.first) << ":" << qPrintable(val.second) << std::endl;
+ }
+}
+
+void jsonPropertyPrinter(const QList<QPair<QString, QString>> &values)
+{
+ QJsonObject object;
+ for (const auto &val : values)
+ object.insert(val.first, val.second);
+
+ QJsonDocument document(object);
+ std::cout << document.toJson().constData();
+}
+
+QT_END_NAMESPACE