aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cmakeprojectmanager/cmaketool.cpp
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2018-07-10 14:03:55 +0200
committerTobias Hunger <tobias.hunger@qt.io>2018-07-11 08:30:50 +0000
commit7478c4aef1aa29ed7fb94e5b749b73d11ba00d2a (patch)
tree0d65b5539e274d381e9be432efbde94c2402cf96 /src/plugins/cmakeprojectmanager/cmaketool.cpp
parent942bd5f74b7da70ddc5e4ebed527f3d33f8c9919 (diff)
CMakeTool: Split parsing out of data retrievel methods
Change-Id: I237d90310bc032b7537ab33e0cb181e2163be5a7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/plugins/cmakeprojectmanager/cmaketool.cpp')
-rw-r--r--src/plugins/cmakeprojectmanager/cmaketool.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmaketool.cpp b/src/plugins/cmakeprojectmanager/cmaketool.cpp
index e123bd4e5a6..c096a6a29d0 100644
--- a/src/plugins/cmakeprojectmanager/cmaketool.cpp
+++ b/src/plugins/cmakeprojectmanager/cmaketool.cpp
@@ -374,10 +374,13 @@ void CMakeTool::fetchGeneratorsFromHelp() const
Utils::SynchronousProcessResponse response = run({"--help"});
if (response.result != Utils::SynchronousProcessResponse::Finished)
return;
+ parseGeneratorsFromHelp(response.stdOut().split('\n'));
+}
+void CMakeTool::parseGeneratorsFromHelp(const QStringList &lines) const
+{
bool inGeneratorSection = false;
QHash<QString, QStringList> generatorInfo;
- const QStringList lines = response.stdOut().split('\n');
foreach (const QString &line, lines) {
if (line.isEmpty())
continue;
@@ -427,9 +430,13 @@ void CMakeTool::fetchVersionFromVersionOutput() const
if (response.result != Utils::SynchronousProcessResponse::Finished)
return;
+ parseVersionFormVersionOutput(response.stdOut().split('\n'));
+}
+
+void CMakeTool::parseVersionFormVersionOutput(const QStringList &lines) const
+{
QRegularExpression versionLine("^cmake.* version ((\\d+).(\\d+).(\\d+).*)$");
- const QString responseText = response.stdOut();
- for (const QStringRef &line : responseText.splitRef(QLatin1Char('\n'))) {
+ for (const QString &line : lines) {
QRegularExpressionMatch match = versionLine.match(line);
if (!match.hasMatch())
continue;
@@ -448,7 +455,12 @@ void CMakeTool::fetchFromCapabilities() const
if (response.result != Utils::SynchronousProcessResponse::Finished)
return;
- auto doc = QJsonDocument::fromJson(response.stdOut().toUtf8());
+ parseFromCapabilities(response.stdOut());
+}
+
+void CMakeTool::parseFromCapabilities(const QString &input) const
+{
+ auto doc = QJsonDocument::fromJson(input.toUtf8());
if (!doc.isObject())
return;