Fixed adding the hardcoded test servers in a dev. environment

(issue found during debugging of #533)
Added some functions to find similar servers by address/port
This commit is contained in:
Klaus Basan
2015-12-06 05:40:50 +01:00
parent f4eec653c1
commit 22ca6ae922
7 changed files with 80 additions and 10 deletions

View File

@@ -13,7 +13,6 @@ namespace BlackMisc
{
namespace Network
{
CServerList::CServerList() { }
CServerList::CServerList(const CSequence<CServer> &other) :
@@ -29,5 +28,30 @@ namespace BlackMisc
return false;
}
bool CServerList::containsAddressPort(const CServer &server)
{
for (const CServer &s : *this)
{
if (s.matchesAddressPort(server)) { return true; }
}
return false;
}
void CServerList::addIfAddressNotExists(const CServer &server)
{
if (!server.hasAddressAndPort() || server.getName().isEmpty()) { return; }
if (!this->containsAddressPort(server))
{
this->push_back(server);
}
}
void CServerList::addIfAddressNotExists(const CServerList &servers)
{
for (const CServer &s : servers)
{
this->addIfAddressNotExists(s);
}
}
} // namespace
} // namespace