From 15a361b28e9fff41d02ddfb8eb1b9cbc1f4b3c29 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 13 Aug 2015 13:21:08 +0200 Subject: [PATCH] certauth: C++11 range-based for loops --- modules/certauth.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/modules/certauth.cpp b/modules/certauth.cpp index d4e46101..175a6740 100644 --- a/modules/certauth.cpp +++ b/modules/certauth.cpp @@ -41,24 +41,23 @@ public: bool OnBoot() override { const vector& vListeners = CZNC::Get().GetListeners(); - vector::const_iterator it; // We need the SSL_VERIFY_PEER flag on all listeners, or else // the client doesn't send a ssl cert - for (it = vListeners.begin(); it != vListeners.end(); ++it) - (*it)->GetRealListener()->SetRequireClientCertFlags(SSL_VERIFY_PEER); + for (CListener* pListener : vListeners) + pListener->GetRealListener()->SetRequireClientCertFlags(SSL_VERIFY_PEER); - for (MCString::const_iterator it1 = BeginNV(); it1 != EndNV(); ++it1) { + for (MCString::const_iterator it = BeginNV(); it != EndNV(); ++it) { VCString vsKeys; - if (CZNC::Get().FindUser(it1->first) == nullptr) { - DEBUG("Unknown user in saved data [" + it1->first + "]"); + if (CZNC::Get().FindUser(it->first) == nullptr) { + DEBUG("Unknown user in saved data [" + it->first + "]"); continue; } - it1->second.Split(" ", vsKeys, false); - for (VCString::const_iterator it2 = vsKeys.begin(); it2 != vsKeys.end(); ++it2) { - m_PubKeys[it1->first].insert(it2->AsLower()); + it->second.Split(" ", vsKeys, false); + for (const CString& sKey : vsKeys) { + m_PubKeys[it->first].insert(sKey.AsLower()); } } @@ -77,14 +76,14 @@ public: bool Save() { ClearNV(false); - for (MSCString::const_iterator it = m_PubKeys.begin(); it != m_PubKeys.end(); ++it) { + for (const auto& it : m_PubKeys) { CString sVal; - for (SCString::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) { - sVal += *it2 + " "; + for (const CString& sKey : it.second) { + sVal += sKey + " "; } if (!sVal.empty()) - SetNV(it->first, sVal, false); + SetNV(it.first, sVal, false); } return SaveRegistry(); @@ -177,10 +176,10 @@ public: } unsigned int id = 1; - for (SCString::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) { + for (const CString& sKey : it->second) { Table.AddRow(); Table.SetCell("Id", CString(id++)); - Table.SetCell("Key", *it2); + Table.SetCell("Key", sKey); } if (PutModule(Table) == 0) { @@ -244,9 +243,9 @@ public: if (sPageName == "index") { MSCString::const_iterator it = m_PubKeys.find(pUser->GetUserName()); if (it != m_PubKeys.end()) { - for (SCString::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) { + for (const CString& sKey : it->second) { CTemplate& row = Tmpl.AddRow("KeyLoop"); - row["Key"] = *it2; + row["Key"] = sKey; } }