| 12 | QRegularExpression rule_re = QRegularExpression(R"((\S+?)\s*:\s*(?:\"(.*?)(?<!\\)\"|'(.*?)(?<!\\)'|(\S+?))\s*(?:;|$))"); |
| 13 | |
| 14 | QDCSS::QDCSS(QString s) |
| 15 | { |
| 16 | // not much error handling over here... |
| 17 | // the original java code used indeces returned by the matcher for them, but QRE does not expose those |
| 18 | QRegularExpressionMatchIterator ruleset_i = ruleset_re.globalMatch(s); |
| 19 | while (ruleset_i.hasNext()) { |
| 20 | QRegularExpressionMatch ruleset = ruleset_i.next(); |
| 21 | QString selector = ruleset.captured(1); |
| 22 | QString rules = ruleset.captured(2); |
| 23 | QRegularExpressionMatchIterator rule_i = rule_re.globalMatch(rules); |
| 24 | while (rule_i.hasNext()) { |
| 25 | QRegularExpressionMatch rule = rule_i.next(); |
| 26 | QString property = rule.captured(1); |
| 27 | QString value; |
| 28 | if (!rule.captured(2).isNull()) { |
| 29 | value = rule.captured(2); |
| 30 | } else if (!rule.captured(3).isNull()) { |
| 31 | value = rule.captured(3); |
| 32 | } else { |
| 33 | value = rule.captured(4); |
| 34 | } |
| 35 | QString key = selector + "." + property; |
| 36 | if (!m_data.contains(key)) { |
| 37 | m_data.insert(key, QStringList()); |
| 38 | } |
| 39 | m_data.find(key)->append(value); |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | std::optional<QString>* QDCSS::get(QString key) |
| 45 | { |