MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / applyTransformScript

Function applyTransformScript

app/src/AI/ToolDispatcher.cpp:1248–1278  ·  view source on GitHub ↗

* @brief Applies a transform script to its target dataset, optionally promoting it to virtual. */

Source from the content-addressed store, hash-verified

1246 * @brief Applies a transform script to its target dataset, optionally promoting it to virtual.
1247 */
1248static QJsonObject applyTransformScript(const QJsonObject& args,
1249 const QJsonObject& dryRun,
1250 int language)
1251{
1252 const auto target = scriptTargetDataset(args);
1253 if (!target.value(QStringLiteral("ok")).toBool())
1254 return target;
1255
1256 const auto dataset = target.value(QStringLiteral("dataset")).toObject();
1257 const int groupId = dataset.value(QStringLiteral("groupId")).toInt();
1258 const int datasetId = dataset.value(Keys::DatasetId).toInt();
1259
1260 QJsonArray steps;
1261 const auto virtualReply = maybeMarkDatasetVirtual(args, groupId, datasetId, steps);
1262 if (!virtualReply.isEmpty() && !virtualReply.value(QStringLiteral("ok")).toBool())
1263 return attachRepairHint(virtualReply, QStringLiteral("project.dataset.setVirtual"));
1264
1265 QJsonObject applyArgs;
1266 applyArgs[QStringLiteral("code")] = args.value(QStringLiteral("code")).toString();
1267 applyArgs[QStringLiteral("groupId")] = groupId;
1268 applyArgs[Keys::DatasetId] = datasetId;
1269 applyArgs[QStringLiteral("language")] = language;
1270
1271 const QString command = QStringLiteral("project.dataset.setTransformCode");
1272 auto applyReply = runCommand(command, applyArgs);
1273 applyReply[QStringLiteral("dryRun")] = dryRun;
1274 if (!steps.isEmpty())
1275 applyReply[QStringLiteral("steps")] = steps;
1276
1277 return attachRepairHint(applyReply, command);
1278}
1279
1280/**
1281 * @brief Applies a frame-parser script, forwarding optional sourceId to the API.

Callers 1

executeScriptApplyFunction · 0.85

Calls 6

scriptTargetDatasetFunction · 0.85
maybeMarkDatasetVirtualFunction · 0.85
attachRepairHintFunction · 0.85
runCommandFunction · 0.85
isEmptyMethod · 0.80
valueMethod · 0.45

Tested by

no test coverage detected