mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 01:45:38 +08:00
Use nested namespaces (C++17 feature)
This commit is contained in:
@@ -13,55 +13,52 @@
|
||||
#include <QJsonValue>
|
||||
#include <tuple>
|
||||
|
||||
namespace BlackMisc
|
||||
namespace BlackMisc::Network
|
||||
{
|
||||
namespace Network
|
||||
CRoleList::CRoleList() { }
|
||||
|
||||
bool CRoleList::hasRole(const QString &roleName) const
|
||||
{
|
||||
CRoleList::CRoleList() { }
|
||||
return this->contains(&CRole::getName, roleName.trimmed().toUpper());
|
||||
}
|
||||
|
||||
bool CRoleList::hasRole(const QString &roleName) const
|
||||
bool CRoleList::hasRole(const CRole &role) const
|
||||
{
|
||||
return hasRole(role.getName());
|
||||
}
|
||||
|
||||
bool CRoleList::hasAnyRole(const QStringList &roles) const
|
||||
{
|
||||
for (const QString &r : roles)
|
||||
{
|
||||
return this->contains(&CRole::getName, roleName.trimmed().toUpper());
|
||||
if (this->hasRole(r)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CRoleList::hasRole(const CRole &role) const
|
||||
CRoleList::CRoleList(const CSequence<CRole> &other) :
|
||||
CSequence<CRole>(other)
|
||||
{ }
|
||||
|
||||
QString CRoleList::namesAsString(const QString &separator) const
|
||||
{
|
||||
QStringList rolesString;
|
||||
rolesString.reserve(size());
|
||||
for (const CRole &role : (*this))
|
||||
{
|
||||
return hasRole(role.getName());
|
||||
rolesString.append(role.getName());
|
||||
}
|
||||
return rolesString.join(separator);
|
||||
}
|
||||
|
||||
bool CRoleList::hasAnyRole(const QStringList &roles) const
|
||||
CRoleList CRoleList::fromDatabaseJson(const QJsonArray &array)
|
||||
{
|
||||
CRoleList roles;
|
||||
for (const QJsonValue &value : array)
|
||||
{
|
||||
for (const QString &r : roles)
|
||||
{
|
||||
if (this->hasRole(r)) { return true; }
|
||||
}
|
||||
return false;
|
||||
roles.push_back(CRole::fromDatabaseJson(value.toObject()));
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
CRoleList::CRoleList(const CSequence<CRole> &other) :
|
||||
CSequence<CRole>(other)
|
||||
{ }
|
||||
|
||||
QString CRoleList::namesAsString(const QString &separator) const
|
||||
{
|
||||
QStringList rolesString;
|
||||
rolesString.reserve(size());
|
||||
for (const CRole &role : (*this))
|
||||
{
|
||||
rolesString.append(role.getName());
|
||||
}
|
||||
return rolesString.join(separator);
|
||||
}
|
||||
|
||||
CRoleList CRoleList::fromDatabaseJson(const QJsonArray &array)
|
||||
{
|
||||
CRoleList roles;
|
||||
for (const QJsonValue &value : array)
|
||||
{
|
||||
roles.push_back(CRole::fromDatabaseJson(value.toObject()));
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user