MCPcopy Create free account
hub / github.com/KDE/labplot / getParameter

Method getParameter

src/backend/gsl/ExpressionParser.cpp:323–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321}
322
323QStringList ExpressionParser::getParameter(const QString& expr, const QStringList& vars) {
324 QDEBUG(Q_FUNC_INFO << ", variables:" << vars);
325 QStringList parameters;
326
327 QStringList strings = expr.split(QRegularExpression(QStringLiteral("\\W+")), Qt::SkipEmptyParts);
328 QDEBUG(Q_FUNC_INFO << ", found strings:" << strings);
329 // RE for any number
330 const QRegularExpression re(QRegularExpression::anchoredPattern(QStringLiteral("[0-9]*")));
331 for (const QString& string : strings) {
332 QDEBUG(string << ':' << constants().indexOf(string) << ' ' << functions().indexOf(string) << ' ' << vars.indexOf(string) << ' '
333 << re.match(string).hasMatch());
334 // check if token is not a known constant/function/variable or number
335 if (constants().indexOf(string) == -1 && functions().indexOf(string) == -1 && vars.indexOf(string) == -1 && re.match(string).hasMatch() == false)
336 parameters << string;
337 }
338 parameters.removeDuplicates();
339 QDEBUG(Q_FUNC_INFO << ", parameters found:" << parameters);
340
341 return parameters;
342}
343
344/*
345 * Evaluate cartesian expression returning true on success and false if parsing fails

Callers 1

updateParameterListMethod · 0.80

Calls 2

splitMethod · 0.80
indexOfMethod · 0.45

Tested by

no test coverage detected