| 9 | {} |
| 10 | |
| 11 | void EELParser::loadFile(QString path) |
| 12 | { |
| 13 | container.path = path; |
| 14 | container.code = ""; |
| 15 | container.reloadCode(); |
| 16 | |
| 17 | clearProperties(); |
| 18 | |
| 19 | // Parse parameters |
| 20 | |
| 21 | QRegularExpression descRe(R"((?<var>\w+):(?<def>-?\d+\.?\d*)?<(?<min>-?\d+\.?\d*),(?<max>-?\d+\.?\d*),?(?<step>-?\d+\.?\d*)?>(?<desc>[\s\S][^\n]*))"); |
| 22 | QRegularExpression descListRe(R"((?<var>\w+):(?<def>-?\d+\.?\d*)?<(?<min>-?\d+\.?\d*),(?<max>-?\d+\.?\d*),?(?<step>-?\d+\.?\d*)?\{(?<opt>[^\}]*)\}>(?<desc>[\s\S][^\n]*))"); |
| 23 | |
| 24 | for (const auto &line : container.code.split("\n")) |
| 25 | { |
| 26 | // List parameters |
| 27 | { |
| 28 | auto matchIterator = descListRe.globalMatch(line); |
| 29 | |
| 30 | if (matchIterator.hasNext()) |
| 31 | { |
| 32 | auto match = matchIterator.next(); |
| 33 | QString key = match.captured("var"); |
| 34 | QString min = match.captured("min"); |
| 35 | QString max = match.captured("max"); |
| 36 | QString step = match.captured("step"); |
| 37 | QString opt = match.captured("opt"); |
| 38 | QString def = match.captured("def"); |
| 39 | QString desc = match.captured("desc").trimmed(); |
| 40 | |
| 41 | if (step.isEmpty()) |
| 42 | { |
| 43 | step = "1"; |
| 44 | } |
| 45 | |
| 46 | QString current = findVariable(key, EELPropertyType::List); |
| 47 | |
| 48 | if (current == NORESULT) |
| 49 | { |
| 50 | break; |
| 51 | } |
| 52 | |
| 53 | bool defOk = false; |
| 54 | std::optional<float> defaultValue = def.toFloat(&defOk); |
| 55 | if(def.isEmpty() || !defOk) |
| 56 | defaultValue = std::nullopt; |
| 57 | |
| 58 | EELListProperty *prop = new EELListProperty(key, desc, defaultValue, current.toInt(), |
| 59 | min.toInt(), max.toInt(), opt.split(',', Qt::SkipEmptyParts)); |
| 60 | properties.append(prop); |
| 61 | continue; |
| 62 | } |
| 63 | |
| 64 | } |
| 65 | |
| 66 | // Number range parameters |
| 67 | { |
| 68 | auto matchIterator = descRe.globalMatch(line); |
no test coverage detected