- if (values.empty())
- return Config::Pairs();
- std::string value(values[0]);
- Config::Pairs res;
- size_t start = 0;
- while (start < value.size()) {
- Config::Pair pair;
- start = skipSpaces(value, start);
- size_t pairStart = start;
- start = checkChar(value, start, '(');
- std::pair<size_t, std::string> key = readString(value, start);
- start = key.first;
- pair.first = key.second;
- start = skipSpaces(value, start);
- start = checkChar(value, start, ',')
- start = skipSpaces(value, start);
- std::pair<size_t, std::string> value = readString(value, start);
- start = key.first;
- pair.second = value.second;
- start = skipSpaces(value, start);
- start = checkChar(value, start, ')');
- if (res.find(pair.first) != res.end())
- throw ParserError(pairStart, "Duplicate field.");
- res.insert(pair);
+ using tokenizer = boost::tokenizer<boost::char_separator<char>>;
+ const boost::char_separator<char> sep(",");
+
+ const tokenizer tokens(value, sep);
+
+ std::vector<std::pair<std::string, AttrValue>> res;
+
+ for (const auto& token : tokens)
+ {
+ std::vector<std::string> keyValue;
+
+ split(keyValue, boost::algorithm::trim_copy_if(token, boost::is_any_of(" \t")), boost::is_any_of(" ="), boost::token_compress_on);
+
+ if (keyValue.size() != 2)
+ {
+ m_logger("The '%s' attribute specification has an incorrect format: '%s'.", paramName.c_str(), token.c_str());
+ printfd(__FILE__, "The '%s' attribute specification has an incorrect format: '%s'.", paramName.c_str(), token.c_str());
+ return {};
+ }
+
+ auto type = AttrValue::Type::PARAM_NAME;
+ std::string valueName = keyValue[1];
+ if (valueName.front() == '\'' && valueName.back() == '\'')
+ {
+ type = AttrValue::Type::VALUE;
+ valueName.erase(0, 1);
+ valueName.erase(valueName.length() - 1, 1);
+ }
+ else if ((valueName.front() == '\'' && valueName.back() != '\'') || (valueName.front() != '\'' && valueName.back() == '\''))
+ {
+ m_logger("Error ParseRules: '%s' attribute parameter value is invalid.\n", paramName.c_str());
+ printfd(__FILE__, "Error ParseRules: '%s' attribute parameter value is invalid.\n", paramName.c_str());
+ return {};
+ }
+ res.emplace_back(keyValue[0], AttrValue{valueName, type});