mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-06 13:11:25 -07:00
Change parseBool() to return optional bool value
This commit is contained in:
parent
4429a16ca8
commit
d0cac421bb
6 changed files with 24 additions and 19 deletions
|
@ -190,11 +190,14 @@ QString Utils::String::wildcardToRegex(const QString &pattern)
|
|||
return qt_regexp_toCanonical(pattern, QRegExp::Wildcard);
|
||||
}
|
||||
|
||||
bool Utils::String::parseBool(const QString &string, const bool defaultValue)
|
||||
std::optional<bool> Utils::String::parseBool(const QString &string)
|
||||
{
|
||||
if (defaultValue)
|
||||
return (string.compare("false", Qt::CaseInsensitive) == 0) ? false : true;
|
||||
return (string.compare("true", Qt::CaseInsensitive) == 0) ? true : false;
|
||||
if (string.compare("true", Qt::CaseInsensitive) == 0)
|
||||
return true;
|
||||
if (string.compare("false", Qt::CaseInsensitive) == 0)
|
||||
return false;
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
QString Utils::String::join(const QVector<QStringRef> &strings, const QString &separator)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue