ParameterSystem: replace if nest with switch

This commit is contained in:
Arne Morten Kvarving 2024-09-05 08:41:09 +02:00
parent 4cc187d2d8
commit 95ab000612

View File

@ -154,22 +154,19 @@ std::string parseQuotedValue(std::string& s, const std::string& errorPrefix)
for (; i < s.size(); ++i) { for (; i < s.size(); ++i) {
// handle escape characters // handle escape characters
if (s[i] == '\\') { if (s[i] == '\\') {
++ i; ++i;
if (s.size() <= i) if (s.size() <= i)
throw std::runtime_error(errorPrefix+"Unexpected end of quoted string"); throw std::runtime_error(errorPrefix+"Unexpected end of quoted string");
if (s[i] == 'n') switch (s[i]) {
result += '\n'; case 'n': result += '\n'; break;
else if (s[i] == 'r') case 'r': result += '\r'; break;
result += '\r'; case 't': result += '\t'; break;
else if (s[i] == 't') case '"': result += '"'; break;
result += '\t'; case '\\': result += '\\'; break;
else if (s[i] == '"') default: throw std::runtime_error(errorPrefix +
result += '"'; "Unknown escape character '\\" + s[i] + "'");
else if (s[i] == '\\') }
result += '\\';
else
throw std::runtime_error(errorPrefix+"Unknown escape character '\\" + s[i] + "'");
} }
else if (s[i] == '"') else if (s[i] == '"')
break; break;