mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
ParameterSystem: replace if nest with switch
This commit is contained in:
parent
4cc187d2d8
commit
95ab000612
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user