summaryrefslogtreecommitdiff
path: root/src/opertype.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/opertype.cpp')
-rw-r--r--src/opertype.cpp48
1 files changed, 16 insertions, 32 deletions
diff --git a/src/opertype.cpp b/src/opertype.cpp
index 6a144fd3c..e7708f99f 100644
--- a/src/opertype.cpp
+++ b/src/opertype.cpp
@@ -27,10 +27,8 @@ Oper::~Oper()
Oper *Oper::Find(const Anope::string &name)
{
- for (unsigned i = 0; i < opers.size(); ++i)
+ for (auto *o : opers)
{
- Oper *o = opers[i];
-
if (o->name.equals_ci(name))
return o;
}
@@ -40,10 +38,8 @@ Oper *Oper::Find(const Anope::string &name)
OperType *OperType::Find(const Anope::string &name)
{
- for (unsigned i = 0; i < Config->MyOperTypes.size(); ++i)
+ for (auto *ot : Config->MyOperTypes)
{
- OperType *ot = Config->MyOperTypes[i];
-
if (ot->GetName() == name)
return ot;
}
@@ -57,19 +53,15 @@ OperType::OperType(const Anope::string &nname) : name(nname)
bool OperType::HasCommand(const Anope::string &cmdstr) const
{
- for (std::list<Anope::string>::const_iterator it = this->commands.begin(), it_end = this->commands.end(); it != it_end; ++it)
+ for (const auto &command : this->commands)
{
- const Anope::string &s = *it;
-
- if (!s.find('~') && Anope::Match(cmdstr, s.substr(1)))
+ if (!command.find('~') && Anope::Match(cmdstr, command.substr(1)))
return false;
- else if (Anope::Match(cmdstr, s))
+ else if (Anope::Match(cmdstr, command))
return true;
}
- for (std::set<OperType *>::const_iterator iit = this->inheritances.begin(), iit_end = this->inheritances.end(); iit != iit_end; ++iit)
+ for (auto *ot : this->inheritances)
{
- OperType *ot = *iit;
-
if (ot->HasCommand(cmdstr))
return true;
}
@@ -79,19 +71,15 @@ bool OperType::HasCommand(const Anope::string &cmdstr) const
bool OperType::HasPriv(const Anope::string &privstr) const
{
- for (std::list<Anope::string>::const_iterator it = this->privs.begin(), it_end = this->privs.end(); it != it_end; ++it)
+ for (const auto &priv : this->privs)
{
- const Anope::string &s = *it;
-
- if (!s.find('~') && Anope::Match(privstr, s.substr(1)))
+ if (!priv.find('~') && Anope::Match(privstr, priv.substr(1)))
return false;
- else if (Anope::Match(privstr, s))
+ else if (Anope::Match(privstr, priv))
return true;
}
- for (std::set<OperType *>::const_iterator iit = this->inheritances.begin(), iit_end = this->inheritances.end(); iit != iit_end; ++iit)
+ for (auto *ot : this->inheritances)
{
- OperType *ot = *iit;
-
if (ot->HasPriv(privstr))
return true;
}
@@ -123,12 +111,10 @@ void OperType::Inherits(OperType *ot)
const std::list<Anope::string> OperType::GetCommands() const
{
std::list<Anope::string> cmd_list = this->commands;
- for (std::set<OperType *>::const_iterator it = this->inheritances.begin(), it_end = this->inheritances.end(); it != it_end; ++it)
+ for (auto *ot : this->inheritances)
{
- OperType *ot = *it;
- std::list<Anope::string> cmds = ot->GetCommands();
- for (std::list<Anope::string>::const_iterator it2 = cmds.begin(), it2_end = cmds.end(); it2 != it2_end; ++it2)
- cmd_list.push_back(*it2);
+ for (const auto &cmd : ot->GetCommands())
+ cmd_list.push_back(cmd);
}
return cmd_list;
}
@@ -136,12 +122,10 @@ const std::list<Anope::string> OperType::GetCommands() const
const std::list<Anope::string> OperType::GetPrivs() const
{
std::list<Anope::string> priv_list = this->privs;
- for (std::set<OperType *>::const_iterator it = this->inheritances.begin(), it_end = this->inheritances.end(); it != it_end; ++it)
+ for (auto *ot : this->inheritances)
{
- OperType *ot = *it;
- std::list<Anope::string> priv = ot->GetPrivs();
- for (std::list<Anope::string>::const_iterator it2 = priv.begin(), it2_end = priv.end(); it2 != it2_end; ++it2)
- priv_list.push_back(*it2);
+ for (const auto &priv : ot->GetPrivs())
+ priv_list.push_back(priv);
}
return priv_list;
}