1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "propertyprinter.h"
5
6#include <iostream>
7
8#include <QJsonDocument>
9#include <QJsonObject>
10#include <QJsonValue>
11
12QT_BEGIN_NAMESPACE
13
14void qmakePropertyPrinter(const QList<QPair<QString, QString>> &values)
15{
16 // Assume single property request
17 if (values.size() == 1) {
18 std::cout << qPrintable(values.at(0).second) << std::endl;
19 return;
20 }
21
22 for (const auto &val : values) {
23 std::cout << qPrintable(val.first) << ":" << qPrintable(val.second) << std::endl;
24 }
25}
26
27void jsonPropertyPrinter(const QList<QPair<QString, QString>> &values)
28{
29 QJsonObject object;
30 for (const auto &val : values)
31 object.insert(key: val.first, value: val.second);
32
33 QJsonDocument document(object);
34 std::cout << document.toJson().constData();
35}
36
37QT_END_NAMESPACE
38

source code of qtbase/qmake/propertyprinter.cpp