Tidy config file format.
This commit is contained in:
@@ -77,9 +77,7 @@ std::string multi2string(std::vector<std::string> values)
|
||||
std::string result;
|
||||
for (const auto& value : values) {
|
||||
// remove any " contained in the string value, if present
|
||||
std::string quoteless_value = value;
|
||||
quoteless_value.erase(std::remove(quoteless_value.begin(), quoteless_value.end(), '"'), quoteless_value.end());
|
||||
result += "\"" + trim(quoteless_value) + "\",";
|
||||
result += dequote(trim(value)) + ",";
|
||||
}
|
||||
if (!result.empty())
|
||||
result.pop_back(); // Remove the last comma
|
||||
@@ -91,6 +89,8 @@ std::vector<std::string> string2multi(std::string values)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
|
||||
values = dequote(trim(values));
|
||||
|
||||
// Return values separated by commas, but ignore commas within quotes
|
||||
bool inside_quotes = false;
|
||||
std::string current_item;
|
||||
@@ -100,14 +100,9 @@ std::vector<std::string> string2multi(std::string values)
|
||||
inside_quotes = !inside_quotes;
|
||||
} else if (c == ',' && !inside_quotes) {
|
||||
if (!current_item.empty()) {
|
||||
// Remove quotes if present
|
||||
if (current_item.front() == '"' && current_item.back() == '"') {
|
||||
current_item = current_item.substr(1, current_item.length() - 2);
|
||||
}
|
||||
std::string final = trim(current_item);
|
||||
if (!final.empty()) {
|
||||
std::string final = dequote(trim(current_item));
|
||||
if (!final.empty())
|
||||
result.push_back(final);
|
||||
}
|
||||
current_item.clear();
|
||||
}
|
||||
} else {
|
||||
@@ -117,14 +112,9 @@ std::vector<std::string> string2multi(std::string values)
|
||||
|
||||
// Add the last item if not empty
|
||||
if (!current_item.empty()) {
|
||||
// Remove quotes if present
|
||||
if (current_item.front() == '"' && current_item.back() == '"') {
|
||||
current_item = current_item.substr(1, current_item.length() - 2);
|
||||
}
|
||||
std::string final = trim(current_item);
|
||||
if (!final.empty()) {
|
||||
std::string final = dequote(trim(current_item));
|
||||
if (!final.empty())
|
||||
result.push_back(final);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
Reference in New Issue
Block a user