mirror of
https://github.com/znc/znc.git
synced 2026-05-02 19:42:32 +02:00
CIRCSock: C++11 range-based for loops
This commit is contained in:
@@ -100,14 +100,14 @@ CIRCSock::~CIRCSock() {
|
||||
}
|
||||
|
||||
const vector<CChan*>& vChans = m_pNetwork->GetChans();
|
||||
for (unsigned int a = 0; a < vChans.size(); a++) {
|
||||
vChans[a]->Reset();
|
||||
for (CChan* pChan : vChans) {
|
||||
pChan->Reset();
|
||||
}
|
||||
|
||||
m_pNetwork->IRCDisconnected();
|
||||
|
||||
for (map<CString, CChan*>::iterator a = m_msChans.begin(); a != m_msChans.end(); ++a) {
|
||||
delete a->second;
|
||||
for (const auto& it : m_msChans) {
|
||||
delete it.second;
|
||||
}
|
||||
|
||||
Quit();
|
||||
@@ -183,8 +183,7 @@ void CIRCSock::ReadLine(const CString& sData) {
|
||||
|
||||
const vector<CClient*>& vClients = m_pNetwork->GetClients();
|
||||
|
||||
for (unsigned int a = 0; a < vClients.size(); a++) {
|
||||
CClient* pClient = vClients[a];
|
||||
for (CClient* pClient : vClients) {
|
||||
CString sClientNick = pClient->GetNick(false);
|
||||
|
||||
if (!sClientNick.Equals(sNick)) {
|
||||
@@ -345,18 +344,15 @@ void CIRCSock::ReadLine(const CString& sData) {
|
||||
|
||||
const vector<CChan*>& vChans = m_pNetwork->GetChans();
|
||||
|
||||
for (unsigned int a = 0; a < vChans.size(); a++) {
|
||||
vChans[a]->OnWho(sNick, sIdent, sHost);
|
||||
for (CChan* pChan : vChans) {
|
||||
pChan->OnWho(sNick, sIdent, sHost);
|
||||
}
|
||||
|
||||
if (m_bNamesx && (sNick.size() > 1) && IsPermChar(sNick[1])) {
|
||||
// sLine uses multi-prefix
|
||||
|
||||
const vector<CClient*>& vClients = m_pNetwork->GetClients();
|
||||
vector<CClient*>::const_iterator it;
|
||||
for (it = vClients.begin(); it != vClients.end(); ++it) {
|
||||
CClient *pClient = *it;
|
||||
|
||||
for (CClient* pClient : vClients) {
|
||||
if (pClient->HasNamesx()) {
|
||||
m_pNetwork->PutUser(sLine, pClient);
|
||||
} else {
|
||||
@@ -504,9 +500,7 @@ void CIRCSock::ReadLine(const CString& sData) {
|
||||
vector<CChan*> vFoundChans;
|
||||
const vector<CChan*>& vChans = m_pNetwork->GetChans();
|
||||
|
||||
for (unsigned int a = 0; a < vChans.size(); a++) {
|
||||
CChan* pChan = vChans[a];
|
||||
|
||||
for (CChan* pChan : vChans) {
|
||||
if (pChan->ChangeNick(Nick.GetNick(), sNewNick)) {
|
||||
vFoundChans.push_back(pChan);
|
||||
|
||||
@@ -545,9 +539,7 @@ void CIRCSock::ReadLine(const CString& sData) {
|
||||
vector<CChan*> vFoundChans;
|
||||
const vector<CChan*>& vChans = m_pNetwork->GetChans();
|
||||
|
||||
for (unsigned int a = 0; a < vChans.size(); a++) {
|
||||
CChan* pChan = vChans[a];
|
||||
|
||||
for (CChan* pChan : vChans) {
|
||||
if (pChan->RemNick(Nick.GetNick())) {
|
||||
vFoundChans.push_back(pChan);
|
||||
|
||||
@@ -833,12 +825,11 @@ void CIRCSock::ReadLine(const CString& sData) {
|
||||
|
||||
if (sSubCmd == "LS") {
|
||||
VCString vsTokens;
|
||||
VCString::iterator it;
|
||||
sArgs.Split(" ", vsTokens, false);
|
||||
|
||||
for (it = vsTokens.begin(); it != vsTokens.end(); ++it) {
|
||||
if (OnServerCapAvailable(*it) || *it == "multi-prefix" || *it == "userhost-in-names") {
|
||||
m_ssPendingCaps.insert(*it);
|
||||
for (const CString& sCap : vsTokens) {
|
||||
if (OnServerCapAvailable(sCap) || sCap == "multi-prefix" || sCap == "userhost-in-names") {
|
||||
m_ssPendingCaps.insert(sCap);
|
||||
}
|
||||
}
|
||||
} else if (sSubCmd == "ACK") {
|
||||
@@ -1136,8 +1127,8 @@ void CIRCSock::Disconnected() {
|
||||
// otherwise, on reconnect, it might think it still
|
||||
// had user modes that it actually doesn't have.
|
||||
CString sUserMode;
|
||||
for (set<unsigned char>::const_iterator it = m_scUserModes.begin(); it != m_scUserModes.end(); ++it) {
|
||||
sUserMode += *it;
|
||||
for (unsigned char cMode : m_scUserModes) {
|
||||
sUserMode += cMode;
|
||||
}
|
||||
if (!sUserMode.empty()) {
|
||||
m_pNetwork->PutUser(":" + m_pNetwork->GetIRCNick().GetNickMask() + " MODE " + m_pNetwork->GetIRCNick().GetNick() + " :-" + sUserMode);
|
||||
@@ -1223,13 +1214,12 @@ void CIRCSock::ReachedMaxBuffer() {
|
||||
|
||||
void CIRCSock::ParseISupport(const CString& sLine) {
|
||||
VCString vsTokens;
|
||||
VCString::iterator it;
|
||||
|
||||
sLine.Split(" ", vsTokens, false);
|
||||
|
||||
for (it = vsTokens.begin(); it != vsTokens.end(); ++it) {
|
||||
CString sName = it->Token(0, false, "=");
|
||||
CString sValue = it->Token(1, true, "=");
|
||||
for (const CString& sToken : vsTokens) {
|
||||
CString sName = sToken.Token(0, false, "=");
|
||||
CString sValue = sToken.Token(1, true, "=");
|
||||
|
||||
if (0 < sName.length() && ':' == sName[0]) {
|
||||
break;
|
||||
@@ -1291,10 +1281,9 @@ CString CIRCSock::GetISupport(const CString& sKey, const CString& sDefault) cons
|
||||
|
||||
void CIRCSock::ForwardRaw353(const CString& sLine) const {
|
||||
const vector<CClient*>& vClients = m_pNetwork->GetClients();
|
||||
vector<CClient*>::const_iterator it;
|
||||
|
||||
for (it = vClients.begin(); it != vClients.end(); ++it) {
|
||||
ForwardRaw353(sLine, *it);
|
||||
for (CClient* pClient : vClients) {
|
||||
ForwardRaw353(sLine, pClient);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1309,12 +1298,10 @@ void CIRCSock::ForwardRaw353(const CString& sLine, CClient* pClient) const {
|
||||
CString sTmp = sLine.Token(0, false, " :") + " :";
|
||||
|
||||
VCString vsNicks;
|
||||
VCString::const_iterator it;
|
||||
|
||||
// This loop runs once for every nick on the channel
|
||||
sNicks.Split(" ", vsNicks, false);
|
||||
for (it = vsNicks.begin(); it != vsNicks.end(); ++it) {
|
||||
CString sNick = *it;
|
||||
for (CString sNick : vsNicks) {
|
||||
if (sNick.empty())
|
||||
break;
|
||||
|
||||
@@ -1416,8 +1403,8 @@ CIRCSock::EChanModeArgs CIRCSock::GetModeType(unsigned char uMode) const {
|
||||
}
|
||||
|
||||
void CIRCSock::ResetChans() {
|
||||
for (map<CString, CChan*>::iterator a = m_msChans.begin(); a != m_msChans.end(); ++a) {
|
||||
a->second->Reset();
|
||||
for (const auto& it : m_msChans) {
|
||||
it.second->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user