Declared severityFromString function

This commit is contained in:
Shikhar Vashistha
2021-10-22 19:25:46 +02:00
committed by Kamil Śliwak
parent 85cdb29121
commit e4ac0fcd96
2 changed files with 9 additions and 3 deletions
+7 -3
View File
@@ -72,13 +72,17 @@ Error::Error(
*this << util::errinfo_comment(_description);
}
static std::optional<Severity> severityFromString(std::string _severity)
static optional<Severity> severityFromString(string _severity)
{
boost::algorithm::to_lower(_severity);
_severity = boost::algorithm::trim_copy(_severity);
_severity[0] = toupper(_severity[0]);
if (_severity == formatErrorSeverityLowercase(Severity::Error)) { return Severity::Error; }
return std::make_optional<std::string>(_severity).has_value() ? std::optional<std::string>(_severity) : std::nullopt;
else if (_severity == formatErrorSeverityLowercase(Severity::Warning)) { return Severity::Warning; }
else if (_severity == formatErrorSeverityLowercase(Severity::Info)) { return Severity::Info; }
else return std::make_optional<Severity>(_severity).has_value() ? std::optional<Severity>(_severity) : std::nullopt;
}
+2
View File
@@ -205,6 +205,8 @@ public:
return nullptr;
}
static std::optional<Severity> severityFromString(std::string _severity);
static Severity errorSeverity(Type _type)
{
if (_type == Type::Info)