nlohmann::json parseSonataJson(const std::string& uri) { // Reading the input file into a string std::ifstream file(uri); if (file.fail()) throw std::runtime_error("Could not open file `" + uri + "`"); // Parsing const auto json = nlohmann::json::parse(file); // Parsing manifest and expanding all variables const auto vars = _replaceVariables(_readVariables(json)); return _expandVariables(json, vars); }
QVariant Settings::get(const QString& key) const { if (hasKey(key) == false) { throw HootException("Error finding key: " + key); } QVariant result = _settings.value(key); if (result.type() == QVariant::String) { std::set<QString> used; QString r = _replaceVariables(key, used); result = r; } return result; }
QString Settings::_replaceVariablesValue(QString value, std::set<QString> used) const { bool done = false; while (!done) { done = true; int offset = 0; if (_dynamicRegex.indexIn(value, offset) >= 0) { offset += _dynamicRegex.matchedLength(); QString varStr = _dynamicRegex.capturedTexts()[0]; QString subKey = _dynamicRegex.capturedTexts()[1]; QString expanded = _replaceVariables(subKey, used); value.replace(varStr, expanded); done = false; } } return value; }