mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-19 06:57:24 -06:00
Simplify functions
This commit is contained in:
@@ -47,22 +47,15 @@ namespace Utils
|
||||
return !QHostAddress(ip).isNull();
|
||||
}
|
||||
|
||||
Subnet parseSubnet(const QString &subnetStr, bool *ok)
|
||||
std::optional<Subnet> parseSubnet(const QString &subnetStr)
|
||||
{
|
||||
const Subnet invalid = qMakePair(QHostAddress(), -1);
|
||||
const Subnet subnet = QHostAddress::parseSubnet(subnetStr);
|
||||
if (ok)
|
||||
*ok = (subnet != invalid);
|
||||
const Subnet invalid = {QHostAddress(), -1};
|
||||
if (subnet == invalid)
|
||||
return std::nullopt;
|
||||
return subnet;
|
||||
}
|
||||
|
||||
bool canParseSubnet(const QString &subnetStr)
|
||||
{
|
||||
bool ok = false;
|
||||
parseSubnet(subnetStr, &ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool isLoopbackAddress(const QHostAddress &addr)
|
||||
{
|
||||
return (addr == QHostAddress::LocalHost)
|
||||
|
||||
Reference in New Issue
Block a user