diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index 0887f4d5f..6299429ee 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -34,7 +34,6 @@ #include "config.h" #include #include -#include #ifndef _WIN32 # include @@ -243,7 +242,7 @@ int Main(void) #endif /* _WIN32 */ if (vm.count("define")) { - BOOST_FOREACH(const String& define, vm["define"].as >()) { + for (const String& define : vm["define"].as >()) { String key, value; size_t pos = define.FindFirstOf('='); if (pos != String::NPos) { @@ -269,7 +268,7 @@ int Main(void) ConfigCompiler::AddIncludeSearchDir(Application::GetIncludeConfDir()); if (!autocomplete && vm.count("include")) { - BOOST_FOREACH(const String& includePath, vm["include"].as >()) { + for (const String& includePath : vm["include"].as >()) { ConfigCompiler::AddIncludeSearchDir(includePath); } } @@ -293,7 +292,7 @@ int Main(void) } if (vm.count("library")) { - BOOST_FOREACH(const String& libraryName, vm["library"].as >()) { + for (const String& libraryName : vm["library"].as >()) { try { (void) Loader::LoadExtensionLibrary(libraryName); } catch (const std::exception& ex) { diff --git a/icinga-studio/mainform.cpp b/icinga-studio/mainform.cpp index a441a7448..ebaf6e4a0 100644 --- a/icinga-studio/mainform.cpp +++ b/icinga-studio/mainform.cpp @@ -21,7 +21,6 @@ #include "icinga-studio/aboutform.hpp" #include #include -#include #include using namespace icinga; @@ -72,11 +71,11 @@ void MainForm::TypesCompletionHandler(boost::exception_ptr eptr, const std::vect wxTreeItemId rootNode = m_TypesTree->AddRoot("root"); - BOOST_FOREACH(const ApiType::Ptr& type, types) { + for (const ApiType::Ptr& type : types) { m_Types[type->Name] = type; } - BOOST_FOREACH(const ApiType::Ptr& type, types) { + for (const ApiType::Ptr& type : types) { if (type->Abstract) continue; @@ -146,7 +145,7 @@ void MainForm::ObjectsCompletionHandler(boost::exception_ptr eptr, const std::ve std::vector sortedObjects = objects; std::sort(sortedObjects.begin(), sortedObjects.end(), ApiObjectLessComparer); - BOOST_FOREACH(const ApiObject::Ptr& object, sortedObjects) { + for (const ApiObject::Ptr& object : sortedObjects) { std::string name = object->Name; m_ObjectsList->InsertItem(0, name); } @@ -195,7 +194,7 @@ wxPGProperty *MainForm::ValueToProperty(const String& name, const Value& value) { ObjectLock olock(arr); - BOOST_FOREACH(const Value& aitem, arr) { + for (const Value& aitem : arr) { String val1 = aitem; val.Add(val1.GetData()); } @@ -211,7 +210,7 @@ wxPGProperty *MainForm::ValueToProperty(const String& name, const Value& value) { ObjectLock olock(dict); - BOOST_FOREACH(const Dictionary::Pair& kv, dict) { + for (const Dictionary::Pair& kv : dict) { if (kv.first != "type") prop->AppendChild(ValueToProperty(kv.first, kv.second)); } @@ -268,8 +267,7 @@ void MainForm::ObjectDetailsCompletionHandler(boost::exception_ptr eptr, const s std::map parents; - typedef std::pair kv_pair_attr; - BOOST_FOREACH(const kv_pair_attr& kv, object->Attrs) { + for (const auto& kv : object->Attrs) { std::vector tokens; boost::algorithm::split(tokens, kv.first, boost::is_any_of(".")); @@ -298,8 +296,7 @@ void MainForm::ObjectDetailsCompletionHandler(boost::exception_ptr eptr, const s parents.erase(propName); } - typedef std::pair kv_pair_prop; - BOOST_FOREACH(const kv_pair_prop& kv, parents) { + for (const auto& kv : parents) { m_PropertyGrid->Append(kv.second); m_PropertyGrid->SetPropertyReadOnly(kv.second); } diff --git a/lib/base/application.cpp b/lib/base/application.cpp index 9746b0130..3402b97cd 100644 --- a/lib/base/application.cpp +++ b/lib/base/application.cpp @@ -32,7 +32,6 @@ #include "base/scriptglobal.hpp" #include "base/process.hpp" #include -#include #include #include #include @@ -115,7 +114,7 @@ void Application::Exit(int rc) std::cout.flush(); std::cerr.flush(); - BOOST_FOREACH(const Logger::Ptr& logger, Logger::GetLoggers()) { + for (const Logger::Ptr& logger : Logger::GetLoggers()) { logger->Flush(); } @@ -452,7 +451,7 @@ String Application::GetExePath(const String& argv0) boost::algorithm::split(paths, pathEnv, boost::is_any_of(":")); bool foundPath = false; - BOOST_FOREACH(String& path, paths) { + for (const String& path : paths) { String pathTest = path + "/" + argv0; if (access(pathTest.CStr(), X_OK) == 0) { diff --git a/lib/base/array-script.cpp b/lib/base/array-script.cpp index e7f57a349..6eeaf8ed2 100644 --- a/lib/base/array-script.cpp +++ b/lib/base/array-script.cpp @@ -23,7 +23,6 @@ #include "base/scriptframe.hpp" #include "base/objectlock.hpp" #include "base/exception.hpp" -#include using namespace icinga; @@ -123,7 +122,7 @@ static Value ArrayJoin(const Value& separator) bool first = true; ObjectLock olock(self); - BOOST_FOREACH(const Value& item, self) { + for (const Value& item : self) { if (first) { first = false; } else { @@ -154,7 +153,7 @@ static Array::Ptr ArrayMap(const Function::Ptr& function) Array::Ptr result = new Array(); ObjectLock olock(self); - BOOST_FOREACH(const Value& item, self) { + for (const Value& item : self) { std::vector args; args.push_back(item); result->Add(function->Invoke(args)); @@ -198,7 +197,7 @@ static Array::Ptr ArrayFilter(const Function::Ptr& function) Array::Ptr result = new Array(); ObjectLock olock(self); - BOOST_FOREACH(const Value& item, self) { + for (const Value& item : self) { std::vector args; args.push_back(item); if (function->Invoke(args)) @@ -216,7 +215,7 @@ static Array::Ptr ArrayUnique(void) std::set result; ObjectLock olock(self); - BOOST_FOREACH(const Value& item, self) { + for (const Value& item : self) { result.insert(item); } diff --git a/lib/base/array.cpp b/lib/base/array.cpp index f38e41e65..9b7067cd8 100644 --- a/lib/base/array.cpp +++ b/lib/base/array.cpp @@ -25,7 +25,6 @@ #include "base/configwriter.hpp" #include "base/convert.hpp" #include "base/exception.hpp" -#include using namespace icinga; @@ -185,7 +184,7 @@ Object::Ptr Array::Clone(void) const Array::Ptr arr = new Array(); ObjectLock olock(this); - BOOST_FOREACH(const Value& val, m_Data) { + for (const Value& val : m_Data) { arr->Add(val.Clone()); } diff --git a/lib/base/array.hpp b/lib/base/array.hpp index f6d75e4dc..432ec221f 100644 --- a/lib/base/array.hpp +++ b/lib/base/array.hpp @@ -142,33 +142,16 @@ private: std::vector m_Data; /**< The data for the array. */ }; -inline Array::Iterator range_begin(Array::Ptr x) +inline Array::Iterator begin(Array::Ptr x) { return x->Begin(); } -inline Array::Iterator range_end(Array::Ptr x) +inline Array::Iterator end(Array::Ptr x) { return x->End(); } } -namespace boost -{ - -template<> -struct range_mutable_iterator -{ - typedef icinga::Array::Iterator type; -}; - -template<> -struct range_const_iterator -{ - typedef icinga::Array::Iterator type; -}; - -} - #endif /* ARRAY_H */ diff --git a/lib/base/configobject.cpp b/lib/base/configobject.cpp index 87e8296a1..137aa4a6c 100644 --- a/lib/base/configobject.cpp +++ b/lib/base/configobject.cpp @@ -34,7 +34,6 @@ #include "base/context.hpp" #include "base/application.hpp" #include -#include #include #include #include @@ -181,7 +180,7 @@ void ConfigObject::ModifyAttribute(const String& attr, const Value& value, bool if (oldValue.IsObjectType()) { Dictionary::Ptr oldDict = oldValue; ObjectLock olock(oldDict); - BOOST_FOREACH(const Dictionary::Pair& kv, oldDict) { + for (const auto& kv : oldDict) { String key = prefix + "." + kv.first; if (!original_attributes->Contains(key)) original_attributes->Set(key, kv.second); @@ -191,7 +190,7 @@ void ConfigObject::ModifyAttribute(const String& attr, const Value& value, bool if (value.IsObjectType()) { Dictionary::Ptr valueDict = value; ObjectLock olock(valueDict); - BOOST_FOREACH(const Dictionary::Pair& kv, valueDict) { + for (const auto& kv : valueDict) { String key = attr + "." + kv.first; if (!original_attributes->Contains(key)) original_attributes->Set(key, Empty); @@ -282,7 +281,7 @@ void ConfigObject::RestoreAttribute(const String& attr, bool updateVersion) { ObjectLock olock(original_attributes); - BOOST_FOREACH(const Dictionary::Pair& kv, original_attributes) { + for (const auto& kv : original_attributes) { std::vector originalTokens; boost::algorithm::split(originalTokens, kv.first, boost::is_any_of(".")); @@ -325,7 +324,7 @@ void ConfigObject::RestoreAttribute(const String& attr, bool updateVersion) } } - BOOST_FOREACH(const String& attr, restoredAttrs) + for (const String& attr : restoredAttrs) original_attributes->Remove(attr); @@ -497,13 +496,13 @@ void ConfigObject::DumpObjects(const String& filename, int attributeTypes) StdioStream::Ptr sfp = new StdioStream(&fp, false); - BOOST_FOREACH(const Type::Ptr& type, Type::GetAllTypes()) { + for (const Type::Ptr& type : Type::GetAllTypes()) { ConfigType *dtype = dynamic_cast(type.get()); if (!dtype) continue; - BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) { + for (const ConfigObject::Ptr& object : dtype->GetObjects()) { Dictionary::Ptr persistentObject = new Dictionary(); persistentObject->Set("type", type->GetName()); @@ -599,13 +598,13 @@ void ConfigObject::RestoreObjects(const String& filename, int attributeTypes) unsigned long no_state = 0; - BOOST_FOREACH(const Type::Ptr& type, Type::GetAllTypes()) { + for (const Type::Ptr& type : Type::GetAllTypes()) { ConfigType *dtype = dynamic_cast(type.get()); if (!dtype) continue; - BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) { + for (const ConfigObject::Ptr& object : dtype->GetObjects()) { if (!object->GetStateLoaded()) { object->OnStateLoaded(); object->SetStateLoaded(true); @@ -621,13 +620,13 @@ void ConfigObject::RestoreObjects(const String& filename, int attributeTypes) void ConfigObject::StopObjects(void) { - BOOST_FOREACH(const Type::Ptr& type, Type::GetAllTypes()) { + for (const Type::Ptr& type : Type::GetAllTypes()) { ConfigType *dtype = dynamic_cast(type.get()); if (!dtype) continue; - BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) { + for (const ConfigObject::Ptr& object : dtype->GetObjects()) { object->Deactivate(); } } @@ -635,20 +634,20 @@ void ConfigObject::StopObjects(void) void ConfigObject::DumpModifiedAttributes(const boost::function& callback) { - BOOST_FOREACH(const Type::Ptr& type, Type::GetAllTypes()) { + for (const Type::Ptr& type : Type::GetAllTypes()) { ConfigType *dtype = dynamic_cast(type.get()); if (!dtype) continue; - BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) { + for (const ConfigObject::Ptr& object : dtype->GetObjects()) { Dictionary::Ptr originalAttributes = object->GetOriginalAttributes(); if (!originalAttributes) continue; ObjectLock olock(originalAttributes); - BOOST_FOREACH(const Dictionary::Pair& kv, originalAttributes) { + for (const Dictionary::Pair& kv : originalAttributes) { String key = kv.first; Type::Ptr type = object->GetReflectionType(); diff --git a/lib/base/configtype.hpp b/lib/base/configtype.hpp index 2b2af6e6b..53831d18e 100644 --- a/lib/base/configtype.hpp +++ b/lib/base/configtype.hpp @@ -24,7 +24,6 @@ #include "base/object.hpp" #include "base/type.hpp" #include "base/dictionary.hpp" -#include namespace icinga { @@ -55,7 +54,7 @@ public: { std::vector > objects = GetObjectsHelper(T::TypeInstance.get()); std::vector > result; - BOOST_FOREACH(const intrusive_ptr& object, objects) { + for (const auto& object : objects) { result.push_back(static_pointer_cast(object)); } return result; diff --git a/lib/base/configwriter.cpp b/lib/base/configwriter.cpp index 5372c0885..5cd6013df 100644 --- a/lib/base/configwriter.cpp +++ b/lib/base/configwriter.cpp @@ -19,7 +19,6 @@ #include "base/configwriter.hpp" #include "base/exception.hpp" -#include #include #include #include @@ -63,7 +62,7 @@ void ConfigWriter::EmitArrayItems(std::ostream& fp, int indentLevel, const Array bool first = true; ObjectLock olock(val); - BOOST_FOREACH(const Value& item, val) { + for (const Value& item : val) { if (first) first = false; else @@ -80,7 +79,7 @@ void ConfigWriter::EmitScope(std::ostream& fp, int indentLevel, const Dictionary if (imports && imports->GetLength() > 0) { ObjectLock xlock(imports); - BOOST_FOREACH(const Value& import, imports) { + for (const Value& import : imports) { fp << "\n"; EmitIndent(fp, indentLevel); fp << "import \"" << import << "\""; @@ -91,7 +90,7 @@ void ConfigWriter::EmitScope(std::ostream& fp, int indentLevel, const Dictionary if (val) { ObjectLock olock(val); - BOOST_FOREACH(const Dictionary::Pair& kv, val) { + for (const Dictionary::Pair& kv : val) { fp << "\n"; EmitIndent(fp, indentLevel); diff --git a/lib/base/context.cpp b/lib/base/context.cpp index 377343694..efee1e5f9 100644 --- a/lib/base/context.cpp +++ b/lib/base/context.cpp @@ -19,7 +19,6 @@ #include "base/context.hpp" #include -#include using namespace icinga; @@ -52,7 +51,7 @@ void ContextTrace::Print(std::ostream& fp) const fp << std::endl; int i = 0; - BOOST_FOREACH(const String& frame, m_Frames) { + for (const String& frame : m_Frames) { fp << "\t(" << i << ") " << frame << std::endl; i++; } diff --git a/lib/base/dependencygraph.cpp b/lib/base/dependencygraph.cpp index 037830d56..3cf67e172 100644 --- a/lib/base/dependencygraph.cpp +++ b/lib/base/dependencygraph.cpp @@ -18,7 +18,6 @@ ******************************************************************************/ #include "base/dependencygraph.hpp" -#include using namespace icinga; @@ -59,7 +58,7 @@ std::vector DependencyGraph::GetParents(const Object::Ptr& child) if (it != m_Dependencies.end()) { typedef std::pair kv_pair; - BOOST_FOREACH(const kv_pair& kv, it->second) { + for (const kv_pair& kv : it->second) { objects.push_back(kv.first); } } diff --git a/lib/base/dictionary-script.cpp b/lib/base/dictionary-script.cpp index 01196d52c..50da75a35 100644 --- a/lib/base/dictionary-script.cpp +++ b/lib/base/dictionary-script.cpp @@ -22,7 +22,6 @@ #include "base/functionwrapper.hpp" #include "base/scriptframe.hpp" #include "base/array.hpp" -#include using namespace icinga; @@ -74,7 +73,7 @@ static Array::Ptr DictionaryKeys(void) Dictionary::Ptr self = static_cast(vframe->Self); Array::Ptr keys = new Array(); ObjectLock olock(self); - BOOST_FOREACH(const Dictionary::Pair& kv, self) { + for (const Dictionary::Pair& kv : self) { keys->Add(kv.first); } return keys; diff --git a/lib/base/dictionary.cpp b/lib/base/dictionary.cpp index df19aecb0..b1a5cbafe 100644 --- a/lib/base/dictionary.cpp +++ b/lib/base/dictionary.cpp @@ -22,7 +22,6 @@ #include "base/debug.hpp" #include "base/primitivetype.hpp" #include "base/configwriter.hpp" -#include using namespace icinga; @@ -137,7 +136,7 @@ void Dictionary::CopyTo(const Dictionary::Ptr& dest) const { ObjectLock olock(this); - BOOST_FOREACH(const Dictionary::Pair& kv, m_Data) { + for (const Dictionary::Pair& kv : m_Data) { dest->Set(kv.first, kv.second); } } @@ -165,7 +164,7 @@ Object::Ptr Dictionary::Clone(void) const Dictionary::Ptr dict = new Dictionary(); ObjectLock olock(this); - BOOST_FOREACH(const Dictionary::Pair& kv, m_Data) { + for (const Dictionary::Pair& kv : m_Data) { dict->Set(kv.first, kv.second.Clone()); } @@ -184,7 +183,7 @@ std::vector Dictionary::GetKeys(void) const std::vector keys; - BOOST_FOREACH(const Dictionary::Pair& kv, m_Data) { + for (const Dictionary::Pair& kv : m_Data) { keys.push_back(kv.first); } diff --git a/lib/base/dictionary.hpp b/lib/base/dictionary.hpp index 38007dfe8..c83f8c0ba 100644 --- a/lib/base/dictionary.hpp +++ b/lib/base/dictionary.hpp @@ -125,33 +125,16 @@ private: std::map m_Data; /**< The data for the dictionary. */ }; -inline Dictionary::Iterator range_begin(Dictionary::Ptr x) +inline Dictionary::Iterator begin(Dictionary::Ptr x) { return x->Begin(); } -inline Dictionary::Iterator range_end(Dictionary::Ptr x) +inline Dictionary::Iterator end(Dictionary::Ptr x) { return x->End(); } } -namespace boost -{ - -template<> -struct range_mutable_iterator -{ - typedef icinga::Dictionary::Iterator type; -}; - -template<> -struct range_const_iterator -{ - typedef icinga::Dictionary::Iterator type; -}; - -} - #endif /* DICTIONARY_H */ diff --git a/lib/base/exception.cpp b/lib/base/exception.cpp index 2389cc06c..a3a5af42e 100644 --- a/lib/base/exception.cpp +++ b/lib/base/exception.cpp @@ -18,8 +18,6 @@ ******************************************************************************/ #include "base/exception.hpp" -#include -#include #ifdef HAVE_CXXABI_H # include @@ -160,7 +158,7 @@ String icinga::DiagnosticInformation(const std::exception& ex, bool verbose, Sta Array::Ptr messages; if (currentHint) { - BOOST_FOREACH(const String& attr, vex->GetAttributePath()) { + for (const String& attr : vex->GetAttributePath()) { Dictionary::Ptr props = currentHint->Get("properties"); if (!props) @@ -326,7 +324,7 @@ ValidationError::ValidationError(const ConfigObject::Ptr& object, const std::vec { String path; - BOOST_FOREACH(const String& attribute, attributePath) { + for (const String& attribute : attributePath) { if (!path.IsEmpty()) path += " -> "; diff --git a/lib/base/filelogger.cpp b/lib/base/filelogger.cpp index bd8e59286..2ed34617d 100644 --- a/lib/base/filelogger.cpp +++ b/lib/base/filelogger.cpp @@ -34,7 +34,7 @@ void FileLogger::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&) { Dictionary::Ptr nodes = new Dictionary(); - BOOST_FOREACH(const FileLogger::Ptr& filelogger, ConfigType::GetObjectsByType()) { + for (const FileLogger::Ptr& filelogger : ConfigType::GetObjectsByType()) { nodes->Set(filelogger->GetName(), 1); //add more stats } diff --git a/lib/base/json.cpp b/lib/base/json.cpp index 27f80c9f4..de1552528 100644 --- a/lib/base/json.cpp +++ b/lib/base/json.cpp @@ -23,7 +23,6 @@ #include "base/array.hpp" #include "base/objectlock.hpp" #include "base/convert.hpp" -#include #include #include #include @@ -45,7 +44,7 @@ static void EncodeDictionary(yajl_gen handle, const Dictionary::Ptr& dict) yajl_gen_map_open(handle); ObjectLock olock(dict); - BOOST_FOREACH(const Dictionary::Pair& kv, dict) { + for (const Dictionary::Pair& kv : dict) { yajl_gen_string(handle, reinterpret_cast(kv.first.CStr()), kv.first.GetLength()); Encode(handle, kv.second); } @@ -58,7 +57,7 @@ static void EncodeArray(yajl_gen handle, const Array::Ptr& arr) yajl_gen_array_open(handle); ObjectLock olock(arr); - BOOST_FOREACH(const Value& value, arr) { + for (const Value& value : arr) { Encode(handle, value); } diff --git a/lib/base/loader.cpp b/lib/base/loader.cpp index a34ce8c3e..9900bbe27 100644 --- a/lib/base/loader.cpp +++ b/lib/base/loader.cpp @@ -20,7 +20,6 @@ #include "base/loader.hpp" #include "base/logger.hpp" #include "base/exception.hpp" -#include using namespace icinga; diff --git a/lib/base/logger.cpp b/lib/base/logger.cpp index d4a204855..3c132800e 100644 --- a/lib/base/logger.cpp +++ b/lib/base/logger.cpp @@ -26,7 +26,6 @@ #include "base/objectlock.hpp" #include "base/context.hpp" #include "base/scriptglobal.hpp" -#include #include using namespace icinga; @@ -102,7 +101,7 @@ void icinga::IcingaLog(LogSeverity severity, const String& facility, } } - BOOST_FOREACH(const Logger::Ptr& logger, Logger::GetLoggers()) { + for (const Logger::Ptr& logger : Logger::GetLoggers()) { ObjectLock llock(logger); if (!logger->IsActive()) diff --git a/lib/base/math-script.cpp b/lib/base/math-script.cpp index ff24d8bc6..6c5101eef 100644 --- a/lib/base/math-script.cpp +++ b/lib/base/math-script.cpp @@ -24,7 +24,6 @@ #include "base/initialize.hpp" #include #include -#include #include using namespace icinga; @@ -84,7 +83,7 @@ static Value MathMax(const std::vector& args) bool first = true; Value result = -INFINITY; - BOOST_FOREACH(const Value& arg, args) { + for (const Value& arg : args) { if (first || arg > result) { first = false; result = arg; @@ -99,7 +98,7 @@ static Value MathMin(const std::vector& args) bool first = true; Value result = INFINITY; - BOOST_FOREACH(const Value& arg, args) { + for (const Value& arg : args) { if (first || arg < result) { first = false; result = arg; diff --git a/lib/base/object.cpp b/lib/base/object.cpp index 36c43a75a..4d149006f 100644 --- a/lib/base/object.cpp +++ b/lib/base/object.cpp @@ -25,7 +25,6 @@ #include "base/timer.hpp" #include "base/logger.hpp" #include "base/exception.hpp" -#include #include using namespace icinga; @@ -227,7 +226,7 @@ static void TypeInfoTimerHandler(void) boost::mutex::scoped_lock lock(l_ObjectCountLock); typedef std::map::value_type kv_pair; - BOOST_FOREACH(kv_pair& kv, l_ObjectCounts) { + for (kv_pair& kv : l_ObjectCounts) { if (kv.second == 0) continue; diff --git a/lib/base/process.cpp b/lib/base/process.cpp index 5a522e09d..6e90efc56 100644 --- a/lib/base/process.cpp +++ b/lib/base/process.cpp @@ -27,7 +27,6 @@ #include "base/logger.hpp" #include "base/utility.hpp" #include "base/scriptglobal.hpp" -#include #include #include @@ -128,7 +127,7 @@ Process::Arguments Process::PrepareCommand(const Value& command) Array::Ptr arguments = command; ObjectLock olock(arguments); - BOOST_FOREACH(const Value& argument, arguments) { + for (const Value& argument : arguments) { #ifdef _WIN32 if (args != "") args += " "; @@ -200,7 +199,7 @@ void Process::IOThreadProc(int tid) int i = 1; typedef std::pair kv_pair; - BOOST_FOREACH(const kv_pair& kv, l_Processes[tid]) { + for (const kv_pair& kv : l_Processes[tid]) { const Process::Ptr& process = kv.second; #ifdef _WIN32 handles[i] = kv.first; @@ -454,7 +453,7 @@ void Process::Run(const boost::function& callback) if (m_ExtraEnvironment) { ObjectLock olock(m_ExtraEnvironment); - BOOST_FOREACH(const Dictionary::Pair& kv, m_ExtraEnvironment) { + for (const Dictionary::Pair& kv : m_ExtraEnvironment) { String skv = kv.first + "=" + Convert::ToString(kv.second); envp = static_cast(realloc(envp, offset + skv.GetLength() + 1)); @@ -560,7 +559,7 @@ void Process::Run(const boost::function& callback) ObjectLock olock(m_ExtraEnvironment); int index = envc; - BOOST_FOREACH(const Dictionary::Pair& kv, m_ExtraEnvironment) { + for (const Dictionary::Pair& kv : m_ExtraEnvironment) { String skv = kv.first + "=" + Convert::ToString(kv.second); envp[index] = strdup(skv.CStr()); index++; diff --git a/lib/base/registry.hpp b/lib/base/registry.hpp index c3c95b867..b99ff412d 100644 --- a/lib/base/registry.hpp +++ b/lib/base/registry.hpp @@ -25,7 +25,6 @@ #include #include #include -#include namespace icinga { @@ -80,9 +79,7 @@ public: items = m_Items; } - typedef typename std::pair ItemMapPair; - - BOOST_FOREACH(const ItemMapPair& kv, items) { + for (const auto& kv : items) { OnUnregistered(kv.first); } diff --git a/lib/base/scriptglobal.cpp b/lib/base/scriptglobal.cpp index 48a1d6654..716945267 100644 --- a/lib/base/scriptglobal.cpp +++ b/lib/base/scriptglobal.cpp @@ -26,7 +26,6 @@ #include "base/convert.hpp" #include "base/objectlock.hpp" #include "base/exception.hpp" -#include #include #include @@ -105,7 +104,7 @@ void ScriptGlobal::WriteToFile(const String& filename) StdioStream::Ptr sfp = new StdioStream(&fp, false); ObjectLock olock(m_Globals); - BOOST_FOREACH(const Dictionary::Pair& kv, m_Globals) { + for (const Dictionary::Pair& kv : m_Globals) { Dictionary::Ptr persistentVariable = new Dictionary(); persistentVariable->Set("name", kv.first); diff --git a/lib/base/scriptutils.cpp b/lib/base/scriptutils.cpp index 5d07b2494..18f81d057 100644 --- a/lib/base/scriptutils.cpp +++ b/lib/base/scriptutils.cpp @@ -27,7 +27,6 @@ #include "base/configtype.hpp" #include "base/application.hpp" #include "base/dependencygraph.hpp" -#include #include #include #include @@ -115,19 +114,19 @@ Array::Ptr ScriptUtils::Union(const std::vector& arguments) { std::set values; - BOOST_FOREACH(const Value& varr, arguments) { + for (const Value& varr : arguments) { Array::Ptr arr = varr; if (arr) { ObjectLock olock(arr); - BOOST_FOREACH(const Value& value, arr) { + for (const Value& value : arr) { values.insert(value); } } } Array::Ptr result = new Array(); - BOOST_FOREACH(const Value& value, values) { + for (const Value& value : values) { result->Add(value); } @@ -252,7 +251,7 @@ Array::Ptr ScriptUtils::Keys(const Dictionary::Ptr& dict) if (dict) { ObjectLock olock(dict); - BOOST_FOREACH(const Dictionary::Pair& kv, dict) { + for (const Dictionary::Pair& kv : dict) { result->Add(kv.first); } } @@ -289,7 +288,7 @@ Array::Ptr ScriptUtils::GetObjects(const Type::Ptr& type) Array::Ptr result = new Array(); - BOOST_FOREACH(const ConfigObject::Ptr& object, ctype->GetObjects()) + for (const ConfigObject::Ptr& object : ctype->GetObjects()) result->Add(object); return result; diff --git a/lib/base/serializer.cpp b/lib/base/serializer.cpp index 770726a6a..9beb27094 100644 --- a/lib/base/serializer.cpp +++ b/lib/base/serializer.cpp @@ -21,7 +21,6 @@ #include "base/type.hpp" #include "base/application.hpp" #include "base/objectlock.hpp" -#include using namespace icinga; @@ -31,7 +30,7 @@ static Array::Ptr SerializeArray(const Array::Ptr& input, int attributeTypes) ObjectLock olock(input); - BOOST_FOREACH(const Value& value, input) { + for (const Value& value : input) { result->Add(Serialize(value, attributeTypes)); } @@ -44,7 +43,7 @@ static Dictionary::Ptr SerializeDictionary(const Dictionary::Ptr& input, int att ObjectLock olock(input); - BOOST_FOREACH(const Dictionary::Pair& kv, input) { + for (const Dictionary::Pair& kv : input) { result->Set(kv.first, Serialize(kv.second, attributeTypes)); } @@ -80,7 +79,7 @@ static Array::Ptr DeserializeArray(const Array::Ptr& input, bool safe_mode, int ObjectLock olock(input); - BOOST_FOREACH(const Value& value, input) { + for (const Value& value : input) { result->Add(Deserialize(value, safe_mode, attributeTypes)); } @@ -93,7 +92,7 @@ static Dictionary::Ptr DeserializeDictionary(const Dictionary::Ptr& input, bool ObjectLock olock(input); - BOOST_FOREACH(const Dictionary::Pair& kv, input) { + for (const Dictionary::Pair& kv : input) { result->Set(kv.first, Deserialize(kv.second, safe_mode, attributeTypes)); } @@ -123,7 +122,7 @@ static Object::Ptr DeserializeObject(const Object::Ptr& object, const Dictionary instance = type->Instantiate(std::vector()); ObjectLock olock(input); - BOOST_FOREACH(const Dictionary::Pair& kv, input) { + for (const Dictionary::Pair& kv : input) { if (kv.first.IsEmpty()) continue; diff --git a/lib/base/socketevents-epoll.cpp b/lib/base/socketevents-epoll.cpp index a6476ac61..bfb391027 100644 --- a/lib/base/socketevents-epoll.cpp +++ b/lib/base/socketevents-epoll.cpp @@ -21,7 +21,6 @@ #include "base/exception.hpp" #include "base/logger.hpp" #include -#include #include #ifdef __linux__ # include @@ -121,7 +120,7 @@ void SocketEventEngineEpoll::ThreadProc(int tid) } } - BOOST_FOREACH(const EventDescription& event, events) { + for (const EventDescription& event : events) { try { event.Descriptor.EventInterface->OnEvent(event.REvents); } catch (const std::exception& ex) { diff --git a/lib/base/socketevents-poll.cpp b/lib/base/socketevents-poll.cpp index a84b3bc4f..c1bcb1bb8 100644 --- a/lib/base/socketevents-poll.cpp +++ b/lib/base/socketevents-poll.cpp @@ -21,7 +21,6 @@ #include "base/exception.hpp" #include "base/logger.hpp" #include -#include #include using namespace icinga; @@ -54,7 +53,7 @@ void SocketEventEnginePoll::ThreadProc(int tid) typedef std::map::value_type kv_pair; - BOOST_FOREACH(const kv_pair& desc, m_Sockets[tid]) { + for (const kv_pair& desc : m_Sockets[tid]) { if (desc.second.Events == 0) continue; @@ -113,7 +112,7 @@ void SocketEventEnginePoll::ThreadProc(int tid) } } - BOOST_FOREACH(const EventDescription& event, events) { + for (const EventDescription& event : events) { try { event.Descriptor.EventInterface->OnEvent(event.REvents); } catch (const std::exception& ex) { diff --git a/lib/base/socketevents.cpp b/lib/base/socketevents.cpp index f68e056ea..06f157313 100644 --- a/lib/base/socketevents.cpp +++ b/lib/base/socketevents.cpp @@ -23,7 +23,6 @@ #include "base/application.hpp" #include "base/scriptglobal.hpp" #include -#include #include #ifdef __linux__ # include diff --git a/lib/base/string-script.cpp b/lib/base/string-script.cpp index 531918e8e..5fff4c829 100644 --- a/lib/base/string-script.cpp +++ b/lib/base/string-script.cpp @@ -24,7 +24,6 @@ #include "base/scriptframe.hpp" #include "base/exception.hpp" #include -#include using namespace icinga; @@ -80,7 +79,7 @@ static Array::Ptr StringSplit(const String& delims) boost::algorithm::split(tokens, self, boost::is_any_of(delims)); Array::Ptr result = new Array(); - BOOST_FOREACH(const String& token, tokens) { + for (const String& token : tokens) { result->Add(token); } return result; diff --git a/lib/base/string.hpp b/lib/base/string.hpp index 0605896e5..2ed06b86d 100644 --- a/lib/base/string.hpp +++ b/lib/base/string.hpp @@ -439,6 +439,25 @@ inline bool operator!=(const char *lhs, const String& rhs) return lhs != rhs.GetData(); } +inline String::Iterator begin(String& x) +{ + return x.Begin(); +} + +inline String::ConstIterator begin(const String& x) +{ + return x.Begin(); +} + +inline String::Iterator end(String& x) +{ + return x.End(); +} + +inline String::ConstIterator end(const String& x) +{ + return x.End(); +} inline String::Iterator range_begin(String& x) { return x.Begin(); diff --git a/lib/base/sysloglogger.cpp b/lib/base/sysloglogger.cpp index 81ca602b3..c6ab08143 100644 --- a/lib/base/sysloglogger.cpp +++ b/lib/base/sysloglogger.cpp @@ -34,7 +34,7 @@ void SyslogLogger::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&) { Dictionary::Ptr nodes = new Dictionary(); - BOOST_FOREACH(const SyslogLogger::Ptr& sysloglogger, ConfigType::GetObjectsByType()) { + for (const SyslogLogger::Ptr& sysloglogger : ConfigType::GetObjectsByType()) { nodes->Set(sysloglogger->GetName(), 1); //add more stats } diff --git a/lib/base/timer.cpp b/lib/base/timer.cpp index 00ef7ef3e..2555130c1 100644 --- a/lib/base/timer.cpp +++ b/lib/base/timer.cpp @@ -21,7 +21,6 @@ #include "base/debug.hpp" #include "base/utility.hpp" #include -#include #include #include #include @@ -223,7 +222,7 @@ void Timer::AdjustTimers(double adjustment) std::vector timers; - BOOST_FOREACH(Timer *timer, idx) { + for (Timer *timer : idx) { if (std::fabs(now - (timer->m_Next + adjustment)) < std::fabs(now - timer->m_Next)) { timer->m_Next += adjustment; @@ -231,7 +230,7 @@ void Timer::AdjustTimers(double adjustment) } } - BOOST_FOREACH(Timer *timer, timers) { + for (Timer *timer : timers) { l_Timers.erase(timer); l_Timers.insert(timer); } diff --git a/lib/base/type.cpp b/lib/base/type.cpp index cad78a626..6fc72cd11 100644 --- a/lib/base/type.cpp +++ b/lib/base/type.cpp @@ -20,7 +20,6 @@ #include "base/type.hpp" #include "base/scriptglobal.hpp" #include "base/objectlock.hpp" -#include using namespace icinga; @@ -72,11 +71,10 @@ std::vector Type::GetAllTypes(void) if (typesNS) { ObjectLock olock(typesNS); - BOOST_FOREACH(const Dictionary::Pair& kv, typesNS) { + for (const Dictionary::Pair& kv : typesNS) { if (kv.second.IsObjectType()) types.push_back(kv.second); - } - + } } return types; diff --git a/lib/base/utility.cpp b/lib/base/utility.cpp index 82470822f..48fc4c15a 100644 --- a/lib/base/utility.cpp +++ b/lib/base/utility.cpp @@ -28,7 +28,6 @@ #include "base/objectlock.hpp" #include #include -#include #include #include #include @@ -264,7 +263,7 @@ String Utility::DirName(const String& path) String dupPath = path; /* PathRemoveFileSpec doesn't properly handle forward slashes. */ - BOOST_FOREACH(char& ch, dupPath) { + for (char& ch : dupPath) { if (ch == '/') ch = '\\'; } @@ -543,7 +542,7 @@ bool Utility::Glob(const String& pathSpec, const boost::function= len) break; @@ -1424,7 +1423,7 @@ String Utility::EscapeString(const String& s, const String& chars, const bool il { std::ostringstream result; if (illegal) { - BOOST_FOREACH(char ch, s) { + for (char ch : s) { if (chars.FindFirstOf(ch) != String::NPos || ch == '%') { result << '%'; HexEncode(ch, result); @@ -1432,7 +1431,7 @@ String Utility::EscapeString(const String& s, const String& chars, const bool il result << ch; } } else { - BOOST_FOREACH(char ch, s) { + for (char ch : s) { if (chars.FindFirstOf(ch) == String::NPos || ch == '%') { result << '%'; HexEncode(ch, result); diff --git a/lib/base/value-operators.cpp b/lib/base/value-operators.cpp index ad0039722..432b1603c 100644 --- a/lib/base/value-operators.cpp +++ b/lib/base/value-operators.cpp @@ -24,7 +24,6 @@ #include "base/convert.hpp" #include "base/utility.hpp" #include "base/objectlock.hpp" -#include #include using namespace icinga; @@ -297,10 +296,10 @@ Value icinga::operator-(const Value& lhs, const Value& rhs) Array::Ptr right = rhs; ObjectLock olock(left); - BOOST_FOREACH(const Value& lv, left) { + for (const Value& lv : left) { bool found = false; ObjectLock xlock(right); - BOOST_FOREACH(const Value& rv, right) { + for (const Value& rv : right) { if (lv == rv) { found = true; break; diff --git a/lib/base/workqueue.cpp b/lib/base/workqueue.cpp index c7b62caa1..a1b0a81a2 100644 --- a/lib/base/workqueue.cpp +++ b/lib/base/workqueue.cpp @@ -24,7 +24,6 @@ #include "base/application.hpp" #include "base/exception.hpp" #include -#include #include using namespace icinga; @@ -173,7 +172,7 @@ void WorkQueue::ReportExceptions(const String& facility) const { std::vector exceptions = GetExceptions(); - BOOST_FOREACH(const boost::exception_ptr& eptr, exceptions) { + for (const auto& eptr : exceptions) { Log(LogCritical, facility) << DiagnosticInformation(eptr); } diff --git a/lib/checker/checkercomponent.cpp b/lib/checker/checkercomponent.cpp index 3f5d2d112..b90d0a526 100644 --- a/lib/checker/checkercomponent.cpp +++ b/lib/checker/checkercomponent.cpp @@ -30,7 +30,6 @@ #include "base/exception.hpp" #include "base/convert.hpp" #include "base/statsfunction.hpp" -#include using namespace icinga; @@ -42,7 +41,7 @@ void CheckerComponent::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr { Dictionary::Ptr nodes = new Dictionary(); - BOOST_FOREACH(const CheckerComponent::Ptr& checker, ConfigType::GetObjectsByType()) { + for (const CheckerComponent::Ptr& checker : ConfigType::GetObjectsByType()) { unsigned long idle = checker->GetIdleCheckables(); unsigned long pending = checker->GetPendingCheckables(); diff --git a/lib/cli/apisetuputility.cpp b/lib/cli/apisetuputility.cpp index 027a7d242..05de8e50b 100644 --- a/lib/cli/apisetuputility.cpp +++ b/lib/cli/apisetuputility.cpp @@ -27,7 +27,6 @@ #include "base/tlsutility.hpp" #include "base/scriptglobal.hpp" #include "base/exception.hpp" -#include #include #include #include @@ -141,7 +140,7 @@ bool ApiSetupUtility::SetupMasterCertificates(const String& cn) files.push_back(csr); files.push_back(cert); - BOOST_FOREACH(const String& file, files) { + for (const String& file : files) { if (!Utility::SetFileOwnership(file, user, group)) { Log(LogWarning, "cli") << "Cannot set ownership for user '" << user << "' group '" << group << "' on file '" << file << "'."; diff --git a/lib/cli/clicommand.cpp b/lib/cli/clicommand.cpp index 2ef3128f2..47b90c5d9 100644 --- a/lib/cli/clicommand.cpp +++ b/lib/cli/clicommand.cpp @@ -23,7 +23,6 @@ #include "base/serializer.hpp" #include #include -#include #include #include #include @@ -173,7 +172,7 @@ bool CLICommand::ParseCommand(int argc, char **argv, po::options_description& vi std::vector best_match; int arg_end = 0; - BOOST_FOREACH(const CLIKeyValue& kv, GetRegistry()) { + for (const CLIKeyValue& kv : GetRegistry()) { const std::vector& vname = kv.first; std::vector::size_type i; @@ -234,7 +233,7 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi int arg_begin = 0; CLICommand::Ptr command; - BOOST_FOREACH(const CLIKeyValue& kv, GetRegistry()) { + for (const CLIKeyValue& kv : GetRegistry()) { const std::vector& vname = kv.first; arg_begin = 0; @@ -276,7 +275,7 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi } else std::cout << "Supported commands: " << std::endl; - BOOST_FOREACH(const CLIKeyValue& kv, GetRegistry()) { + for (const CLIKeyValue& kv : GetRegistry()) { const std::vector& vname = kv.first; if (vname.size() < best_match.size() || kv.second->IsHidden()) @@ -345,25 +344,25 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi if (odesc->semantic()->min_tokens() == 0) goto complete_option; - BOOST_FOREACH(const String& suggestion, globalArgCompletionCallback(odesc->long_name(), pword)) { + for (const String& suggestion : globalArgCompletionCallback(odesc->long_name(), pword)) { std::cout << prefix << suggestion << "\n"; } - BOOST_FOREACH(const String& suggestion, command->GetArgumentSuggestions(odesc->long_name(), pword)) { + for (const String& suggestion : command->GetArgumentSuggestions(odesc->long_name(), pword)) { std::cout << prefix << suggestion << "\n"; } return; complete_option: - BOOST_FOREACH(const boost::shared_ptr& odesc, visibleDesc->options()) { + for (const boost::shared_ptr& odesc : visibleDesc->options()) { String cname = "--" + odesc->long_name(); if (cname.Find(aword) == 0) std::cout << cname << "\n"; } - BOOST_FOREACH(const String& suggestion, command->GetPositionalSuggestions(aword)) { + for (const String& suggestion : command->GetPositionalSuggestions(aword)) { std::cout << suggestion << "\n"; } } diff --git a/lib/cli/daemoncommand.cpp b/lib/cli/daemoncommand.cpp index f9777896c..bb74cc4d2 100644 --- a/lib/cli/daemoncommand.cpp +++ b/lib/cli/daemoncommand.cpp @@ -35,7 +35,6 @@ #include "config.h" #include #include -#include #include #include diff --git a/lib/cli/daemonutility.cpp b/lib/cli/daemonutility.cpp index 1b6d8a843..07aaa3869 100644 --- a/lib/cli/daemonutility.cpp +++ b/lib/cli/daemonutility.cpp @@ -105,7 +105,7 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector& configs, ConfigCompilerContext::GetInstance()->OpenObjectsFile(objectsFile); if (!configs.empty()) { - BOOST_FOREACH(const String& configPath, configs) { + for (const String& configPath : configs) { Expression *expression = ConfigCompiler::CompileFile(configPath, String(), "_etc"); success = ExecuteExpression(expression); delete expression; diff --git a/lib/cli/featurelistcommand.cpp b/lib/cli/featurelistcommand.cpp index d95ac36ec..b94a5922e 100644 --- a/lib/cli/featurelistcommand.cpp +++ b/lib/cli/featurelistcommand.cpp @@ -22,7 +22,6 @@ #include "base/logger.hpp" #include "base/convert.hpp" #include "base/console.hpp" -#include #include #include diff --git a/lib/cli/featureutility.cpp b/lib/cli/featureutility.cpp index 71845b2e8..f3b612f9e 100644 --- a/lib/cli/featureutility.cpp +++ b/lib/cli/featureutility.cpp @@ -21,7 +21,6 @@ #include "base/logger.hpp" #include "base/console.hpp" #include "base/application.hpp" -#include #include #include #include @@ -48,7 +47,7 @@ std::vector FeatureUtility::GetFieldCompletionSuggestions(const String& std::sort(cache.begin(), cache.end()); - BOOST_FOREACH(const String& suggestion, cache) { + for (const String& suggestion : cache) { if (suggestion.Find(word) == 0) suggestions.push_back(suggestion); } @@ -75,7 +74,7 @@ int FeatureUtility::EnableFeatures(const std::vector& features) std::vector errors; - BOOST_FOREACH(const String& feature, features) { + for (const String& feature : features) { String source = features_available_dir + "/" + feature + ".conf"; if (!Utility::PathExists(source) ) { @@ -143,7 +142,7 @@ int FeatureUtility::DisableFeatures(const std::vector& features) std::vector errors; - BOOST_FOREACH(const String& feature, features) { + for (const String& feature : features) { String target = features_enabled_dir + "/" + feature + ".conf"; if (!Utility::PathExists(target) ) { @@ -242,7 +241,7 @@ bool FeatureUtility::CheckFeatureInternal(const String& feature, bool check_disa if (!FeatureUtility::GetFeatures(features, check_disabled)) return false; - BOOST_FOREACH(const String& check_feature, features) { + for (const String& check_feature : features) { if (check_feature == feature) return true; } diff --git a/lib/cli/nodeaddcommand.cpp b/lib/cli/nodeaddcommand.cpp index 73acb2f3d..cfcc330e8 100644 --- a/lib/cli/nodeaddcommand.cpp +++ b/lib/cli/nodeaddcommand.cpp @@ -21,7 +21,6 @@ #include "cli/nodeutility.hpp" #include "base/logger.hpp" #include "base/application.hpp" -#include #include #include #include diff --git a/lib/cli/nodeblackandwhitelistcommand.cpp b/lib/cli/nodeblackandwhitelistcommand.cpp index fbf4346af..ec43ba819 100644 --- a/lib/cli/nodeblackandwhitelistcommand.cpp +++ b/lib/cli/nodeblackandwhitelistcommand.cpp @@ -23,7 +23,6 @@ #include "base/application.hpp" #include "base/objectlock.hpp" #include "base/json.hpp" -#include #include #include diff --git a/lib/cli/nodelistcommand.cpp b/lib/cli/nodelistcommand.cpp index 1d09a8641..3074b2523 100644 --- a/lib/cli/nodelistcommand.cpp +++ b/lib/cli/nodelistcommand.cpp @@ -22,7 +22,6 @@ #include "base/logger.hpp" #include "base/application.hpp" #include "base/console.hpp" -#include #include #include #include diff --git a/lib/cli/noderemovecommand.cpp b/lib/cli/noderemovecommand.cpp index 10450c882..cbdcc37b1 100644 --- a/lib/cli/noderemovecommand.cpp +++ b/lib/cli/noderemovecommand.cpp @@ -21,7 +21,6 @@ #include "cli/nodeutility.hpp" #include "base/logger.hpp" #include "base/application.hpp" -#include #include #include #include @@ -65,7 +64,7 @@ int NodeRemoveCommand::GetMaxArguments(void) const */ int NodeRemoveCommand::Run(const boost::program_options::variables_map& vm, const std::vector& ap) const { - BOOST_FOREACH(const String& node, ap) { + for (const String& node : ap) { NodeUtility::RemoveNode(node); } diff --git a/lib/cli/nodesetcommand.cpp b/lib/cli/nodesetcommand.cpp index b03862590..d786f8bed 100644 --- a/lib/cli/nodesetcommand.cpp +++ b/lib/cli/nodesetcommand.cpp @@ -21,7 +21,6 @@ #include "cli/nodeutility.hpp" #include "base/logger.hpp" #include "base/application.hpp" -#include #include #include #include diff --git a/lib/cli/nodesetupcommand.cpp b/lib/cli/nodesetupcommand.cpp index cf185b335..80039e72a 100644 --- a/lib/cli/nodesetupcommand.cpp +++ b/lib/cli/nodesetupcommand.cpp @@ -28,7 +28,6 @@ #include "base/tlsutility.hpp" #include "base/scriptglobal.hpp" #include "base/exception.hpp" -#include #include #include #include diff --git a/lib/cli/nodeupdateconfigcommand.cpp b/lib/cli/nodeupdateconfigcommand.cpp index 4af4a5563..c9ba63772 100644 --- a/lib/cli/nodeupdateconfigcommand.cpp +++ b/lib/cli/nodeupdateconfigcommand.cpp @@ -27,7 +27,6 @@ #include "base/tlsutility.hpp" #include "base/json.hpp" #include "base/objectlock.hpp" -#include #include #include #include @@ -93,7 +92,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm std::vector nodes = NodeUtility::GetNodes(); /* first make sure that all nodes are valid and should not be removed */ - BOOST_FOREACH(const Dictionary::Ptr& node, nodes) { + for (const Dictionary::Ptr& node : nodes) { Dictionary::Ptr repository = node->Get("repository"); String zone = node->Get("zone"); String endpoint = node->Get("endpoint"); @@ -106,7 +105,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm if (old_inventory) { /* check if there are objects inside the old_inventory which do not exist anymore */ ObjectLock ulock(old_inventory); - BOOST_FOREACH(const Dictionary::Pair& old_node_objs, old_inventory) { + for (const Dictionary::Pair& old_node_objs : old_inventory) { String old_node_name = old_node_objs.first; @@ -121,7 +120,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm if (old_node_repository) { ObjectLock olock(old_node_repository); - BOOST_FOREACH(const Dictionary::Pair& kv, old_node_repository) { + for (const Dictionary::Pair& kv : old_node_repository) { String host = kv.first; Dictionary::Ptr host_attrs = new Dictionary(); @@ -150,7 +149,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm if (old_node_repository) { ObjectLock xlock(old_node_repository); - BOOST_FOREACH(const Dictionary::Pair& kv, old_node_repository) { + for (const Dictionary::Pair& kv : old_node_repository) { String old_host = kv.first; if (old_host == "localhost") { @@ -180,7 +179,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm Array::Ptr new_services = new_node_repository->Get(old_host); ObjectLock ylock(old_services); - BOOST_FOREACH(const String& old_service, old_services) { + for (const String& old_service : old_services) { /* check against black/whitelist before trying to remove service */ if (NodeUtility::CheckAgainstBlackAndWhiteList("blacklist", old_node_name, old_host, old_service) && !NodeUtility::CheckAgainstBlackAndWhiteList("whitelist", old_node_name, old_host, old_service)) { @@ -209,7 +208,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm } /* next iterate over all nodes and add hosts/services */ - BOOST_FOREACH(const Dictionary::Ptr& node, nodes) { + for (const Dictionary::Ptr& node : nodes) { Dictionary::Ptr repository = node->Get("repository"); String zone = node->Get("zone"); String endpoint = node->Get("endpoint"); @@ -242,7 +241,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm if (repository) { ObjectLock olock(repository); - BOOST_FOREACH(const Dictionary::Pair& kv, repository) { + for (const Dictionary::Pair& kv : repository) { String host = kv.first; String host_pattern = host + ".conf"; bool skip_host = false; @@ -253,7 +252,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm continue; } - BOOST_FOREACH(const String& object_path, object_paths) { + for (const String& object_path : object_paths) { if (object_path.Contains(host_pattern)) { Log(LogNotice, "cli") << "Host '" << host << "' already exists."; @@ -313,12 +312,12 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm } ObjectLock xlock(services); - BOOST_FOREACH(const String& service, services) { + for (const String& service : services) { bool skip_service = false; String service_pattern = host + "/" + service + ".conf"; - BOOST_FOREACH(const String& object_path, object_paths) { + for (const String& object_path : object_paths) { if (object_path.Contains(service_pattern)) { Log(LogNotice, "cli") << "Service '" << service << "' on Host '" << host << "' already exists."; diff --git a/lib/cli/nodeutility.cpp b/lib/cli/nodeutility.cpp index 2bfe8085d..a8827d430 100644 --- a/lib/cli/nodeutility.cpp +++ b/lib/cli/nodeutility.cpp @@ -34,7 +34,6 @@ #include "base/console.hpp" #include "base/exception.hpp" #include "base/configwriter.hpp" -#include #include #include #include @@ -77,7 +76,7 @@ std::vector NodeUtility::GetNodeCompletionSuggestions(const String& word { std::vector suggestions; - BOOST_FOREACH(const Dictionary::Ptr& node, GetNodes()) { + for (const Dictionary::Ptr& node : GetNodes()) { String node_name = node->Get("endpoint"); if (node_name.Find(word) == 0) @@ -91,7 +90,7 @@ void NodeUtility::PrintNodes(std::ostream& fp) { bool first = true; - BOOST_FOREACH(const Dictionary::Ptr& node, GetNodes()) { + for (const Dictionary::Ptr& node : GetNodes()) { if (first) first = false; else @@ -126,13 +125,13 @@ void NodeUtility::PrintNodeRepository(std::ostream& fp, const Dictionary::Ptr& r return; ObjectLock olock(repository); - BOOST_FOREACH(const Dictionary::Pair& kv, repository) { + for (const Dictionary::Pair& kv : repository) { fp << std::setw(4) << " " << "* Host '" << ConsoleColorTag(Console_ForegroundGreen | Console_Bold) << kv.first << ConsoleColorTag(Console_Normal) << "'\n"; Array::Ptr services = kv.second; ObjectLock xlock(services); - BOOST_FOREACH(const String& service, services) { + for (const String& service : services) { fp << std::setw(8) << " " << "* Service '" << ConsoleColorTag(Console_ForegroundGreen | Console_Bold) << service << ConsoleColorTag(Console_Normal) << "'\n"; } } @@ -142,7 +141,7 @@ void NodeUtility::PrintNodesJson(std::ostream& fp) { Dictionary::Ptr result = new Dictionary(); - BOOST_FOREACH(const Dictionary::Ptr& node, GetNodes()) { + for (const Dictionary::Ptr& node : GetNodes()) { result->Set(node->Get("endpoint"), node); } @@ -264,7 +263,7 @@ int NodeUtility::GenerateNodeIcingaConfig(const std::vector& endpoi String master_zone_name = "master"; //TODO: Find a better name. - BOOST_FOREACH(const std::string& endpoint, endpoints) { + for (const std::string& endpoint : endpoints) { /* extract all --endpoint arguments and store host,port info */ std::vector tokens; @@ -394,7 +393,7 @@ bool NodeUtility::WriteNodeConfigObjects(const String& filename, const Array::Pt fp << " */\n\n"; ObjectLock olock(objects); - BOOST_FOREACH(const Dictionary::Ptr& object, objects) { + for (const Dictionary::Ptr& object : objects) { SerializeObject(fp, object); } @@ -443,7 +442,7 @@ int NodeUtility::UpdateBlackAndWhiteList(const String& type, const String& zone_ { ObjectLock olock(lists); - BOOST_FOREACH(const Dictionary::Ptr& filter, lists) { + for (const Dictionary::Ptr& filter : lists) { if (filter->Get("zone") == zone_filter) { if (filter->Get("host") == host_filter && service_filter.IsEmpty()) { @@ -484,7 +483,7 @@ int NodeUtility::RemoveBlackAndWhiteList(const String& type, const String& zone_ { ObjectLock olock(lists); - BOOST_FOREACH(const Dictionary::Ptr& filter, lists) { + for (const Dictionary::Ptr& filter : lists) { if (filter->Get("zone") == zone_filter) { if (filter->Get("host") == host_filter && service_filter.IsEmpty()) { @@ -509,7 +508,7 @@ int NodeUtility::RemoveBlackAndWhiteList(const String& type, const String& zone_ return 1; } - BOOST_FOREACH(int remove, remove_filters) { + for (int remove : remove_filters) { lists->Remove(remove); } @@ -530,7 +529,7 @@ int NodeUtility::PrintBlackAndWhiteList(std::ostream& fp, const String& type) fp << "Listing all " << type << " entries:\n"; ObjectLock olock(lists); - BOOST_FOREACH(const Dictionary::Ptr& filter, lists) { + for (const Dictionary::Ptr& filter : lists) { fp << type << " filter for Node: '" << filter->Get("zone") << "' Host: '" << filter->Get("host") << "' Service: '" << filter->Get("service") << "'.\n"; } @@ -546,7 +545,7 @@ bool NodeUtility::CheckAgainstBlackAndWhiteList(const String& type, const String << "Checking object against " << type << "."; ObjectLock olock(lists); - BOOST_FOREACH(const Dictionary::Ptr& filter, lists) { + for (const Dictionary::Ptr& filter : lists) { String zone_filter = filter->Get("zone"); String host_filter = filter->Get("host"); String service_filter; @@ -620,7 +619,7 @@ void NodeUtility::SerializeObject(std::ostream& fp, const Dictionary::Ptr& objec fp << " {\n"; ObjectLock olock(object); - BOOST_FOREACH(const Dictionary::Pair& kv, object) { + for (const Dictionary::Pair& kv : object) { if (kv.first == "__type" || kv.first == "__name") continue; diff --git a/lib/cli/nodewizardcommand.cpp b/lib/cli/nodewizardcommand.cpp index d592b0073..31abf94d1 100644 --- a/lib/cli/nodewizardcommand.cpp +++ b/lib/cli/nodewizardcommand.cpp @@ -28,7 +28,6 @@ #include "base/tlsutility.hpp" #include "base/scriptglobal.hpp" #include "base/exception.hpp" -#include #include #include #include diff --git a/lib/cli/objectlistcommand.cpp b/lib/cli/objectlistcommand.cpp index 8005eb384..006edbebc 100644 --- a/lib/cli/objectlistcommand.cpp +++ b/lib/cli/objectlistcommand.cpp @@ -30,7 +30,6 @@ #include "base/debug.hpp" #include "base/objectlock.hpp" #include "base/console.hpp" -#include #include #include #include @@ -129,7 +128,7 @@ void ObjectListCommand::PrintTypeCounts(std::ostream& fp, const std::map::value_type TypeCount; - BOOST_FOREACH(const TypeCount& kv, type_count) { + for (const TypeCount& kv : type_count) { fp << "Found " << kv.second << " " << kv.first << " object"; if (kv.second != 1) diff --git a/lib/cli/objectlistutility.cpp b/lib/cli/objectlistutility.cpp index 82a89fac1..ff3b9b0d4 100644 --- a/lib/cli/objectlistutility.cpp +++ b/lib/cli/objectlistutility.cpp @@ -23,7 +23,6 @@ #include "base/console.hpp" #include "base/objectlock.hpp" #include "base/convert.hpp" -#include #include #include @@ -77,7 +76,7 @@ void ObjectListUtility::PrintProperties(std::ostream& fp, const Dictionary::Ptr& int offset = 2; ObjectLock olock(props); - BOOST_FOREACH(const Dictionary::Pair& kv, props) + for (const Dictionary::Pair& kv : props) { String key = kv.first; Value val = kv.second; @@ -114,7 +113,7 @@ void ObjectListUtility::PrintHints(std::ostream& fp, const Dictionary::Ptr& debu if (messages) { ObjectLock olock(messages); - BOOST_FOREACH(const Value& msg, messages) + for (const Value& msg : messages) { PrintHint(fp, msg, indent); } @@ -155,7 +154,7 @@ void ObjectListUtility::PrintArray(std::ostream& fp, const Array::Ptr& arr) if (arr) { ObjectLock olock(arr); - BOOST_FOREACH(const Value& value, arr) + for (const Value& value : arr) { if (first) first = false; diff --git a/lib/cli/repositoryobjectcommand.cpp b/lib/cli/repositoryobjectcommand.cpp index 6055d81da..e2768d643 100644 --- a/lib/cli/repositoryobjectcommand.cpp +++ b/lib/cli/repositoryobjectcommand.cpp @@ -22,7 +22,6 @@ #include "base/logger.hpp" #include "base/application.hpp" #include "base/utility.hpp" -#include #include #include @@ -164,7 +163,7 @@ int RepositoryObjectCommand::Run(const boost::program_options::variables_map& vm if (vm.count("import")) { Array::Ptr imports = new Array(); - BOOST_FOREACH(const String& import, vm["import"].as >()) { + for (const String& import : vm["import"].as >()) { imports->Add(import); } diff --git a/lib/cli/repositoryutility.cpp b/lib/cli/repositoryutility.cpp index 1ca8984e4..2a41fe5ff 100644 --- a/lib/cli/repositoryutility.cpp +++ b/lib/cli/repositoryutility.cpp @@ -33,7 +33,6 @@ #include "base/console.hpp" #include "base/serializer.hpp" #include "base/exception.hpp" -#include #include #include #include @@ -49,7 +48,7 @@ Dictionary::Ptr RepositoryUtility::GetArgumentAttributes(const std::vector tokens; boost::algorithm::split(tokens, kv, boost::is_any_of("=")); @@ -144,7 +143,7 @@ void RepositoryUtility::PrintObjects(std::ostream& fp, const String& type) { std::vector objects = GetObjects(); //full path - BOOST_FOREACH(const String& object, objects) { + for (const String& object : objects) { if (!FilterRepositoryObjects(type, object)) { Log(LogDebug, "cli") << "Ignoring object '" << object << "'. Type '" << type << "' does not match."; @@ -184,7 +183,7 @@ void RepositoryUtility::PrintChangeLog(std::ostream& fp) std::cout << "Changes to be committed:\n\n"; - BOOST_FOREACH(const Value& entry, changelog) { + for (const Value& entry : changelog) { FormatChangelogEntry(std::cout, entry); } } @@ -209,7 +208,7 @@ bool RepositoryUtility::AddObject(const std::vector& object_paths, const else pattern = EscapeName(name) + ".conf"; - BOOST_FOREACH(const String& object_path, object_paths) { + for (const String& object_path : object_paths) { if (object_path.Contains(pattern)) { Log(LogWarning, "cli") << type << " '" << name << "' already exists. Skipping creation."; @@ -303,7 +302,7 @@ bool RepositoryUtility::CheckChangeExists(const Dictionary::Ptr& change, const A Dictionary::Ptr attrs = change->Get("attrs"); ObjectLock olock(changes); - BOOST_FOREACH(const Dictionary::Ptr& entry, changes) { + for (const Dictionary::Ptr& entry : changes) { if (entry->Get("type") != change->Get("type")) continue; @@ -432,7 +431,7 @@ bool RepositoryUtility::RemoveObjectInternal(const String& name, const String& t boost::bind(&RepositoryUtility::CollectObjects, _1, boost::ref(files)), GlobFile); - BOOST_FOREACH(const String& file, files) { + for (const String& file : files) { RemoveObjectFileInternal(file); } #ifndef _WIN32 @@ -569,7 +568,7 @@ bool RepositoryUtility::GetChangeLog(const boost::functionGet("name") << ConsoleColorTag(Console_Normal) << "'\n"; ObjectLock olock(attrs); - BOOST_FOREACH(const Dictionary::Pair& kv, attrs) { + for (const Dictionary::Pair& kv : attrs) { /* skip the name */ if (kv.first == "name" || kv.first == "__name") continue; @@ -694,7 +693,7 @@ void RepositoryUtility::SerializeObject(std::ostream& fp, const String& name, co Array::Ptr imports = object->Get("import"); ObjectLock olock(imports); - BOOST_FOREACH(const String& import, imports) { + for (const String& import : imports) { fp << "\t" << "import "; ConfigWriter::EmitString(fp, import); fp << '\n'; @@ -702,7 +701,7 @@ void RepositoryUtility::SerializeObject(std::ostream& fp, const String& name, co } ObjectLock xlock(object); - BOOST_FOREACH(const Dictionary::Pair& kv, object) { + for (const Dictionary::Pair& kv : object) { if (kv.first == "import" || kv.first == "name" || kv.first == "__name") { continue; } else { diff --git a/lib/cli/troubleshootcommand.cpp b/lib/cli/troubleshootcommand.cpp index f697cbbf0..d280b12dc 100644 --- a/lib/cli/troubleshootcommand.cpp +++ b/lib/cli/troubleshootcommand.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -325,9 +324,9 @@ bool TroubleshootCommand::CheckFeatures(InfoLog& log) return false; } - BOOST_FOREACH(const String feature, disabled_features) + for (const String feature : disabled_features) features->Set(feature, false); - BOOST_FOREACH(const String feature, enabled_features) + for (const String feature : enabled_features) features->Set(feature, true); InfoLogLine(log) @@ -518,7 +517,7 @@ void TroubleshootCommand::CheckObjectFile(const String& objectfile, InfoLog& log Dictionary::Ptr properties = object->Get("properties"); ObjectLock olock(properties); - BOOST_FOREACH(const Dictionary::Pair& kv, properties) { + for (const Dictionary::Pair& kv : properties) { if (Utility::Match(kv.first, "path")) logs->Set(name, kv.second); } @@ -540,7 +539,7 @@ void TroubleshootCommand::CheckObjectFile(const String& objectfile, InfoLog& log << "Found the " << countTotal << " objects:\n" << " Type" << std::string(typeL-4, ' ') << " : Count\n"; - BOOST_FOREACH(const Dictionary::Pair& kv, type_count) { + for (const Dictionary::Pair& kv : type_count) { InfoLogLine(log) << " " << kv.first << std::string(typeL - kv.first.GetLength(), ' ') << " : " << kv.second << '\n'; @@ -577,7 +576,7 @@ void TroubleshootCommand::PrintLoggers(InfoLog& log, Dictionary::Ptr& logs) << "Getting the last 20 lines of " << logs->GetLength() << " FileLogger objects.\n"; ObjectLock ulock(logs); - BOOST_FOREACH(const Dictionary::Pair& kv, logs) { + for (const Dictionary::Pair& kv : logs) { InfoLogLine(log) << "Logger " << kv.first << " at path: " << kv.second << '\n'; diff --git a/lib/cli/variablegetcommand.cpp b/lib/cli/variablegetcommand.cpp index d205d19eb..ae17f1b52 100644 --- a/lib/cli/variablegetcommand.cpp +++ b/lib/cli/variablegetcommand.cpp @@ -31,7 +31,6 @@ #include "base/objectlock.hpp" #include "base/console.hpp" #include "base/scriptglobal.hpp" -#include #include #include #include diff --git a/lib/cli/variablelistcommand.cpp b/lib/cli/variablelistcommand.cpp index ecc1d9e12..512f16dda 100644 --- a/lib/cli/variablelistcommand.cpp +++ b/lib/cli/variablelistcommand.cpp @@ -26,7 +26,6 @@ #include "base/debug.hpp" #include "base/objectlock.hpp" #include "base/console.hpp" -#include #include #include #include diff --git a/lib/compat/checkresultreader.cpp b/lib/compat/checkresultreader.cpp index 4b1e4ad53..d1fcc057d 100644 --- a/lib/compat/checkresultreader.cpp +++ b/lib/compat/checkresultreader.cpp @@ -44,7 +44,7 @@ void CheckResultReader::StatsFunc(const Dictionary::Ptr& status, const Array::Pt { Dictionary::Ptr nodes = new Dictionary(); - BOOST_FOREACH(const CheckResultReader::Ptr& checkresultreader, ConfigType::GetObjectsByType()) { + for (const CheckResultReader::Ptr& checkresultreader : ConfigType::GetObjectsByType()) { nodes->Set(checkresultreader->GetName(), 1); //add more stats } diff --git a/lib/compat/compatlogger.cpp b/lib/compat/compatlogger.cpp index 438238d35..18effe612 100644 --- a/lib/compat/compatlogger.cpp +++ b/lib/compat/compatlogger.cpp @@ -34,7 +34,6 @@ #include "base/application.hpp" #include "base/utility.hpp" #include "base/statsfunction.hpp" -#include #include using namespace icinga; @@ -47,7 +46,7 @@ void CompatLogger::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&) { Dictionary::Ptr nodes = new Dictionary(); - BOOST_FOREACH(const CompatLogger::Ptr& compat_logger, ConfigType::GetObjectsByType()) { + for (const CompatLogger::Ptr& compat_logger : ConfigType::GetObjectsByType()) { nodes->Set(compat_logger->GetName(), 1); //add more stats } @@ -476,7 +475,7 @@ void CompatLogger::ReopenFile(bool rotate) WriteLine("LOG ROTATION: " + GetRotationMethod()); WriteLine("LOG VERSION: 2.0"); - BOOST_FOREACH(const Host::Ptr& host, ConfigType::GetObjectsByType()) { + for (const Host::Ptr& host : ConfigType::GetObjectsByType()) { String output; CheckResult::Ptr cr = host->GetLastCheckResult(); @@ -494,7 +493,7 @@ void CompatLogger::ReopenFile(bool rotate) WriteLine(msgbuf.str()); } - BOOST_FOREACH(const Service::Ptr& service, ConfigType::GetObjectsByType()) { + for (const Service::Ptr& service : ConfigType::GetObjectsByType()) { Host::Ptr host = service->GetHost(); String output; diff --git a/lib/compat/externalcommandlistener.cpp b/lib/compat/externalcommandlistener.cpp index 359800dbf..3b98bb340 100644 --- a/lib/compat/externalcommandlistener.cpp +++ b/lib/compat/externalcommandlistener.cpp @@ -36,7 +36,7 @@ void ExternalCommandListener::StatsFunc(const Dictionary::Ptr& status, const Arr { Dictionary::Ptr nodes = new Dictionary(); - BOOST_FOREACH(const ExternalCommandListener::Ptr& externalcommandlistener, ConfigType::GetObjectsByType()) { + for (const ExternalCommandListener::Ptr& externalcommandlistener : ConfigType::GetObjectsByType()) { nodes->Set(externalcommandlistener->GetName(), 1); //add more stats } diff --git a/lib/compat/statusdatawriter.cpp b/lib/compat/statusdatawriter.cpp index 8e52526e5..9d6158fca 100644 --- a/lib/compat/statusdatawriter.cpp +++ b/lib/compat/statusdatawriter.cpp @@ -38,7 +38,6 @@ #include "base/application.hpp" #include "base/context.hpp" #include "base/statsfunction.hpp" -#include #include #include #include @@ -54,7 +53,7 @@ void StatusDataWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr { Dictionary::Ptr nodes = new Dictionary(); - BOOST_FOREACH(const StatusDataWriter::Ptr& statusdatawriter, ConfigType::GetObjectsByType()) { + for (const StatusDataWriter::Ptr& statusdatawriter : ConfigType::GetObjectsByType()) { nodes->Set(statusdatawriter->GetName(), 1); //add more stats } @@ -92,7 +91,7 @@ void StatusDataWriter::DumpComments(std::ostream& fp, const Checkable::Ptr& chec Service::Ptr service; tie(host, service) = GetHostService(checkable); - BOOST_FOREACH(const Comment::Ptr& comment, checkable->GetComments()) { + for (const Comment::Ptr& comment : checkable->GetComments()) { if (comment->IsExpired()) continue; @@ -126,7 +125,7 @@ void StatusDataWriter::DumpTimePeriod(std::ostream& fp, const TimePeriod::Ptr& t if (ranges) { ObjectLock olock(ranges); - BOOST_FOREACH(const Dictionary::Pair& kv, ranges) { + for (const Dictionary::Pair& kv : ranges) { fp << "\t" << kv.first << "\t" << kv.second << "\n"; } } @@ -158,7 +157,7 @@ void StatusDataWriter::DumpDowntimes(std::ostream& fp, const Checkable::Ptr& che Service::Ptr service; tie(host, service) = GetHostService(checkable); - BOOST_FOREACH(const Downtime::Ptr& downtime, checkable->GetDowntimes()) { + for (const Downtime::Ptr& downtime : checkable->GetDowntimes()) { if (downtime->IsExpired()) continue; @@ -296,7 +295,7 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host) if (groups) { ObjectLock olock(groups); - BOOST_FOREACH(const String& name, groups) { + for (const String& name : groups) { HostGroup::Ptr hg = HostGroup::GetByName(name); if (hg) { @@ -481,7 +480,7 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s if (groups) { ObjectLock olock(groups); - BOOST_FOREACH(const String& name, groups) { + for (const String& name : groups) { ServiceGroup::Ptr sg = ServiceGroup::GetByName(name); if (sg) { @@ -513,7 +512,7 @@ void StatusDataWriter::DumpCustomAttributes(std::ostream& fp, const CustomVarObj bool is_json = false; ObjectLock olock(vars); - BOOST_FOREACH(const Dictionary::Pair& kv, vars) { + for (const Dictionary::Pair& kv : vars) { if (kv.first.IsEmpty()) continue; @@ -547,13 +546,13 @@ void StatusDataWriter::UpdateObjectsCache(void) "# This file is auto-generated. Do not modify this file." "\n" "\n"; - BOOST_FOREACH(const Host::Ptr& host, ConfigType::GetObjectsByType()) { + for (const Host::Ptr& host : ConfigType::GetObjectsByType()) { std::ostringstream tempobjectfp; tempobjectfp << std::fixed; DumpHostObject(tempobjectfp, host); objectfp << tempobjectfp.str(); - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { std::ostringstream tempobjectfp; tempobjectfp << std::fixed; DumpServiceObject(tempobjectfp, service); @@ -561,7 +560,7 @@ void StatusDataWriter::UpdateObjectsCache(void) } } - BOOST_FOREACH(const HostGroup::Ptr& hg, ConfigType::GetObjectsByType()) { + for (const HostGroup::Ptr& hg : ConfigType::GetObjectsByType()) { std::ostringstream tempobjectfp; tempobjectfp << std::fixed; @@ -592,7 +591,7 @@ void StatusDataWriter::UpdateObjectsCache(void) objectfp << tempobjectfp.str(); } - BOOST_FOREACH(const ServiceGroup::Ptr& sg, ConfigType::GetObjectsByType()) { + for (const ServiceGroup::Ptr& sg : ConfigType::GetObjectsByType()) { std::ostringstream tempobjectfp; tempobjectfp << std::fixed; @@ -618,7 +617,7 @@ void StatusDataWriter::UpdateObjectsCache(void) tempobjectfp << "\t" "members" "\t"; std::vector sglist; - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Host::Ptr host = service->GetHost(); sglist.push_back(host->GetName()); @@ -633,7 +632,7 @@ void StatusDataWriter::UpdateObjectsCache(void) objectfp << tempobjectfp.str(); } - BOOST_FOREACH(const User::Ptr& user, ConfigType::GetObjectsByType()) { + for (const User::Ptr& user : ConfigType::GetObjectsByType()) { std::ostringstream tempobjectfp; tempobjectfp << std::fixed; @@ -661,7 +660,7 @@ void StatusDataWriter::UpdateObjectsCache(void) objectfp << tempobjectfp.str(); } - BOOST_FOREACH(const UserGroup::Ptr& ug, ConfigType::GetObjectsByType()) { + for (const UserGroup::Ptr& ug : ConfigType::GetObjectsByType()) { std::ostringstream tempobjectfp; tempobjectfp << std::fixed; @@ -677,23 +676,23 @@ void StatusDataWriter::UpdateObjectsCache(void) objectfp << tempobjectfp.str(); } - BOOST_FOREACH(const Command::Ptr& command, ConfigType::GetObjectsByType()) { + for (const Command::Ptr& command : ConfigType::GetObjectsByType()) { DumpCommand(objectfp, command); } - BOOST_FOREACH(const Command::Ptr& command, ConfigType::GetObjectsByType()) { + for (const Command::Ptr& command : ConfigType::GetObjectsByType()) { DumpCommand(objectfp, command); } - BOOST_FOREACH(const Command::Ptr& command, ConfigType::GetObjectsByType()) { + for (const Command::Ptr& command : ConfigType::GetObjectsByType()) { DumpCommand(objectfp, command); } - BOOST_FOREACH(const TimePeriod::Ptr& tp, ConfigType::GetObjectsByType()) { + for (const TimePeriod::Ptr& tp : ConfigType::GetObjectsByType()) { DumpTimePeriod(objectfp, tp); } - BOOST_FOREACH(const Dependency::Ptr& dep, ConfigType::GetObjectsByType()) { + for (const Dependency::Ptr& dep : ConfigType::GetObjectsByType()) { Checkable::Ptr parent = dep->GetParent(); if (!parent) { @@ -824,13 +823,13 @@ void StatusDataWriter::StatusTimerHandler(void) statusfp << "\t" "}" "\n" "\n"; - BOOST_FOREACH(const Host::Ptr& host, ConfigType::GetObjectsByType()) { + for (const Host::Ptr& host : ConfigType::GetObjectsByType()) { std::ostringstream tempstatusfp; tempstatusfp << std::fixed; DumpHostStatus(tempstatusfp, host); statusfp << tempstatusfp.str(); - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { std::ostringstream tempstatusfp; tempstatusfp << std::fixed; DumpServiceStatus(tempstatusfp, service); diff --git a/lib/config/applyrule.cpp b/lib/config/applyrule.cpp index f605cf1eb..c917562ee 100644 --- a/lib/config/applyrule.cpp +++ b/lib/config/applyrule.cpp @@ -19,7 +19,6 @@ #include "config/applyrule.hpp" #include "base/logger.hpp" -#include #include using namespace icinga; @@ -121,7 +120,7 @@ bool ApplyRule::IsValidTargetType(const String& sourceType, const String& target if (it->second.size() == 1 && targetType == "") return true; - BOOST_FOREACH(const String& type, it->second) { + for (const String& type : it->second) { if (type == targetType) return true; } @@ -161,8 +160,8 @@ std::vector& ApplyRule::GetRules(const String& type) void ApplyRule::CheckMatches(void) { - BOOST_FOREACH(const RuleMap::value_type& kv, m_Rules) { - BOOST_FOREACH(const ApplyRule& rule, kv.second) { + for (const RuleMap::value_type& kv : m_Rules) { + for (const ApplyRule& rule : kv.second) { if (!rule.HasMatches()) Log(LogWarning, "ApplyRule") << "Apply rule '" << rule.GetName() << "' (" << rule.GetDebugInfo() << ") for type '" << kv.first << "' does not match anywhere!"; diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index b4038f0ed..5d4d2b6f1 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -32,7 +32,6 @@ #include "base/exception.hpp" #include #include -#include #define YYLTYPE icinga::CompilerDebugInfo #define YYERROR_VERBOSE @@ -280,9 +279,8 @@ Expression *ConfigCompiler::Compile(void) m_IgnoreNewlines.pop(); std::vector dlist; - typedef std::pair EListItem; std::vector >::size_type num = 0; - BOOST_FOREACH(const EListItem& litem, llist) { + for (const auto& litem : llist) { if (!litem.second.SideEffect && num != llist.size() - 1) { yyerror(&litem.second.DebugInfo, NULL, NULL, "Value computed is not used."); } @@ -732,7 +730,7 @@ rterm_dict: '{' std::vector dlist; typedef std::pair EListItem; int num = 0; - BOOST_FOREACH(const EListItem& litem, *$3) { + for (const EListItem& litem : *$3) { if (!litem.second.SideEffect) yyerror(&litem.second.DebugInfo, NULL, NULL, "Value computed is not used."); dlist.push_back(litem.first); @@ -755,7 +753,7 @@ rterm_scope_require_side_effect: '{' std::vector dlist; typedef std::pair EListItem; int num = 0; - BOOST_FOREACH(const EListItem& litem, *$3) { + for (const EListItem& litem : *$3) { if (!litem.second.SideEffect) yyerror(&litem.second.DebugInfo, NULL, NULL, "Value computed is not used."); dlist.push_back(litem.first); @@ -779,7 +777,7 @@ rterm_scope: '{' std::vector dlist; typedef std::pair EListItem; std::vector >::size_type num = 0; - BOOST_FOREACH(const EListItem& litem, *$3) { + for (const EListItem& litem : *$3) { if (!litem.second.SideEffect && num != $3->size() - 1) yyerror(&litem.second.DebugInfo, NULL, NULL, "Value computed is not used."); dlist.push_back(litem.first); @@ -1007,7 +1005,7 @@ rterm_no_side_effect_no_dict: T_STRING std::vector dlist; typedef std::pair EListItem; std::vector >::size_type num = 0; - BOOST_FOREACH(const EListItem& litem, *$3) { + for (const EListItem& litem : *$3) { if (!litem.second.SideEffect && num != $3->size() - 1) yyerror(&litem.second.DebugInfo, NULL, NULL, "Value computed is not used."); dlist.push_back(litem.first); diff --git a/lib/config/configcompiler.cpp b/lib/config/configcompiler.cpp index 099f65153..0f26b7b78 100644 --- a/lib/config/configcompiler.cpp +++ b/lib/config/configcompiler.cpp @@ -25,7 +25,6 @@ #include "base/context.hpp" #include "base/exception.hpp" #include -#include using namespace icinga; @@ -144,7 +143,7 @@ Expression *ConfigCompiler::HandleInclude(const String& relativeBase, const Stri String includePath = upath; if (search) { - BOOST_FOREACH(const String& dir, m_IncludeSearchDirs) { + for (const String& dir : m_IncludeSearchDirs) { String spath = dir + "/" + path; if (Utility::PathExists(spath)) { @@ -341,7 +340,7 @@ bool ConfigCompiler::HasZoneConfigAuthority(const String& zoneName) if (!empty) { std::vector paths; - BOOST_FOREACH(const ZoneFragment& zf, zoneDirs) { + for (const ZoneFragment& zf : zoneDirs) { paths.push_back(zf.Path); } diff --git a/lib/config/configcompilercontext.cpp b/lib/config/configcompilercontext.cpp index 0a66968d7..0aef5348e 100644 --- a/lib/config/configcompilercontext.cpp +++ b/lib/config/configcompilercontext.cpp @@ -22,7 +22,6 @@ #include "base/json.hpp" #include "base/netstring.hpp" #include "base/exception.hpp" -#include using namespace icinga; diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp index 0c736b496..073ec95a8 100644 --- a/lib/config/configitem.cpp +++ b/lib/config/configitem.cpp @@ -37,7 +37,6 @@ #include "base/function.hpp" #include #include -#include using namespace icinga; @@ -409,8 +408,8 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue { boost::mutex::scoped_lock lock(m_Mutex); - BOOST_FOREACH(const TypeMap::value_type& kv, m_Items) { - BOOST_FOREACH(const ItemMap::value_type& kv2, kv.second) { + for (const TypeMap::value_type& kv : m_Items) { + for (const ItemMap::value_type& kv2 : kv.second) { if (kv2.second->m_Abstract || kv2.second->m_Object) continue; @@ -423,7 +422,7 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue ItemList newUnnamedItems; - BOOST_FOREACH(const ConfigItem::Ptr& item, m_UnnamedItems) { + for (const ConfigItem::Ptr& item : m_UnnamedItems) { if (item->m_ActivationContext != context) { newUnnamedItems.push_back(item); continue; @@ -441,7 +440,7 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue if (items.empty()) return true; - BOOST_FOREACH(const ItemPair& ip, items) { + for (const ItemPair& ip : items) { newItems.push_back(ip.first); upq.Enqueue(boost::bind(&ConfigItem::Commit, ip.first, ip.second)); } @@ -453,7 +452,7 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue std::set types; - BOOST_FOREACH(const Type::Ptr& type, Type::GetAllTypes()) { + for (const Type::Ptr& type : Type::GetAllTypes()) { if (ConfigObject::TypeInstance->IsAssignableFrom(type)) types.insert(type->GetName()); } @@ -461,7 +460,7 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue std::set completed_types; while (types.size() != completed_types.size()) { - BOOST_FOREACH(const String& type, types) { + for (const String& type : types) { if (completed_types.find(type) != completed_types.end()) continue; @@ -469,7 +468,7 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue bool unresolved_dep = false; /* skip this type (for now) if there are unresolved load dependencies */ - BOOST_FOREACH(const String& loadDep, ptype->GetLoadDependencies()) { + for (const String& loadDep : ptype->GetLoadDependencies()) { if (types.find(loadDep) != types.end() && completed_types.find(loadDep) == completed_types.end()) { unresolved_dep = true; break; @@ -479,7 +478,7 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue if (unresolved_dep) continue; - BOOST_FOREACH(const ItemPair& ip, items) { + for (const ItemPair& ip : items) { const ConfigItem::Ptr& item = ip.first; if (!item->m_Object) @@ -496,8 +495,8 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue if (upq.HasExceptions()) return false; - BOOST_FOREACH(const String& loadDep, ptype->GetLoadDependencies()) { - BOOST_FOREACH(const ItemPair& ip, items) { + for (const String& loadDep : ptype->GetLoadDependencies()) { + for (const ItemPair& ip : items) { const ConfigItem::Ptr& item = ip.first; if (!item->m_Object) @@ -529,7 +528,7 @@ bool ConfigItem::CommitItems(const ActivationContext::Ptr& context, WorkQueue& u if (!CommitNewItems(context, upq, newItems)) { upq.ReportExceptions("config"); - BOOST_FOREACH(const ConfigItem::Ptr& item, newItems) { + for (const ConfigItem::Ptr& item : newItems) { item->Unregister(); } @@ -542,14 +541,14 @@ bool ConfigItem::CommitItems(const ActivationContext::Ptr& context, WorkQueue& u /* log stats for external parsers */ typedef std::map ItemCountMap; ItemCountMap itemCounts; - BOOST_FOREACH(const ConfigItem::Ptr& item, newItems) { + for (const ConfigItem::Ptr& item : newItems) { if (!item->m_Object) continue; itemCounts[item->m_Object->GetReflectionType()]++; } - BOOST_FOREACH(const ItemCountMap::value_type& kv, itemCounts) { + for (const ItemCountMap::value_type& kv : itemCounts) { Log(LogInformation, "ConfigItem") << "Instantiated " << kv.second << " " << (kv.second != 1 ? kv.first->GetPluralName() : kv.first->GetName()) << "."; } @@ -566,7 +565,7 @@ bool ConfigItem::ActivateItems(WorkQueue& upq, const std::vectorm_Object) continue; @@ -590,7 +589,7 @@ bool ConfigItem::ActivateItems(WorkQueue& upq, const std::vectorm_Object; if (!object) @@ -640,7 +639,7 @@ std::vector ConfigItem::GetItems(const String& type) if (it == m_Items.end()) return items; - BOOST_FOREACH(const ItemMap::value_type& kv, it->second) + for (const ItemMap::value_type& kv : it->second) { items.push_back(kv.second); } @@ -652,7 +651,7 @@ void ConfigItem::RemoveIgnoredItems(const String& allowedConfigPath) { boost::mutex::scoped_lock lock(m_Mutex); - BOOST_FOREACH(const String& path, m_IgnoredItems) { + for (const String& path : m_IgnoredItems) { if (path.Find(allowedConfigPath) == String::NPos) continue; diff --git a/lib/config/configitembuilder.cpp b/lib/config/configitembuilder.cpp index 2f19be40b..f45128b1c 100644 --- a/lib/config/configitembuilder.cpp +++ b/lib/config/configitembuilder.cpp @@ -20,7 +20,6 @@ #include "config/configitembuilder.hpp" #include "base/configtype.hpp" #include -#include #include using namespace icinga; diff --git a/lib/config/expression.cpp b/lib/config/expression.cpp index 14f52ac48..f9241da3a 100644 --- a/lib/config/expression.cpp +++ b/lib/config/expression.cpp @@ -28,7 +28,6 @@ #include "base/exception.hpp" #include "base/scriptglobal.hpp" #include "base/loader.hpp" -#include #include #include @@ -429,7 +428,7 @@ ExpressionResult FunctionCallExpression::DoEvaluate(ScriptFrame& frame, DebugHin if (vfunc.IsObjectType()) { std::vector arguments; - BOOST_FOREACH(Expression *arg, m_Args) { + for (Expression *arg : m_Args) { ExpressionResult argres = arg->Evaluate(frame); CHECK_RESULT(argres); @@ -448,7 +447,7 @@ ExpressionResult FunctionCallExpression::DoEvaluate(ScriptFrame& frame, DebugHin BOOST_THROW_EXCEPTION(ScriptError("Function is not marked as safe for sandbox mode.", m_DebugInfo)); std::vector arguments; - BOOST_FOREACH(Expression *arg, m_Args) { + for (Expression *arg : m_Args) { ExpressionResult argres = arg->Evaluate(frame); CHECK_RESULT(argres); @@ -462,7 +461,7 @@ ExpressionResult ArrayExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhin { Array::Ptr result = new Array(); - BOOST_FOREACH(Expression *aexpr, m_Expressions) { + for (Expression *aexpr : m_Expressions) { ExpressionResult element = aexpr->Evaluate(frame); CHECK_RESULT(element); @@ -484,7 +483,7 @@ ExpressionResult DictExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint Value result; try { - BOOST_FOREACH(Expression *aexpr, m_Expressions) { + for (Expression *aexpr : m_Expressions) { ExpressionResult element = aexpr->Evaluate(frame, dhint); CHECK_RESULT(element); result = element.GetValue(); @@ -686,7 +685,7 @@ void icinga::BindToScope(Expression *& expr, ScopeSpecifier scopeSpec) DictExpression *dexpr = dynamic_cast(expr); if (dexpr) { - BOOST_FOREACH(Expression *& expr, dexpr->m_Expressions) + for (Expression *& expr : dexpr->m_Expressions) BindToScope(expr, scopeSpec); return; diff --git a/lib/config/expression.hpp b/lib/config/expression.hpp index c20fe9d15..3734d7183 100644 --- a/lib/config/expression.hpp +++ b/lib/config/expression.hpp @@ -28,7 +28,6 @@ #include "base/exception.hpp" #include "base/scriptframe.hpp" #include "base/convert.hpp" -#include #include #include @@ -574,7 +573,7 @@ public: { delete m_FName; - BOOST_FOREACH(Expression *expr, m_Args) + for (Expression *expr : m_Args) delete expr; } @@ -595,7 +594,7 @@ public: ~ArrayExpression(void) { - BOOST_FOREACH(Expression *expr, m_Expressions) + for (Expression *expr : m_Expressions) delete expr; } @@ -615,7 +614,7 @@ public: ~DictExpression(void) { - BOOST_FOREACH(Expression *expr, m_Expressions) + for (Expression *expr : m_Expressions) delete expr; } @@ -806,7 +805,7 @@ public: { if (m_ClosedVars) { typedef std::pair kv_pair; - BOOST_FOREACH(const kv_pair& kv, *m_ClosedVars) { + for (const kv_pair& kv : *m_ClosedVars) { delete kv.second; } } @@ -843,7 +842,7 @@ public: if (m_ClosedVars) { typedef std::pair kv_pair; - BOOST_FOREACH(const kv_pair& kv, *m_ClosedVars) { + for (const kv_pair& kv : *m_ClosedVars) { delete kv.second; } } @@ -885,7 +884,7 @@ public: if (m_ClosedVars) { typedef std::pair kv_pair; - BOOST_FOREACH(const kv_pair& kv, *m_ClosedVars) { + for (const kv_pair& kv : *m_ClosedVars) { delete kv.second; } } diff --git a/lib/config/objectrule.cpp b/lib/config/objectrule.cpp index 471277a15..39ecad402 100644 --- a/lib/config/objectrule.cpp +++ b/lib/config/objectrule.cpp @@ -18,7 +18,6 @@ ******************************************************************************/ #include "config/objectrule.hpp" -#include #include using namespace icinga; diff --git a/lib/config/vmops.hpp b/lib/config/vmops.hpp index 8a11b5259..948cce1da 100644 --- a/lib/config/vmops.hpp +++ b/lib/config/vmops.hpp @@ -33,7 +33,6 @@ #include "base/exception.hpp" #include "base/convert.hpp" #include "base/objectlock.hpp" -#include #include #include #include @@ -49,7 +48,7 @@ public: Array::Ptr imports = ScriptFrame::GetImports(); ObjectLock olock(imports); - BOOST_FOREACH(const Value& import, imports) { + for (const Value& import : imports) { Object::Ptr obj = import; if (obj->HasOwnField(name)) { *result = import; @@ -192,12 +191,12 @@ public: { ObjectLock olock(dict); - BOOST_FOREACH(const Dictionary::Pair& kv, dict) { + for (const Dictionary::Pair& kv : dict) { keys.push_back(kv.first); } } - BOOST_FOREACH(const String& key, keys) { + for (const String& key : keys) { frame.Locals->Set(fkvar, key); frame.Locals->Set(fvvar, dict->Get(key)); ExpressionResult res = expression->Evaluate(frame); @@ -256,7 +255,7 @@ private: locals = new Dictionary(); typedef std::pair ClosedVar; - BOOST_FOREACH(const ClosedVar& cvar, *closedVars) { + for (const ClosedVar& cvar : *closedVars) { locals->Set(cvar.first, cvar.second->Evaluate(frame)); } } diff --git a/lib/db_ido/commanddbobject.cpp b/lib/db_ido/commanddbobject.cpp index 391ce8990..4789f81af 100644 --- a/lib/db_ido/commanddbobject.cpp +++ b/lib/db_ido/commanddbobject.cpp @@ -24,7 +24,6 @@ #include "icinga/compatutility.hpp" #include "base/objectlock.hpp" #include "base/convert.hpp" -#include using namespace icinga; diff --git a/lib/db_ido/dbconnection.cpp b/lib/db_ido/dbconnection.cpp index 973424d7d..8407a5747 100644 --- a/lib/db_ido/dbconnection.cpp +++ b/lib/db_ido/dbconnection.cpp @@ -29,7 +29,6 @@ #include "base/utility.hpp" #include "base/logger.hpp" #include "base/exception.hpp" -#include using namespace icinga; @@ -466,13 +465,13 @@ void DbConnection::UpdateObject(const ConfigObject::Ptr& object) void DbConnection::UpdateAllObjects(void) { - BOOST_FOREACH(const Type::Ptr& type, Type::GetAllTypes()) { + for (const Type::Ptr& type : Type::GetAllTypes()) { ConfigType *dtype = dynamic_cast(type.get()); if (!dtype) continue; - BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) { + for (const ConfigObject::Ptr& object : dtype->GetObjects()) { UpdateObject(object); } } @@ -480,7 +479,7 @@ void DbConnection::UpdateAllObjects(void) void DbConnection::PrepareDatabase(void) { - BOOST_FOREACH(const DbType::Ptr& type, DbType::GetAllTypes()) { + for (const DbType::Ptr& type : DbType::GetAllTypes()) { FillIDCache(type); } } diff --git a/lib/db_ido/dbevents.cpp b/lib/db_ido/dbevents.cpp index 61814ac2a..660844c7e 100644 --- a/lib/db_ido/dbevents.cpp +++ b/lib/db_ido/dbevents.cpp @@ -33,7 +33,6 @@ #include "icinga/externalcommandprocessor.hpp" #include "icinga/compatutility.hpp" #include "icinga/icingaapplication.hpp" -#include #include using namespace icinga; @@ -203,7 +202,7 @@ void DbEvents::ReachabilityChangedHandler(const Checkable::Ptr& checkable, const Log(LogDebug, "DbEvents") << "Updating reachability for checkable '" << checkable->GetName() << "': " << (is_reachable ? "" : "not" ) << " reachable for " << children.size() << " children."; - BOOST_FOREACH(const Checkable::Ptr& child, children) { + for (const Checkable::Ptr& child : children) { Log(LogDebug, "DbEvents") << "Updating reachability for checkable '" << child->GetName() << "': " << (is_reachable ? "" : "not" ) << " reachable."; @@ -305,7 +304,7 @@ void DbEvents::AddComments(const Checkable::Ptr& checkable) std::vector queries; - BOOST_FOREACH(const Comment::Ptr& comment, comments) { + for (const Comment::Ptr& comment : comments) { AddCommentInternal(queries, comment, false); } @@ -443,7 +442,7 @@ void DbEvents::AddDowntimes(const Checkable::Ptr& checkable) std::vector queries; - BOOST_FOREACH(const Downtime::Ptr& downtime, downtimes) { + for (const Downtime::Ptr& downtime : downtimes) { AddDowntimeInternal(queries, downtime, false); } @@ -875,7 +874,7 @@ void DbEvents::AddNotificationHistory(const Notification::Ptr& notification, con std::vector queries; - BOOST_FOREACH(const User::Ptr& user, users) { + for (const User::Ptr& user : users) { Log(LogDebug, "DbEvents") << "add contact notification history for service '" << checkable->GetName() << "' and user '" << user->GetName() << "'."; diff --git a/lib/db_ido/dbobject.cpp b/lib/db_ido/dbobject.cpp index e00691aed..7affe2afb 100644 --- a/lib/db_ido/dbobject.cpp +++ b/lib/db_ido/dbobject.cpp @@ -37,7 +37,6 @@ #include "base/utility.hpp" #include "base/initialize.hpp" #include "base/logger.hpp" -#include using namespace icinga; @@ -92,7 +91,7 @@ String DbObject::CalculateConfigHash(const Dictionary::Ptr& configFields) const { ObjectLock olock(configFieldsDup); - BOOST_FOREACH(const Dictionary::Pair& kv, configFieldsDup) { + for (const Dictionary::Pair& kv : configFieldsDup) { if (kv.second.IsObjectType()) { ConfigObject::Ptr obj = kv.second; configFieldsDup->Set(kv.first, obj->GetName()); @@ -235,7 +234,7 @@ void DbObject::SendVarsConfigUpdateHeavy(void) if (vars) { ObjectLock olock (vars); - BOOST_FOREACH(const Dictionary::Pair& kv, vars) { + for (const Dictionary::Pair& kv : vars) { if (kv.first.IsEmpty()) continue; @@ -284,7 +283,7 @@ void DbObject::SendVarsStatusUpdate(void) std::vector queries; ObjectLock olock (vars); - BOOST_FOREACH(const Dictionary::Pair& kv, vars) { + for (const Dictionary::Pair& kv : vars) { if (kv.first.IsEmpty()) continue; diff --git a/lib/db_ido/dbtype.cpp b/lib/db_ido/dbtype.cpp index ea25ec56c..bb6f4e8de 100644 --- a/lib/db_ido/dbtype.cpp +++ b/lib/db_ido/dbtype.cpp @@ -22,7 +22,6 @@ #include "base/objectlock.hpp" #include "base/debug.hpp" #include -#include using namespace icinga; @@ -78,7 +77,7 @@ DbType::Ptr DbType::GetByID(long tid) { boost::mutex::scoped_lock lock(GetStaticMutex()); - BOOST_FOREACH(const TypeMap::value_type& kv, GetTypes()) { + for (const TypeMap::value_type& kv : GetTypes()) { if (kv.second->GetTypeID() == tid) return kv.second; } @@ -142,10 +141,11 @@ std::set DbType::GetAllTypes(void) { std::set result; - boost::mutex::scoped_lock lock(GetStaticMutex()); - std::pair kv; - BOOST_FOREACH(kv, GetTypes()) { - result.insert(kv.second); + { + boost::mutex::scoped_lock lock(GetStaticMutex()); + for (const auto& kv : GetTypes()) { + result.insert(kv.second); + } } return result; diff --git a/lib/db_ido/endpointdbobject.cpp b/lib/db_ido/endpointdbobject.cpp index f01dcc518..be0ff646f 100644 --- a/lib/db_ido/endpointdbobject.cpp +++ b/lib/db_ido/endpointdbobject.cpp @@ -27,7 +27,6 @@ #include "base/utility.hpp" #include "base/convert.hpp" #include "base/logger.hpp" -#include using namespace icinga; diff --git a/lib/db_ido/hostdbobject.cpp b/lib/db_ido/hostdbobject.cpp index d607531f2..5af33e49a 100644 --- a/lib/db_ido/hostdbobject.cpp +++ b/lib/db_ido/hostdbobject.cpp @@ -33,7 +33,6 @@ #include "base/objectlock.hpp" #include "base/logger.hpp" #include "base/json.hpp" -#include using namespace icinga; @@ -197,7 +196,7 @@ void HostDbObject::OnConfigUpdateHeavy(void) if (groups) { ObjectLock olock(groups); - BOOST_FOREACH(const String& groupName, groups) { + for (const String& groupName : groups) { HostGroup::Ptr group = HostGroup::GetByName(groupName); DbQuery query2; @@ -231,7 +230,7 @@ void HostDbObject::OnConfigUpdateHeavy(void) queries.push_back(query2); /* parents */ - BOOST_FOREACH(const Checkable::Ptr& checkable, host->GetParents()) { + for (const Checkable::Ptr& checkable : host->GetParents()) { Host::Ptr parent = dynamic_pointer_cast(checkable); if (!parent) @@ -272,7 +271,7 @@ void HostDbObject::OnConfigUpdateHeavy(void) queries.push_back(query3); - BOOST_FOREACH(const Dependency::Ptr& dep, host->GetDependencies()) { + for (const Dependency::Ptr& dep : host->GetDependencies()) { Checkable::Ptr parent = dep->GetParent(); if (!parent) { @@ -320,7 +319,7 @@ void HostDbObject::OnConfigUpdateHeavy(void) queries.push_back(query4); - BOOST_FOREACH(const User::Ptr& user, CompatUtility::GetCheckableNotificationUsers(host)) { + for (const User::Ptr& user : CompatUtility::GetCheckableNotificationUsers(host)) { Log(LogDebug, "HostDbObject") << "host contacts: " << user->GetName(); @@ -354,7 +353,7 @@ void HostDbObject::OnConfigUpdateHeavy(void) queries.push_back(query5); - BOOST_FOREACH(const UserGroup::Ptr& usergroup, CompatUtility::GetCheckableNotificationUserGroups(host)) { + for (const UserGroup::Ptr& usergroup : CompatUtility::GetCheckableNotificationUserGroups(host)) { Log(LogDebug, "HostDbObject") << "host contactgroups: " << usergroup->GetName(); @@ -405,7 +404,7 @@ String HostDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields) co Array::Ptr parents = new Array(); /* parents */ - BOOST_FOREACH(const Checkable::Ptr& checkable, host->GetParents()) { + for (const Checkable::Ptr& checkable : host->GetParents()) { Host::Ptr parent = dynamic_pointer_cast(checkable); if (!parent) @@ -421,7 +420,7 @@ String HostDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields) co Array::Ptr dependencies = new Array(); /* dependencies */ - BOOST_FOREACH(const Dependency::Ptr& dep, host->GetDependencies()) { + for (const Dependency::Ptr& dep : host->GetDependencies()) { Checkable::Ptr parent = dep->GetParent(); if (!parent) @@ -441,7 +440,7 @@ String HostDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields) co Array::Ptr users = new Array(); - BOOST_FOREACH(const User::Ptr& user, CompatUtility::GetCheckableNotificationUsers(host)) { + for (const User::Ptr& user : CompatUtility::GetCheckableNotificationUsers(host)) { users->Add(user->GetName()); } @@ -451,7 +450,7 @@ String HostDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields) co Array::Ptr userGroups = new Array(); - BOOST_FOREACH(const UserGroup::Ptr& usergroup, CompatUtility::GetCheckableNotificationUserGroups(host)) { + for (const UserGroup::Ptr& usergroup : CompatUtility::GetCheckableNotificationUserGroups(host)) { userGroups->Add(usergroup->GetName()); } diff --git a/lib/db_ido/hostgroupdbobject.cpp b/lib/db_ido/hostgroupdbobject.cpp index 7de968ec6..d134d8fa4 100644 --- a/lib/db_ido/hostgroupdbobject.cpp +++ b/lib/db_ido/hostgroupdbobject.cpp @@ -23,7 +23,6 @@ #include "base/objectlock.hpp" #include "base/initialize.hpp" #include "base/configtype.hpp" -#include using namespace icinga; diff --git a/lib/db_ido/idochecktask.cpp b/lib/db_ido/idochecktask.cpp index c6dc1d8e4..ed3cfc18f 100644 --- a/lib/db_ido/idochecktask.cpp +++ b/lib/db_ido/idochecktask.cpp @@ -29,7 +29,6 @@ #include "base/utility.hpp" #include "base/configtype.hpp" #include "base/convert.hpp" -#include using namespace icinga; diff --git a/lib/db_ido/servicedbobject.cpp b/lib/db_ido/servicedbobject.cpp index ca3a5a2e0..f1009d51d 100644 --- a/lib/db_ido/servicedbobject.cpp +++ b/lib/db_ido/servicedbobject.cpp @@ -37,7 +37,6 @@ #include "base/utility.hpp" #include "base/logger.hpp" #include "base/json.hpp" -#include #include using namespace icinga; @@ -191,7 +190,7 @@ void ServiceDbObject::OnConfigUpdateHeavy(void) if (groups) { ObjectLock olock(groups); - BOOST_FOREACH(const String& groupName, groups) { + for (const String& groupName : groups) { ServiceGroup::Ptr group = ServiceGroup::GetByName(groupName); DbQuery query2; @@ -228,7 +227,7 @@ void ServiceDbObject::OnConfigUpdateHeavy(void) queries.push_back(query2); - BOOST_FOREACH(const Dependency::Ptr& dep, service->GetDependencies()) { + for (const Dependency::Ptr& dep : service->GetDependencies()) { Checkable::Ptr parent = dep->GetParent(); if (!parent) { @@ -280,7 +279,7 @@ void ServiceDbObject::OnConfigUpdateHeavy(void) queries.push_back(query3); - BOOST_FOREACH(const User::Ptr& user, CompatUtility::GetCheckableNotificationUsers(service)) { + for (const User::Ptr& user : CompatUtility::GetCheckableNotificationUsers(service)) { Log(LogDebug, "ServiceDbObject") << "service contacts: " << user->GetName(); @@ -314,7 +313,7 @@ void ServiceDbObject::OnConfigUpdateHeavy(void) queries.push_back(query4); - BOOST_FOREACH(const UserGroup::Ptr& usergroup, CompatUtility::GetCheckableNotificationUserGroups(service)) { + for (const UserGroup::Ptr& usergroup : CompatUtility::GetCheckableNotificationUserGroups(service)) { Log(LogDebug, "ServiceDbObject") << "service contactgroups: " << usergroup->GetName(); @@ -365,7 +364,7 @@ String ServiceDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields) Array::Ptr dependencies = new Array(); /* dependencies */ - BOOST_FOREACH(const Dependency::Ptr& dep, service->GetDependencies()) { + for (const Dependency::Ptr& dep : service->GetDependencies()) { Checkable::Ptr parent = dep->GetParent(); if (!parent) @@ -385,7 +384,7 @@ String ServiceDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields) Array::Ptr users = new Array(); - BOOST_FOREACH(const User::Ptr& user, CompatUtility::GetCheckableNotificationUsers(service)) { + for (const User::Ptr& user : CompatUtility::GetCheckableNotificationUsers(service)) { users->Add(user->GetName()); } @@ -395,7 +394,7 @@ String ServiceDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields) Array::Ptr userGroups = new Array(); - BOOST_FOREACH(const UserGroup::Ptr& usergroup, CompatUtility::GetCheckableNotificationUserGroups(service)) { + for (const UserGroup::Ptr& usergroup : CompatUtility::GetCheckableNotificationUserGroups(service)) { userGroups->Add(usergroup->GetName()); } diff --git a/lib/db_ido/servicegroupdbobject.cpp b/lib/db_ido/servicegroupdbobject.cpp index d3395fc90..86a45017c 100644 --- a/lib/db_ido/servicegroupdbobject.cpp +++ b/lib/db_ido/servicegroupdbobject.cpp @@ -22,7 +22,6 @@ #include "db_ido/dbvalue.hpp" #include "base/objectlock.hpp" #include "base/initialize.hpp" -#include using namespace icinga; diff --git a/lib/db_ido/timeperioddbobject.cpp b/lib/db_ido/timeperioddbobject.cpp index 290a2bff4..2cca1f8f2 100644 --- a/lib/db_ido/timeperioddbobject.cpp +++ b/lib/db_ido/timeperioddbobject.cpp @@ -25,7 +25,6 @@ #include "base/utility.hpp" #include "base/exception.hpp" #include "base/objectlock.hpp" -#include using namespace icinga; @@ -69,7 +68,7 @@ void TimePeriodDbObject::OnConfigUpdateHeavy(void) time_t refts = Utility::GetTime(); ObjectLock olock(ranges); - BOOST_FOREACH(const Dictionary::Pair& kv, ranges) { + for (const Dictionary::Pair& kv : ranges) { int wday = LegacyTimePeriod::WeekdayFromString(kv.first); if (wday == -1) @@ -81,7 +80,7 @@ void TimePeriodDbObject::OnConfigUpdateHeavy(void) LegacyTimePeriod::ProcessTimeRanges(kv.second, &reference, segments); ObjectLock olock(segments); - BOOST_FOREACH(const Value& vsegment, segments) { + for (const Value& vsegment : segments) { Dictionary::Ptr segment = vsegment; int begin = segment->Get("begin"); int end = segment->Get("end"); diff --git a/lib/db_ido/userdbobject.cpp b/lib/db_ido/userdbobject.cpp index c50a78e71..bedada1aa 100644 --- a/lib/db_ido/userdbobject.cpp +++ b/lib/db_ido/userdbobject.cpp @@ -26,7 +26,6 @@ #include "base/convert.hpp" #include "base/objectlock.hpp" #include "base/logger.hpp" -#include using namespace icinga; @@ -100,7 +99,7 @@ void UserDbObject::OnConfigUpdateHeavy(void) if (groups) { ObjectLock olock(groups); - BOOST_FOREACH(const String& groupName, groups) { + for (const String& groupName : groups) { UserGroup::Ptr group = UserGroup::GetByName(groupName); DbQuery query2; diff --git a/lib/db_ido/usergroupdbobject.cpp b/lib/db_ido/usergroupdbobject.cpp index a5419b58b..017dd55a5 100644 --- a/lib/db_ido/usergroupdbobject.cpp +++ b/lib/db_ido/usergroupdbobject.cpp @@ -23,7 +23,6 @@ #include "base/objectlock.hpp" #include "base/initialize.hpp" #include "base/configtype.hpp" -#include using namespace icinga; diff --git a/lib/db_ido_mysql/idomysqlconnection.cpp b/lib/db_ido_mysql/idomysqlconnection.cpp index 486a816bd..5f9cfaace 100644 --- a/lib/db_ido_mysql/idomysqlconnection.cpp +++ b/lib/db_ido_mysql/idomysqlconnection.cpp @@ -31,7 +31,6 @@ #include "base/exception.hpp" #include "base/statsfunction.hpp" #include -#include using namespace icinga; @@ -53,7 +52,7 @@ void IdoMysqlConnection::StatsFunc(const Dictionary::Ptr& status, const Array::P { Dictionary::Ptr nodes = new Dictionary(); - BOOST_FOREACH(const IdoMysqlConnection::Ptr& idomysqlconnection, ConfigType::GetObjectsByType()) { + for (const IdoMysqlConnection::Ptr& idomysqlconnection : ConfigType::GetObjectsByType()) { size_t items = idomysqlconnection->m_QueryQueue.GetLength(); Dictionary::Ptr stats = new Dictionary(); @@ -401,7 +400,7 @@ void IdoMysqlConnection::Reconnect(void) EnableActiveChangedHandler(); - BOOST_FOREACH(const DbObject::Ptr& dbobj, activeDbObjs) { + for (const DbObject::Ptr& dbobj : activeDbObjs) { if (dbobj->GetObject()) continue; @@ -830,7 +829,7 @@ bool IdoMysqlConnection::CanExecuteQuery(const DbQuery& query) ObjectLock olock(query.WhereCriteria); Value value; - BOOST_FOREACH(const Dictionary::Pair& kv, query.WhereCriteria) { + for (const Dictionary::Pair& kv : query.WhereCriteria) { if (!FieldToEscapedString(kv.first, kv.second, &value)) return false; } @@ -839,7 +838,7 @@ bool IdoMysqlConnection::CanExecuteQuery(const DbQuery& query) if (query.Fields) { ObjectLock olock(query.Fields); - BOOST_FOREACH(const Dictionary::Pair& kv, query.Fields) { + for (const Dictionary::Pair& kv : query.Fields) { Value value; if (kv.second.IsEmpty() && !kv.second.IsString()) @@ -860,7 +859,7 @@ void IdoMysqlConnection::InternalExecuteMultipleQueries(const std::vector -#include using namespace icinga; @@ -57,7 +56,7 @@ void IdoPgsqlConnection::StatsFunc(const Dictionary::Ptr& status, const Array::P { Dictionary::Ptr nodes = new Dictionary(); - BOOST_FOREACH(const IdoPgsqlConnection::Ptr& idopgsqlconnection, ConfigType::GetObjectsByType()) { + for (const IdoPgsqlConnection::Ptr& idopgsqlconnection : ConfigType::GetObjectsByType()) { size_t items = idopgsqlconnection->m_QueryQueue.GetLength(); Dictionary::Ptr stats = new Dictionary(); @@ -374,7 +373,7 @@ void IdoPgsqlConnection::Reconnect(void) EnableActiveChangedHandler(); - BOOST_FOREACH(const DbObject::Ptr& dbobj, activeDbObjs) { + for (const DbObject::Ptr& dbobj : activeDbObjs) { if (dbobj->GetObject()) continue; @@ -687,7 +686,7 @@ bool IdoPgsqlConnection::CanExecuteQuery(const DbQuery& query) ObjectLock olock(query.WhereCriteria); Value value; - BOOST_FOREACH(const Dictionary::Pair& kv, query.WhereCriteria) { + for (const Dictionary::Pair& kv : query.WhereCriteria) { if (!FieldToEscapedString(kv.first, kv.second, &value)) return false; } @@ -696,7 +695,7 @@ bool IdoPgsqlConnection::CanExecuteQuery(const DbQuery& query) if (query.Fields) { ObjectLock olock(query.Fields); - BOOST_FOREACH(const Dictionary::Pair& kv, query.Fields) { + for (const Dictionary::Pair& kv : query.Fields) { Value value; if (kv.second.IsEmpty() && !kv.second.IsString()) @@ -717,7 +716,7 @@ void IdoPgsqlConnection::InternalExecuteMultipleQueries(const std::vectorContains("timestamp")) return ApiActions::CreateResult(403, "A timestamp is required to delay notifications"); - BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) { + for (const Notification::Ptr& notification : checkable->GetNotifications()) { notification->SetNextNotification(HttpUtility::GetLastParameter(params, "timestamp")); } @@ -275,7 +275,7 @@ Dictionary::Ptr ApiActions::RemoveComment(const ConfigObject::Ptr& object, if (checkable) { std::set comments = checkable->GetComments(); - BOOST_FOREACH(const Comment::Ptr& comment, comments) { + for (const Comment::Ptr& comment : comments) { Comment::RemoveComment(comment->GetName()); } @@ -341,7 +341,7 @@ Dictionary::Ptr ApiActions::RemoveDowntime(const ConfigObject::Ptr& object, if (checkable) { std::set downtimes = checkable->GetDowntimes(); - BOOST_FOREACH(const Downtime::Ptr& downtime, downtimes) { + for (const Downtime::Ptr& downtime : downtimes) { Downtime::RemoveDowntime(downtime->GetName(), true); } diff --git a/lib/icinga/apievents.cpp b/lib/icinga/apievents.cpp index baa624087..6c4e9cbd5 100644 --- a/lib/icinga/apievents.cpp +++ b/lib/icinga/apievents.cpp @@ -70,7 +70,7 @@ void ApiEvents::CheckResultHandler(const Checkable::Ptr& checkable, const CheckR result->Set("check_result", Serialize(cr)); - BOOST_FOREACH(const EventQueue::Ptr& queue, queues) { + for (const EventQueue::Ptr& queue : queues) { queue->ProcessEvent(result); } } @@ -100,7 +100,7 @@ void ApiEvents::StateChangeHandler(const Checkable::Ptr& checkable, const CheckR result->Set("state_type", checkable->GetStateType()); result->Set("check_result", Serialize(cr)); - BOOST_FOREACH(const EventQueue::Ptr& queue, queues) { + for (const EventQueue::Ptr& queue : queues) { queue->ProcessEvent(result); } } @@ -130,7 +130,7 @@ void ApiEvents::NotificationSentToAllUsersHandler(const Notification::Ptr& notif Array::Ptr userNames = new Array(); - BOOST_FOREACH(const User::Ptr& user, users) { + for (const User::Ptr& user : users) { userNames->Add(user->GetName()); } @@ -140,7 +140,7 @@ void ApiEvents::NotificationSentToAllUsersHandler(const Notification::Ptr& notif result->Set("text", text); result->Set("check_result", Serialize(cr)); - BOOST_FOREACH(const EventQueue::Ptr& queue, queues) { + for (const EventQueue::Ptr& queue : queues) { queue->ProcessEvent(result); } } @@ -170,7 +170,7 @@ void ApiEvents::FlappingChangedHandler(const Checkable::Ptr& checkable, const Me result->Set("state_type", checkable->GetStateType()); result->Set("is_flapping", checkable->IsFlapping()); - BOOST_FOREACH(const EventQueue::Ptr& queue, queues) { + for (const EventQueue::Ptr& queue : queues) { queue->ProcessEvent(result); } } @@ -207,7 +207,7 @@ void ApiEvents::AcknowledgementSetHandler(const Checkable::Ptr& checkable, result->Set("notify", notify); result->Set("expiry", expiry); - BOOST_FOREACH(const EventQueue::Ptr& queue, queues) { + for (const EventQueue::Ptr& queue : queues) { queue->ProcessEvent(result); } } @@ -236,7 +236,7 @@ void ApiEvents::AcknowledgementClearedHandler(const Checkable::Ptr& checkable, c result->Set("state", service ? static_cast(service->GetState()) : static_cast(host->GetState())); result->Set("state_type", checkable->GetStateType()); - BOOST_FOREACH(const EventQueue::Ptr& queue, queues) { + for (const EventQueue::Ptr& queue : queues) { queue->ProcessEvent(result); } @@ -258,7 +258,7 @@ void ApiEvents::CommentAddedHandler(const Comment::Ptr& comment) result->Set("comment", Serialize(comment, FAConfig | FAState)); - BOOST_FOREACH(const EventQueue::Ptr& queue, queues) { + for (const EventQueue::Ptr& queue : queues) { queue->ProcessEvent(result); } } @@ -278,7 +278,7 @@ void ApiEvents::CommentRemovedHandler(const Comment::Ptr& comment) result->Set("comment", Serialize(comment, FAConfig | FAState)); - BOOST_FOREACH(const EventQueue::Ptr& queue, queues) { + for (const EventQueue::Ptr& queue : queues) { queue->ProcessEvent(result); } } @@ -298,7 +298,7 @@ void ApiEvents::DowntimeAddedHandler(const Downtime::Ptr& downtime) result->Set("downtime", Serialize(downtime, FAConfig | FAState)); - BOOST_FOREACH(const EventQueue::Ptr& queue, queues) { + for (const EventQueue::Ptr& queue : queues) { queue->ProcessEvent(result); } } @@ -318,7 +318,7 @@ void ApiEvents::DowntimeRemovedHandler(const Downtime::Ptr& downtime) result->Set("downtime", Serialize(downtime, FAConfig | FAState)); - BOOST_FOREACH(const EventQueue::Ptr& queue, queues) { + for (const EventQueue::Ptr& queue : queues) { queue->ProcessEvent(result); } } @@ -338,7 +338,7 @@ void ApiEvents::DowntimeTriggeredHandler(const Downtime::Ptr& downtime) result->Set("downtime", Serialize(downtime, FAConfig | FAState)); - BOOST_FOREACH(const EventQueue::Ptr& queue, queues) { + for (const EventQueue::Ptr& queue : queues) { queue->ProcessEvent(result); } } diff --git a/lib/icinga/checkable-check.cpp b/lib/icinga/checkable-check.cpp index 00e48232b..0bcc509c2 100644 --- a/lib/icinga/checkable-check.cpp +++ b/lib/icinga/checkable-check.cpp @@ -31,7 +31,6 @@ #include "base/convert.hpp" #include "base/utility.hpp" #include "base/context.hpp" -#include using namespace icinga; @@ -240,7 +239,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig } /* reschedule direct parents */ - BOOST_FOREACH(const Checkable::Ptr& parent, GetParents()) { + for (const Checkable::Ptr& parent : GetParents()) { if (parent.get() == this) continue; diff --git a/lib/icinga/checkable-comment.cpp b/lib/icinga/checkable-comment.cpp index c0df46469..f0c1620a0 100644 --- a/lib/icinga/checkable-comment.cpp +++ b/lib/icinga/checkable-comment.cpp @@ -24,21 +24,20 @@ #include "base/timer.hpp" #include "base/utility.hpp" #include "base/logger.hpp" -#include using namespace icinga; void Checkable::RemoveAllComments(void) { - BOOST_FOREACH(const Comment::Ptr& comment, GetComments()) { + for (const Comment::Ptr& comment : GetComments()) { Comment::RemoveComment(comment->GetName()); } } void Checkable::RemoveCommentsByType(int type) { - BOOST_FOREACH(const Comment::Ptr& comment, GetComments()) { + for (const Comment::Ptr& comment : GetComments()) { if (comment->GetEntryType() == type) Comment::RemoveComment(comment->GetName()); } diff --git a/lib/icinga/checkable-dependency.cpp b/lib/icinga/checkable-dependency.cpp index c8e08bf94..8f1d46542 100644 --- a/lib/icinga/checkable-dependency.cpp +++ b/lib/icinga/checkable-dependency.cpp @@ -20,7 +20,6 @@ #include "icinga/service.hpp" #include "icinga/dependency.hpp" #include "base/logger.hpp" -#include using namespace icinga; @@ -69,7 +68,7 @@ bool Checkable::IsReachable(DependencyType dt, Dependency::Ptr *failedDependency return false; } - BOOST_FOREACH(const Checkable::Ptr& checkable, GetParents()) { + for (const Checkable::Ptr& checkable : GetParents()) { if (!checkable->IsReachable(dt, failedDependency, rstack + 1)) return false; } @@ -87,7 +86,7 @@ bool Checkable::IsReachable(DependencyType dt, Dependency::Ptr *failedDependency } } - BOOST_FOREACH(const Dependency::Ptr& dep, GetDependencies()) { + for (const Dependency::Ptr& dep : GetDependencies()) { if (!dep->IsAvailable(dt)) { if (failedDependency) *failedDependency = dep; @@ -106,7 +105,7 @@ std::set Checkable::GetParents(void) const { std::set parents; - BOOST_FOREACH(const Dependency::Ptr& dep, GetDependencies()) { + for (const Dependency::Ptr& dep : GetDependencies()) { Checkable::Ptr parent = dep->GetParent(); if (parent && parent.get() != this) @@ -120,7 +119,7 @@ std::set Checkable::GetChildren(void) const { std::set parents; - BOOST_FOREACH(const Dependency::Ptr& dep, GetReverseDependencies()) { + for (const Dependency::Ptr& dep : GetReverseDependencies()) { Checkable::Ptr service = dep->GetChild(); if (service && service.get() != this) diff --git a/lib/icinga/checkable-downtime.cpp b/lib/icinga/checkable-downtime.cpp index f1eec03ef..c872a27f4 100644 --- a/lib/icinga/checkable-downtime.cpp +++ b/lib/icinga/checkable-downtime.cpp @@ -23,27 +23,26 @@ #include "base/logger.hpp" #include "base/utility.hpp" #include "base/convert.hpp" -#include using namespace icinga; void Checkable::RemoveAllDowntimes(void) { - BOOST_FOREACH(const Downtime::Ptr& downtime, GetDowntimes()) { + for (const Downtime::Ptr& downtime : GetDowntimes()) { Downtime::RemoveDowntime(downtime->GetName(), true, true); } } void Checkable::TriggerDowntimes(void) { - BOOST_FOREACH(const Downtime::Ptr& downtime, GetDowntimes()) { + for (const Downtime::Ptr& downtime : GetDowntimes()) { downtime->TriggerDowntime(); } } bool Checkable::IsInDowntime(void) const { - BOOST_FOREACH(const Downtime::Ptr& downtime, GetDowntimes()) { + for (const Downtime::Ptr& downtime : GetDowntimes()) { if (downtime->IsInEffect()) return true; } @@ -55,7 +54,7 @@ int Checkable::GetDowntimeDepth(void) const { int downtime_depth = 0; - BOOST_FOREACH(const Downtime::Ptr& downtime, GetDowntimes()) { + for (const Downtime::Ptr& downtime : GetDowntimes()) { if (downtime->IsInEffect()) downtime_depth++; } diff --git a/lib/icinga/checkable-flapping.cpp b/lib/icinga/checkable-flapping.cpp index 1169a34a4..64aa6a490 100644 --- a/lib/icinga/checkable-flapping.cpp +++ b/lib/icinga/checkable-flapping.cpp @@ -20,7 +20,6 @@ #include "icinga/checkable.hpp" #include "icinga/icingaapplication.hpp" #include "base/utility.hpp" -#include using namespace icinga; diff --git a/lib/icinga/checkable-notification.cpp b/lib/icinga/checkable-notification.cpp index 0ceae52c3..ac7761652 100644 --- a/lib/icinga/checkable-notification.cpp +++ b/lib/icinga/checkable-notification.cpp @@ -24,7 +24,6 @@ #include "base/exception.hpp" #include "base/context.hpp" #include "base/convert.hpp" -#include using namespace icinga; @@ -37,7 +36,7 @@ boost::signals2::signalResetNotificationNumber(); } @@ -71,7 +70,7 @@ void Checkable::SendNotifications(NotificationType type, const CheckResult::Ptr& Log(LogDebug, "Checkable") << "Checkable '" << GetName() << "' has " << notifications.size() << " notification(s)."; - BOOST_FOREACH(const Notification::Ptr& notification, notifications) { + for (const Notification::Ptr& notification : notifications) { try { if (!notification->IsPaused()) notification->BeginExecuteNotification(type, cr, force, false, author, text); diff --git a/lib/icinga/checkable.cpp b/lib/icinga/checkable.cpp index 9e13c17fd..913011b66 100644 --- a/lib/icinga/checkable.cpp +++ b/lib/icinga/checkable.cpp @@ -24,7 +24,6 @@ #include "base/objectlock.hpp" #include "base/utility.hpp" #include "base/exception.hpp" -#include #include using namespace icinga; diff --git a/lib/icinga/cib.cpp b/lib/icinga/cib.cpp index 38aec3baa..abf8153a5 100644 --- a/lib/icinga/cib.cpp +++ b/lib/icinga/cib.cpp @@ -25,7 +25,6 @@ #include "base/utility.hpp" #include "base/configtype.hpp" #include "base/statsfunction.hpp" -#include using namespace icinga; @@ -82,7 +81,7 @@ CheckableCheckStatistics CIB::CalculateHostCheckStats(void) int count_execution_time = 0; bool checkresult = false; - BOOST_FOREACH(const Host::Ptr& host, ConfigType::GetObjectsByType()) { + for (const Host::Ptr& host : ConfigType::GetObjectsByType()) { ObjectLock olock(host); CheckResult::Ptr cr = host->GetLastCheckResult(); @@ -143,7 +142,7 @@ CheckableCheckStatistics CIB::CalculateServiceCheckStats(void) int count_execution_time = 0; bool checkresult = false; - BOOST_FOREACH(const Service::Ptr& service, ConfigType::GetObjectsByType()) { + for (const Service::Ptr& service : ConfigType::GetObjectsByType()) { ObjectLock olock(service); CheckResult::Ptr cr = service->GetLastCheckResult(); @@ -200,7 +199,7 @@ ServiceStatistics CIB::CalculateServiceStats(void) { ServiceStatistics ss = {}; - BOOST_FOREACH(const Service::Ptr& service, ConfigType::GetObjectsByType()) { + for (const Service::Ptr& service : ConfigType::GetObjectsByType()) { ObjectLock olock(service); CheckResult::Ptr cr = service->GetLastCheckResult(); @@ -234,7 +233,7 @@ HostStatistics CIB::CalculateHostStats(void) { HostStatistics hs = {}; - BOOST_FOREACH(const Host::Ptr& host, ConfigType::GetObjectsByType()) { + for (const Host::Ptr& host : ConfigType::GetObjectsByType()) { ObjectLock olock(host); if (host->IsReachable()) { @@ -269,13 +268,8 @@ std::pair CIB::GetFeatureStats(void) Array::Ptr perfdata = new Array(); String name; - BOOST_FOREACH(tie(name, boost::tuples::ignore), StatsFunctionRegistry::GetInstance()->GetItems()) { - StatsFunction::Ptr func = StatsFunctionRegistry::GetInstance()->GetItem(name); - - if (!func) - BOOST_THROW_EXCEPTION(std::invalid_argument("Function '" + name + "' does not exist.")); - - func->Invoke(status, perfdata); + for (const auto& kv : StatsFunctionRegistry::GetInstance()->GetItems()) { + kv.second->Invoke(status, perfdata); } return std::make_pair(status, perfdata); diff --git a/lib/icinga/clusterevents.cpp b/lib/icinga/clusterevents.cpp index 1898cd844..0128e7a23 100644 --- a/lib/icinga/clusterevents.cpp +++ b/lib/icinga/clusterevents.cpp @@ -138,7 +138,7 @@ Value ClusterEvents::CheckResultAPIHandler(const MessageOrigin::Ptr& origin, con if (vperf) { ObjectLock olock(vperf); - BOOST_FOREACH(const Value& vp, vperf) { + for (const Value& vp : vperf) { Value p; if (vp.IsObjectType()) { @@ -687,10 +687,10 @@ void ClusterEvents::RepositoryTimerHandler(void) Dictionary::Ptr repository = new Dictionary(); - BOOST_FOREACH(const Host::Ptr& host, ConfigType::GetObjectsByType()) { + for (const Host::Ptr& host : ConfigType::GetObjectsByType()) { Array::Ptr services = new Array(); - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { services->Add(service->GetShortName()); } @@ -958,7 +958,7 @@ void ClusterEvents::NotificationSentToAllUsersHandler(const Notification::Ptr& n params->Set("notification", notification->GetName()); Array::Ptr ausers = new Array(); - BOOST_FOREACH(const User::Ptr& user, users) { + for (const User::Ptr& user : users) { ausers->Add(user->GetName()); } params->Set("users", ausers); @@ -1042,7 +1042,7 @@ Value ClusterEvents::NotificationSentToAllUsersAPIHandler(const MessageOrigin::P { ObjectLock olock(ausers); - BOOST_FOREACH(const String& auser, ausers) { + for (const String& auser : ausers) { User::Ptr user = User::GetByName(auser); if (!user) @@ -1059,7 +1059,7 @@ Value ClusterEvents::NotificationSentToAllUsersAPIHandler(const MessageOrigin::P notification->SetNoMoreNotifications(params->Get("no_more_notifications")); Array::Ptr notifiedUsers = new Array(); - BOOST_FOREACH(const User::Ptr& user, users) { + for (const User::Ptr& user : users) { notifiedUsers->Add(user->GetName()); } diff --git a/lib/icinga/command.cpp b/lib/icinga/command.cpp index 20ca2677f..61d9c586d 100644 --- a/lib/icinga/command.cpp +++ b/lib/icinga/command.cpp @@ -22,7 +22,6 @@ #include "icinga/macroprocessor.hpp" #include "base/exception.hpp" #include "base/objectlock.hpp" -#include using namespace icinga; @@ -42,7 +41,7 @@ void Command::Validate(int types, const ValidationUtils& utils) BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("command"), "Attribute 'command' must be an array if the 'arguments' attribute is set.")); ObjectLock olock(arguments); - BOOST_FOREACH(const Dictionary::Pair& kv, arguments) { + for (const Dictionary::Pair& kv : arguments) { const Value& arginfo = kv.second; Value argval; @@ -73,7 +72,7 @@ void Command::Validate(int types, const ValidationUtils& utils) if (env) { ObjectLock olock(env); - BOOST_FOREACH(const Dictionary::Pair& kv, env) { + for (const Dictionary::Pair& kv : env) { const Value& envval = kv.second; if (!envval.IsString() || envval.IsEmpty()) diff --git a/lib/icinga/comment.cpp b/lib/icinga/comment.cpp index 7b9165366..380f29886 100644 --- a/lib/icinga/comment.cpp +++ b/lib/icinga/comment.cpp @@ -24,7 +24,6 @@ #include "base/utility.hpp" #include "base/configtype.hpp" #include "base/timer.hpp" -#include #include #include @@ -187,7 +186,7 @@ String Comment::AddComment(const Checkable::Ptr& checkable, CommentType entryTyp if (!ConfigObjectUtility::CreateObject(Comment::TypeInstance, fullName, config, errors)) { ObjectLock olock(errors); - BOOST_FOREACH(const String& error, errors) { + for (const String& error : errors) { Log(LogCritical, "Comment", error); } @@ -219,7 +218,7 @@ void Comment::RemoveComment(const String& id, const MessageOrigin::Ptr& origin) if (!ConfigObjectUtility::DeleteObject(comment, false, errors)) { ObjectLock olock(errors); - BOOST_FOREACH(const String& error, errors) { + for (const String& error : errors) { Log(LogCritical, "Comment", error); } @@ -243,11 +242,11 @@ void Comment::CommentsExpireTimerHandler(void) { std::vector comments; - BOOST_FOREACH(const Comment::Ptr& comment, ConfigType::GetObjectsByType()) { + for (const Comment::Ptr& comment : ConfigType::GetObjectsByType()) { comments.push_back(comment); } - BOOST_FOREACH(const Comment::Ptr& comment, comments) { + for (const Comment::Ptr& comment : comments) { /* Only remove comment which are activated after daemon start. */ if (comment->IsActive() && comment->IsExpired()) RemoveComment(comment->GetName()); diff --git a/lib/icinga/compatutility.cpp b/lib/icinga/compatutility.cpp index 20c1f6f7a..dc7270571 100644 --- a/lib/icinga/compatutility.cpp +++ b/lib/icinga/compatutility.cpp @@ -27,7 +27,6 @@ #include "base/configtype.hpp" #include "base/objectlock.hpp" #include "base/convert.hpp" -#include #include #include @@ -43,8 +42,7 @@ String CompatUtility::GetCommandLine(const Command::Ptr& command) Array::Ptr args = commandLine; ObjectLock olock(args); - String arg; - BOOST_FOREACH(arg, args) { + for (const String& arg : args) { // This is obviously incorrect for non-trivial cases. result += " \"" + EscapeString(arg) + "\""; } @@ -144,7 +142,7 @@ String CompatUtility::GetCheckableCommandArgs(const Checkable::Ptr& checkable) if (command_vars) { ObjectLock olock(command_vars); - BOOST_FOREACH(const Dictionary::Pair& kv, command_vars) { + for (const Dictionary::Pair& kv : command_vars) { String macro = "$" + kv.first + "$"; // this is too simple if (command_line.Contains(macro)) args->Set(kv.first, kv.second); @@ -156,7 +154,7 @@ String CompatUtility::GetCheckableCommandArgs(const Checkable::Ptr& checkable) if (host_vars) { ObjectLock olock(host_vars); - BOOST_FOREACH(const Dictionary::Pair& kv, host_vars) { + for (const Dictionary::Pair& kv : host_vars) { String macro = "$" + kv.first + "$"; // this is too simple if (command_line.Contains(macro)) args->Set(kv.first, kv.second); @@ -171,7 +169,7 @@ String CompatUtility::GetCheckableCommandArgs(const Checkable::Ptr& checkable) if (service_vars) { ObjectLock olock(service_vars); - BOOST_FOREACH(const Dictionary::Pair& kv, service_vars) { + for (const Dictionary::Pair& kv : service_vars) { String macro = "$" + kv.first + "$"; // this is too simple if (command_line.Contains(macro)) args->Set(kv.first, kv.second); @@ -184,7 +182,7 @@ String CompatUtility::GetCheckableCommandArgs(const Checkable::Ptr& checkable) String arg_string; ObjectLock olock(args); - BOOST_FOREACH(const Dictionary::Pair& kv, args) { + for (const Dictionary::Pair& kv : args) { arg_string += Convert::ToString(kv.first) + "=" + Convert::ToString(kv.second) + "!"; } return arg_string; @@ -354,7 +352,7 @@ int CompatUtility::GetCheckableInCheckPeriod(const Checkable::Ptr& checkable) int CompatUtility::GetCheckableInNotificationPeriod(const Checkable::Ptr& checkable) { - BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) { + for (const Notification::Ptr& notification : checkable->GetNotifications()) { TimePeriod::Ptr timeperiod = notification->GetPeriod(); if (!timeperiod || timeperiod->IsInside(Utility::GetTime())) @@ -394,7 +392,7 @@ int CompatUtility::GetCheckableNotificationsEnabled(const Checkable::Ptr& checka int CompatUtility::GetCheckableNotificationLastNotification(const Checkable::Ptr& checkable) { double last_notification = 0.0; - BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) { + for (const Notification::Ptr& notification : checkable->GetNotifications()) { if (notification->GetLastNotification() > last_notification) last_notification = notification->GetLastNotification(); } @@ -405,7 +403,7 @@ int CompatUtility::GetCheckableNotificationLastNotification(const Checkable::Ptr int CompatUtility::GetCheckableNotificationNextNotification(const Checkable::Ptr& checkable) { double next_notification = 0.0; - BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) { + for (const Notification::Ptr& notification : checkable->GetNotifications()) { if (next_notification == 0 || notification->GetNextNotification() < next_notification) next_notification = notification->GetNextNotification(); } @@ -416,7 +414,7 @@ int CompatUtility::GetCheckableNotificationNextNotification(const Checkable::Ptr int CompatUtility::GetCheckableNotificationNotificationNumber(const Checkable::Ptr& checkable) { int notification_number = 0; - BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) { + for (const Notification::Ptr& notification : checkable->GetNotifications()) { if (notification->GetNotificationNumber() > notification_number) notification_number = notification->GetNotificationNumber(); } @@ -428,7 +426,7 @@ double CompatUtility::GetCheckableNotificationNotificationInterval(const Checkab { double notification_interval = -1; - BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) { + for (const Notification::Ptr& notification : checkable->GetNotifications()) { if (notification_interval == -1 || notification->GetInterval() < notification_interval) notification_interval = notification->GetInterval(); } @@ -449,7 +447,7 @@ String CompatUtility::GetCheckableNotificationNotificationOptions(const Checkabl unsigned long notification_type_filter = 0; unsigned long notification_state_filter = 0; - BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) { + for (const Notification::Ptr& notification : checkable->GetNotifications()) { notification_type_filter |= notification->GetTypeFilter(); notification_state_filter |= notification->GetStateFilter(); } @@ -494,7 +492,7 @@ int CompatUtility::GetCheckableNotificationTypeFilter(const Checkable::Ptr& chec { unsigned long notification_type_filter = 0; - BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) { + for (const Notification::Ptr& notification : checkable->GetNotifications()) { ObjectLock olock(notification); notification_type_filter |= notification->GetTypeFilter(); @@ -507,7 +505,7 @@ int CompatUtility::GetCheckableNotificationStateFilter(const Checkable::Ptr& che { unsigned long notification_state_filter = 0; - BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) { + for (const Notification::Ptr& notification : checkable->GetNotifications()) { ObjectLock olock(notification); notification_state_filter |= notification->GetStateFilter(); @@ -577,14 +575,14 @@ std::set CompatUtility::GetCheckableNotificationUsers(const Checkable std::set allUsers; std::set users; - BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) { + for (const Notification::Ptr& notification : checkable->GetNotifications()) { ObjectLock olock(notification); users = notification->GetUsers(); std::copy(users.begin(), users.end(), std::inserter(allUsers, allUsers.begin())); - BOOST_FOREACH(const UserGroup::Ptr& ug, notification->GetUserGroups()) { + for (const UserGroup::Ptr& ug : notification->GetUserGroups()) { std::set members = ug->GetMembers(); std::copy(members.begin(), members.end(), std::inserter(allUsers, allUsers.begin())); } @@ -597,10 +595,10 @@ std::set CompatUtility::GetCheckableNotificationUserGroups(const { std::set usergroups; /* Service -> Notifications -> UserGroups */ - BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) { + for (const Notification::Ptr& notification : checkable->GetNotifications()) { ObjectLock olock(notification); - BOOST_FOREACH(const UserGroup::Ptr& ug, notification->GetUserGroups()) { + for (const UserGroup::Ptr& ug : notification->GetUserGroups()) { usergroups.insert(ug); } } diff --git a/lib/icinga/customvarobject.cpp b/lib/icinga/customvarobject.cpp index 81b5f53fd..88e79ec83 100644 --- a/lib/icinga/customvarobject.cpp +++ b/lib/icinga/customvarobject.cpp @@ -44,7 +44,7 @@ int icinga::FilterArrayToInt(const Array::Ptr& typeFilters, const std::map using namespace icinga; @@ -127,7 +126,7 @@ bool Dependency::EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyR Array::Ptr arr = vinstances; ObjectLock olock(arr); - BOOST_FOREACH(const Value& instance, arr) { + for (const Value& instance : arr) { String name = rule.GetName(); if (!rule.GetFKVar().IsEmpty()) { @@ -144,7 +143,7 @@ bool Dependency::EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyR Dictionary::Ptr dict = vinstances; - BOOST_FOREACH(const String& key, dict->GetKeys()) { + for (const String& key : dict->GetKeys()) { frame.Locals->Set(rule.GetFKVar(), key); frame.Locals->Set(rule.GetFVVar(), dict->Get(key)); @@ -160,7 +159,7 @@ void Dependency::EvaluateApplyRules(const Host::Ptr& host) { CONTEXT("Evaluating 'apply' rules for host '" + host->GetName() + "'"); - BOOST_FOREACH(ApplyRule& rule, ApplyRule::GetRules("Dependency")) { + for (ApplyRule& rule : ApplyRule::GetRules("Dependency")) { if (rule.GetTargetType() != "Host") continue; @@ -173,7 +172,7 @@ void Dependency::EvaluateApplyRules(const Service::Ptr& service) { CONTEXT("Evaluating 'apply' rules for service '" + service->GetName() + "'"); - BOOST_FOREACH(ApplyRule& rule, ApplyRule::GetRules("Dependency")) { + for (ApplyRule& rule : ApplyRule::GetRules("Dependency")) { if (rule.GetTargetType() != "Service") continue; diff --git a/lib/icinga/dependency.cpp b/lib/icinga/dependency.cpp index 5d3ea9507..ed48615bd 100644 --- a/lib/icinga/dependency.cpp +++ b/lib/icinga/dependency.cpp @@ -22,7 +22,6 @@ #include "icinga/service.hpp" #include "base/logger.hpp" #include "base/exception.hpp" -#include #include #include diff --git a/lib/icinga/downtime.cpp b/lib/icinga/downtime.cpp index c1accacfb..6e7566005 100644 --- a/lib/icinga/downtime.cpp +++ b/lib/icinga/downtime.cpp @@ -25,7 +25,6 @@ #include "base/configtype.hpp" #include "base/utility.hpp" #include "base/timer.hpp" -#include #include #include @@ -255,7 +254,7 @@ String Downtime::AddDowntime(const Checkable::Ptr& checkable, const String& auth if (!ConfigObjectUtility::CreateObject(Downtime::TypeInstance, fullName, config, errors)) { ObjectLock olock(errors); - BOOST_FOREACH(const String& error, errors) { + for (const String& error : errors) { Log(LogCritical, "Downtime", error); } @@ -307,7 +306,7 @@ void Downtime::RemoveDowntime(const String& id, bool cancelled, bool expired, co if (!ConfigObjectUtility::DeleteObject(downtime, false, errors)) { ObjectLock olock(errors); - BOOST_FOREACH(const String& error, errors) { + for (const String& error : errors) { Log(LogCritical, "Downtime", error); } @@ -347,7 +346,7 @@ void Downtime::TriggerDowntime(void) { ObjectLock olock(triggers); - BOOST_FOREACH(const String& triggerName, triggers) { + for (const String& triggerName : triggers) { Downtime::Ptr downtime = Downtime::GetByName(triggerName); if (!downtime) @@ -376,11 +375,11 @@ void Downtime::DowntimesExpireTimerHandler(void) { std::vector downtimes; - BOOST_FOREACH(const Downtime::Ptr& downtime, ConfigType::GetObjectsByType()) { + for (const Downtime::Ptr& downtime : ConfigType::GetObjectsByType()) { downtimes.push_back(downtime); } - BOOST_FOREACH(const Downtime::Ptr& downtime, downtimes) { + for (const Downtime::Ptr& downtime : downtimes) { /* Only remove downtimes which are activated after daemon start. */ if (downtime->IsActive() && (downtime->IsExpired() || !downtime->HasValidConfigOwner())) RemoveDowntime(downtime->GetName(), false, true); diff --git a/lib/icinga/externalcommandprocessor.cpp b/lib/icinga/externalcommandprocessor.cpp index 01bba2840..92d7dd8af 100644 --- a/lib/icinga/externalcommandprocessor.cpp +++ b/lib/icinga/externalcommandprocessor.cpp @@ -38,7 +38,6 @@ #include "base/exception.hpp" #include #include -#include #include using namespace icinga; @@ -545,7 +544,7 @@ void ExternalCommandProcessor::ScheduleForcedHostSvcChecks(double, const std::ve if (!host) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule forced host service checks for non-existent host '" + arguments[0] + "'")); - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { Log(LogNotice, "ExternalCommandProcessor") << "Rescheduling next check for service '" << service->GetName() << "'"; @@ -569,7 +568,7 @@ void ExternalCommandProcessor::ScheduleHostSvcChecks(double, const std::vectorGetServices()) { + for (const Service::Ptr& service : host->GetServices()) { if (planned_check > service->GetNextCheck()) { Log(LogNotice, "ExternalCommandProcessor") << "Ignoring reschedule request for service '" @@ -594,7 +593,7 @@ void ExternalCommandProcessor::EnableHostSvcChecks(double, const std::vectorGetServices()) { + for (const Service::Ptr& service : host->GetServices()) { Log(LogNotice, "ExternalCommandProcessor") << "Enabling active checks for service '" << service->GetName() << "'"; @@ -609,7 +608,7 @@ void ExternalCommandProcessor::DisableHostSvcChecks(double, const std::vectorGetServices()) { + for (const Service::Ptr& service : host->GetServices()) { Log(LogNotice, "ExternalCommandProcessor") << "Disabling active checks for service '" << service->GetName() << "'"; @@ -741,8 +740,8 @@ void ExternalCommandProcessor::EnableHostgroupSvcChecks(double, const std::vecto if (!hg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable hostgroup service checks for non-existent hostgroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { Log(LogNotice, "ExternalCommandProcessor") << "Enabling active checks for service '" << service->GetName() << "'"; @@ -758,8 +757,8 @@ void ExternalCommandProcessor::DisableHostgroupSvcChecks(double, const std::vect if (!hg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable hostgroup service checks for non-existent hostgroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { Log(LogNotice, "ExternalCommandProcessor") << "Disabling active checks for service '" << service->GetName() << "'"; @@ -775,7 +774,7 @@ void ExternalCommandProcessor::EnableServicegroupSvcChecks(double, const std::ve if (!sg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable servicegroup service checks for non-existent servicegroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Log(LogNotice, "ExternalCommandProcessor") << "Enabling active checks for service '" << service->GetName() << "'"; @@ -790,7 +789,7 @@ void ExternalCommandProcessor::DisableServicegroupSvcChecks(double, const std::v if (!sg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable servicegroup service checks for non-existent servicegroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Log(LogNotice, "ExternalCommandProcessor") << "Disabling active checks for service '" << service->GetName() << "'"; @@ -857,7 +856,7 @@ void ExternalCommandProcessor::EnableServicegroupPassiveSvcChecks(double, const if (!sg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable servicegroup passive service checks for non-existent servicegroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Log(LogNotice, "ExternalCommandProcessor") << "Enabling passive checks for service '" << service->GetName() << "'"; @@ -872,7 +871,7 @@ void ExternalCommandProcessor::DisableServicegroupPassiveSvcChecks(double, const if (!sg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable servicegroup passive service checks for non-existent servicegroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Log(LogNotice, "ExternalCommandProcessor") << "Disabling passive checks for service '" << service->GetName() << "'"; @@ -887,8 +886,8 @@ void ExternalCommandProcessor::EnableHostgroupPassiveSvcChecks(double, const std if (!hg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable hostgroup passive service checks for non-existent hostgroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { Log(LogNotice, "ExternalCommandProcessor") << "Enabling passive checks for service '" << service->GetName() << "'"; @@ -904,8 +903,8 @@ void ExternalCommandProcessor::DisableHostgroupPassiveSvcChecks(double, const st if (!hg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable hostgroup passive service checks for non-existent hostgroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { Log(LogNotice, "ExternalCommandProcessor") << "Disabling passive checks for service '" << service->GetName() << "'"; @@ -1035,18 +1034,18 @@ void ExternalCommandProcessor::DelDowntimeByHostName(double, const std::vectorGetDowntimes()) { + for (const Downtime::Ptr& downtime : host->GetDowntimes()) { Log(LogNotice, "ExternalCommandProcessor") << "Removing downtime '" << downtime->GetName() << "'."; Downtime::RemoveDowntime(downtime->GetName(), true); } - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { if (!serviceName.IsEmpty() && serviceName != service->GetName()) continue; - BOOST_FOREACH(const Downtime::Ptr& downtime, service->GetDowntimes()) { + for (const Downtime::Ptr& downtime : service->GetDowntimes()) { if (!startTime.IsEmpty() && downtime->GetStartTime() != Convert::ToDouble(startTime)) continue; @@ -1081,7 +1080,7 @@ void ExternalCommandProcessor::ScheduleHostSvcDowntime(double, const std::vector Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]), Convert::ToBool(is_fixed), triggeredBy, Convert::ToDouble(arguments[5])); - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { Log(LogNotice, "ExternalCommandProcessor") << "Creating downtime for service " << service->GetName(); (void) Downtime::AddDowntime(service, arguments[6], arguments[7], @@ -1103,7 +1102,7 @@ void ExternalCommandProcessor::ScheduleHostgroupHostDowntime(double, const std:: if (triggeredByLegacy != 0) triggeredBy = Downtime::GetDowntimeIDFromLegacyID(triggeredByLegacy); - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const Host::Ptr& host : hg->GetMembers()) { Log(LogNotice, "ExternalCommandProcessor") << "Creating downtime for host " << host->GetName(); @@ -1132,13 +1131,13 @@ void ExternalCommandProcessor::ScheduleHostgroupSvcDowntime(double, const std::v std::set services; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { services.insert(service); } } - BOOST_FOREACH(const Service::Ptr& service, services) { + for (const Service::Ptr& service : services) { Log(LogNotice, "ExternalCommandProcessor") << "Creating downtime for service " << service->GetName(); (void) Downtime::AddDowntime(service, arguments[6], arguments[7], @@ -1166,12 +1165,12 @@ void ExternalCommandProcessor::ScheduleServicegroupHostDowntime(double, const st std::set hosts; - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Host::Ptr host = service->GetHost(); hosts.insert(host); } - BOOST_FOREACH(const Host::Ptr& host, hosts) { + for (const Host::Ptr& host : hosts) { Log(LogNotice, "ExternalCommandProcessor") << "Creating downtime for host " << host->GetName(); (void) Downtime::AddDowntime(host, arguments[6], arguments[7], @@ -1193,7 +1192,7 @@ void ExternalCommandProcessor::ScheduleServicegroupSvcDowntime(double, const std if (triggeredByLegacy != 0) triggeredBy = Downtime::GetDowntimeIDFromLegacyID(triggeredByLegacy); - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Log(LogNotice, "ExternalCommandProcessor") << "Creating downtime for service " << service->GetName(); (void) Downtime::AddDowntime(service, arguments[6], arguments[7], @@ -1324,7 +1323,7 @@ void ExternalCommandProcessor::DelayHostNotification(double, const std::vectorGetName() << "'"; - BOOST_FOREACH(const Notification::Ptr& notification, host->GetNotifications()) { + for (const Notification::Ptr& notification : host->GetNotifications()) { notification->SetNextNotification(Convert::ToDouble(arguments[1])); } } @@ -1339,7 +1338,7 @@ void ExternalCommandProcessor::DelaySvcNotification(double, const std::vectorGetName(); - BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) { + for (const Notification::Ptr& notification : service->GetNotifications()) { notification->SetNextNotification(Convert::ToDouble(arguments[2])); } } @@ -1406,7 +1405,7 @@ void ExternalCommandProcessor::EnableHostSvcNotifications(double, const std::vec Log(LogNotice, "ExternalCommandProcessor") << "Enabling notifications for all services on host '" << arguments[0] << "'"; - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { Log(LogNotice, "ExternalCommandProcessor") << "Enabling notifications for service '" << service->GetName() << "'"; @@ -1424,7 +1423,7 @@ void ExternalCommandProcessor::DisableHostSvcNotifications(double, const std::ve Log(LogNotice, "ExternalCommandProcessor") << "Disabling notifications for all services on host '" << arguments[0] << "'"; - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { Log(LogNotice, "ExternalCommandProcessor") << "Disabling notifications for service '" << service->GetName() << "'"; @@ -1439,7 +1438,7 @@ void ExternalCommandProcessor::DisableHostgroupHostChecks(double, const std::vec if (!hg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable hostgroup host checks for non-existent hostgroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const Host::Ptr& host : hg->GetMembers()) { Log(LogNotice, "ExternalCommandProcessor") << "Disabling active checks for host '" << host->GetName() << "'"; @@ -1454,7 +1453,7 @@ void ExternalCommandProcessor::DisableHostgroupPassiveHostChecks(double, const s if (!hg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable hostgroup passive host checks for non-existent hostgroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const Host::Ptr& host : hg->GetMembers()) { Log(LogNotice, "ExternalCommandProcessor") << "Disabling passive checks for host '" << host->GetName() << "'"; @@ -1469,7 +1468,7 @@ void ExternalCommandProcessor::DisableServicegroupHostChecks(double, const std:: if (!sg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable servicegroup host checks for non-existent servicegroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Host::Ptr host = service->GetHost(); Log(LogNotice, "ExternalCommandProcessor") @@ -1486,7 +1485,7 @@ void ExternalCommandProcessor::DisableServicegroupPassiveHostChecks(double, cons if (!sg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable servicegroup passive host checks for non-existent servicegroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Host::Ptr host = service->GetHost(); Log(LogNotice, "ExternalCommandProcessor") @@ -1503,7 +1502,7 @@ void ExternalCommandProcessor::EnableHostgroupHostChecks(double, const std::vect if (!hg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable hostgroup host checks for non-existent hostgroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const Host::Ptr& host : hg->GetMembers()) { Log(LogNotice, "ExternalCommandProcessor") << "Enabling active checks for host '" << host->GetName() << "'"; @@ -1518,7 +1517,7 @@ void ExternalCommandProcessor::EnableHostgroupPassiveHostChecks(double, const st if (!hg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable hostgroup passive host checks for non-existent hostgroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const Host::Ptr& host : hg->GetMembers()) { Log(LogNotice, "ExternalCommandProcessor") << "Enabling passive checks for host '" << host->GetName() << "'"; @@ -1533,7 +1532,7 @@ void ExternalCommandProcessor::EnableServicegroupHostChecks(double, const std::v if (!sg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable servicegroup host checks for non-existent servicegroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Host::Ptr host = service->GetHost(); Log(LogNotice, "ExternalCommandProcessor") @@ -1550,7 +1549,7 @@ void ExternalCommandProcessor::EnableServicegroupPassiveHostChecks(double, const if (!sg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable servicegroup passive host checks for non-existent servicegroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Host::Ptr host = service->GetHost(); Log(LogNotice, "ExternalCommandProcessor") @@ -2045,7 +2044,7 @@ void ExternalCommandProcessor::EnableHostgroupHostNotifications(double, const st if (!hg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host notifications for non-existent hostgroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const Host::Ptr& host : hg->GetMembers()) { Log(LogNotice, "ExternalCommandProcessor") << "Enabling notifications for host '" << host->GetName() << "'"; @@ -2060,8 +2059,8 @@ void ExternalCommandProcessor::EnableHostgroupSvcNotifications(double, const std if (!hg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable service notifications for non-existent hostgroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { Log(LogNotice, "ExternalCommandProcessor") << "Enabling notifications for service '" << service->GetName() << "'"; @@ -2077,7 +2076,7 @@ void ExternalCommandProcessor::DisableHostgroupHostNotifications(double, const s if (!hg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host notifications for non-existent hostgroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const Host::Ptr& host : hg->GetMembers()) { Log(LogNotice, "ExternalCommandProcessor") << "Disabling notifications for host '" << host->GetName() << "'"; @@ -2092,8 +2091,8 @@ void ExternalCommandProcessor::DisableHostgroupSvcNotifications(double, const st if (!hg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable service notifications for non-existent hostgroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { Log(LogNotice, "ExternalCommandProcessor") << "Disabling notifications for service '" << service->GetName() << "'"; @@ -2109,7 +2108,7 @@ void ExternalCommandProcessor::EnableServicegroupHostNotifications(double, const if (!sg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host notifications for non-existent servicegroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Host::Ptr host = service->GetHost(); Log(LogNotice, "ExternalCommandProcessor") @@ -2126,7 +2125,7 @@ void ExternalCommandProcessor::EnableServicegroupSvcNotifications(double, const if (!sg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable service notifications for non-existent servicegroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Log(LogNotice, "ExternalCommandProcessor") << "Enabling notifications for service '" << service->GetName() << "'"; @@ -2141,7 +2140,7 @@ void ExternalCommandProcessor::DisableServicegroupHostNotifications(double, cons if (!sg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host notifications for non-existent servicegroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Host::Ptr host = service->GetHost(); Log(LogNotice, "ExternalCommandProcessor") @@ -2158,7 +2157,7 @@ void ExternalCommandProcessor::DisableServicegroupSvcNotifications(double, const if (!sg) BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable service notifications for non-existent servicegroup '" + arguments[0] + "'")); - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Log(LogNotice, "ExternalCommandProcessor") << "Disabling notifications for service '" << service->GetName() << "'"; diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp index d9d971659..99dafe8f4 100644 --- a/lib/icinga/host.cpp +++ b/lib/icinga/host.cpp @@ -28,7 +28,6 @@ #include "base/utility.hpp" #include "base/debug.hpp" #include "base/json.hpp" -#include using namespace icinga; @@ -56,7 +55,7 @@ void Host::OnAllConfigLoaded(void) ObjectLock olock(groups); - BOOST_FOREACH(const String& name, groups) { + for (const String& name : groups) { HostGroup::Ptr hg = HostGroup::GetByName(name); if (hg) @@ -89,7 +88,7 @@ void Host::Stop(bool runtimeRemoved) if (groups) { ObjectLock olock(groups); - BOOST_FOREACH(const String& name, groups) { + for (const String& name : groups) { HostGroup::Ptr hg = HostGroup::GetByName(name); if (hg) @@ -107,7 +106,7 @@ std::vector Host::GetServices(void) const std::vector services; services.reserve(m_Services.size()); typedef std::pair ServicePair; - BOOST_FOREACH(const ServicePair& kv, m_Services) { + for (const ServicePair& kv : m_Services) { services.push_back(kv.second); } @@ -274,7 +273,7 @@ bool Host::ResolveMacro(const String& macro, const CheckResult::Ptr&, Value *res else if (macro == "num_services_critical") filter = ServiceCritical; - BOOST_FOREACH(const Service::Ptr& service, GetServices()) { + for (const Service::Ptr& service : GetServices()) { if (filter != -1 && service->GetState() != filter) continue; diff --git a/lib/icinga/hostgroup.cpp b/lib/icinga/hostgroup.cpp index e2201137c..36758850e 100644 --- a/lib/icinga/hostgroup.cpp +++ b/lib/icinga/hostgroup.cpp @@ -26,7 +26,6 @@ #include "base/objectlock.hpp" #include "base/context.hpp" #include "base/workqueue.hpp" -#include using namespace icinga; @@ -66,7 +65,7 @@ void HostGroup::EvaluateObjectRules(const Host::Ptr& host) { CONTEXT("Evaluating group memberships for host '" + host->GetName() + "'"); - BOOST_FOREACH(const ConfigItem::Ptr& group, ConfigItem::GetItems("HostGroup")) + for (const ConfigItem::Ptr& group : ConfigItem::GetItems("HostGroup")) { if (!group->GetFilter()) continue; @@ -110,7 +109,7 @@ bool HostGroup::ResolveGroupMembership(const Host::Ptr& host, bool add, int rsta if (groups && groups->GetLength() > 0) { ObjectLock olock(groups); - BOOST_FOREACH(const String& name, groups) { + for (const String& name : groups) { HostGroup::Ptr group = HostGroup::GetByName(name); if (group && !group->ResolveGroupMembership(host, add, rstack + 1)) diff --git a/lib/icinga/icingaapplication.cpp b/lib/icinga/icingaapplication.cpp index 1b7e99c6d..0be50a0d4 100644 --- a/lib/icinga/icingaapplication.cpp +++ b/lib/icinga/icingaapplication.cpp @@ -66,7 +66,7 @@ void IcingaApplication::StatsFunc(const Dictionary::Ptr& status, const Array::Pt { Dictionary::Ptr nodes = new Dictionary(); - BOOST_FOREACH(const IcingaApplication::Ptr& icingaapplication, ConfigType::GetObjectsByType()) { + for (const IcingaApplication::Ptr& icingaapplication : ConfigType::GetObjectsByType()) { Dictionary::Ptr stats = new Dictionary(); stats->Set("node_name", icingaapplication->GetNodeName()); stats->Set("enable_notifications", icingaapplication->GetEnableNotifications()); diff --git a/lib/icinga/legacytimeperiod.cpp b/lib/icinga/legacytimeperiod.cpp index 3ab43f0c6..c82542a95 100644 --- a/lib/icinga/legacytimeperiod.cpp +++ b/lib/icinga/legacytimeperiod.cpp @@ -27,7 +27,6 @@ #include "base/utility.hpp" #include #include -#include using namespace icinga; @@ -387,7 +386,7 @@ void LegacyTimePeriod::ProcessTimeRanges(const String& timeranges, tm *reference boost::algorithm::split(ranges, timeranges, boost::is_any_of(",")); - BOOST_FOREACH(const String& range, ranges) { + for (const String& range : ranges) { Dictionary::Ptr segment = ProcessTimeRange(range, reference); if (segment->Get("begin") >= segment->Get("end")) @@ -428,7 +427,7 @@ Dictionary::Ptr LegacyTimePeriod::FindNextSegment(const String& daydef, const St double bestBegin; ObjectLock olock(segments); - BOOST_FOREACH(const Dictionary::Ptr& segment, segments) { + for (const Dictionary::Ptr& segment : segments) { double begin = segment->Get("begin"); if (begin < tsref) @@ -472,7 +471,7 @@ Array::Ptr LegacyTimePeriod::ScriptFunc(const TimePeriod::Ptr& tp, double begin, #endif /* I2_DEBUG */ ObjectLock olock(ranges); - BOOST_FOREACH(const Dictionary::Pair& kv, ranges) { + for (const Dictionary::Pair& kv : ranges) { if (!IsInDayDefinition(kv.first, &reference)) { #ifdef I2_DEBUG Log(LogDebug, "LegacyTimePeriod") diff --git a/lib/icinga/macroprocessor.cpp b/lib/icinga/macroprocessor.cpp index de90b055d..fd4e2cf55 100644 --- a/lib/icinga/macroprocessor.cpp +++ b/lib/icinga/macroprocessor.cpp @@ -29,7 +29,6 @@ #include "base/convert.hpp" #include "base/exception.hpp" #include -#include #include #include #include @@ -55,7 +54,7 @@ Value MacroProcessor::ResolveMacros(const Value& str, const ResolverList& resolv ObjectLock olock(arr); - BOOST_FOREACH(const Value& arg, arr) { + for (const Value& arg : arr) { /* Note: don't escape macros here. */ Value value = InternalResolveMacros(arg, resolvers, cr, missingMacro, EscapeCallback(), resolvedMacros, useResolvedMacros, recursionLevel + 1); @@ -73,7 +72,7 @@ Value MacroProcessor::ResolveMacros(const Value& str, const ResolverList& resolv ObjectLock olock(dict); - BOOST_FOREACH(const Dictionary::Pair& kv, dict) { + for (const Dictionary::Pair& kv : dict) { /* Note: don't escape macros here. */ resultDict->Set(kv.first, InternalResolveMacros(kv.second, resolvers, cr, missingMacro, EscapeCallback(), resolvedMacros, useResolvedMacros, recursionLevel + 1)); @@ -105,7 +104,7 @@ bool MacroProcessor::ResolveMacro(const String& macro, const ResolverList& resol tokens.erase(tokens.begin()); } - BOOST_FOREACH(const ResolverSpec& resolver, resolvers) { + for (const ResolverSpec& resolver : resolvers) { if (!objName.IsEmpty() && objName != resolver.first) continue; @@ -131,7 +130,7 @@ bool MacroProcessor::ResolveMacro(const String& macro, const ResolverList& resol Value ref = resolver.second; bool valid = true; - BOOST_FOREACH(const String& token, tokens) { + for (const String& token : tokens) { if (ref.IsObjectType()) { Dictionary::Ptr dict = ref; if (dict->Contains(token)) { @@ -212,7 +211,7 @@ Value MacroProcessor::EvaluateFunction(const Function::Ptr& func, const Resolver { Dictionary::Ptr resolvers_this = new Dictionary(); - BOOST_FOREACH(const ResolverSpec& resolver, resolvers) { + for (const ResolverSpec& resolver : resolvers) { resolvers_this->Set(resolver.first, resolver.second); } @@ -290,7 +289,7 @@ Value MacroProcessor::InternalResolveMacros(const String& str, const ResolverLis Array::Ptr resolved_arr = new Array(); ObjectLock olock(arr); - BOOST_FOREACH(const Value& value, arr) { + for (const Value& value : arr) { if (value.IsScalar()) { resolved_arr->Add(InternalResolveMacros(value, resolvers, cr, missingMacro, EscapeCallback(), Dictionary::Ptr(), @@ -364,7 +363,7 @@ void MacroProcessor::ValidateCustomVars(const ConfigObject::Ptr& object, const D /* string, array, dictionary */ ObjectLock olock(value); - BOOST_FOREACH(const Dictionary::Pair& kv, value) { + for (const Dictionary::Pair& kv : value) { const Value& varval = kv.second; if (varval.IsObjectType()) { @@ -372,7 +371,7 @@ void MacroProcessor::ValidateCustomVars(const ConfigObject::Ptr& object, const D Dictionary::Ptr varval_dict = varval; ObjectLock xlock(varval_dict); - BOOST_FOREACH(const Dictionary::Pair& kv_var, varval_dict) { + for (const Dictionary::Pair& kv_var : varval_dict) { if (!kv_var.second.IsString()) continue; @@ -384,7 +383,7 @@ void MacroProcessor::ValidateCustomVars(const ConfigObject::Ptr& object, const D Array::Ptr varval_arr = varval; ObjectLock ylock (varval_arr); - BOOST_FOREACH(const Value& arrval, varval_arr) { + for (const Value& arrval : varval_arr) { if (!arrval.IsString()) continue; @@ -420,7 +419,7 @@ Value MacroProcessor::EscapeMacroShellArg(const Value& value) Array::Ptr arr = value; ObjectLock olock(arr); - BOOST_FOREACH(const Value& arg, arr) { + for (const Value& arg : arr) { if (result.GetLength() > 0) result += " "; @@ -469,7 +468,7 @@ Value MacroProcessor::ResolveArguments(const Value& command, const Dictionary::P std::vector args; ObjectLock olock(arguments); - BOOST_FOREACH(const Dictionary::Pair& kv, arguments) { + for (const Dictionary::Pair& kv : arguments) { const Value& arginfo = kv.second; CommandArgument arg; @@ -548,7 +547,7 @@ Value MacroProcessor::ResolveArguments(const Value& command, const Dictionary::P std::sort(args.begin(), args.end()); Array::Ptr command_arr = resolvedCommand; - BOOST_FOREACH(const CommandArgument& arg, args) { + for (const CommandArgument& arg : args) { if (arg.AValue.IsObjectType()) { Log(LogWarning, "PluginUtility", "Tried to use dictionary in argument"); @@ -558,7 +557,7 @@ Value MacroProcessor::ResolveArguments(const Value& command, const Dictionary::P Array::Ptr arr = static_cast(arg.AValue); ObjectLock olock(arr); - BOOST_FOREACH(const Value& value, arr) { + for (const Value& value : arr) { bool add_key; if (first) { diff --git a/lib/icinga/notification-apply.cpp b/lib/icinga/notification-apply.cpp index a64e2554b..e7940a1a3 100644 --- a/lib/icinga/notification-apply.cpp +++ b/lib/icinga/notification-apply.cpp @@ -27,7 +27,6 @@ #include "base/context.hpp" #include "base/workqueue.hpp" #include "base/exception.hpp" -#include using namespace icinga; @@ -126,7 +125,7 @@ bool Notification::EvaluateApplyRule(const Checkable::Ptr& checkable, const Appl Array::Ptr arr = vinstances; ObjectLock olock(arr); - BOOST_FOREACH(const Value& instance, arr) { + for (const Value& instance : arr) { String name = rule.GetName(); if (!rule.GetFKVar().IsEmpty()) { @@ -143,7 +142,7 @@ bool Notification::EvaluateApplyRule(const Checkable::Ptr& checkable, const Appl Dictionary::Ptr dict = vinstances; - BOOST_FOREACH(const String& key, dict->GetKeys()) { + for (const String& key : dict->GetKeys()) { frame.Locals->Set(rule.GetFKVar(), key); frame.Locals->Set(rule.GetFVVar(), dict->Get(key)); @@ -159,7 +158,7 @@ void Notification::EvaluateApplyRules(const Host::Ptr& host) { CONTEXT("Evaluating 'apply' rules for host '" + host->GetName() + "'"); - BOOST_FOREACH(ApplyRule& rule, ApplyRule::GetRules("Notification")) + for (ApplyRule& rule : ApplyRule::GetRules("Notification")) { if (rule.GetTargetType() != "Host") continue; @@ -173,7 +172,7 @@ void Notification::EvaluateApplyRules(const Service::Ptr& service) { CONTEXT("Evaluating 'apply' rules for service '" + service->GetName() + "'"); - BOOST_FOREACH(ApplyRule& rule, ApplyRule::GetRules("Notification")) { + for (ApplyRule& rule : ApplyRule::GetRules("Notification")) { if (rule.GetTargetType() != "Service") continue; diff --git a/lib/icinga/notification.cpp b/lib/icinga/notification.cpp index 52f7dea13..c15bd2f5e 100644 --- a/lib/icinga/notification.cpp +++ b/lib/icinga/notification.cpp @@ -29,7 +29,6 @@ #include "base/exception.hpp" #include "base/initialize.hpp" #include "base/scriptglobal.hpp" -#include #include #include @@ -185,7 +184,7 @@ std::set Notification::GetUsers(void) const if (users) { ObjectLock olock(users); - BOOST_FOREACH(const String& name, users) { + for (const String& name : users) { User::Ptr user = User::GetByName(name); if (!user) @@ -207,7 +206,7 @@ std::set Notification::GetUserGroups(void) const if (groups) { ObjectLock olock(groups); - BOOST_FOREACH(const String& name, groups) { + for (const String& name : groups) { UserGroup::Ptr ug = UserGroup::GetByName(name); if (!ug) @@ -381,7 +380,7 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe std::set users = GetUsers(); std::copy(users.begin(), users.end(), std::inserter(allUsers, allUsers.begin())); - BOOST_FOREACH(const UserGroup::Ptr& ug, GetUserGroups()) { + for (const UserGroup::Ptr& ug : GetUserGroups()) { std::set members = ug->GetMembers(); std::copy(members.begin(), members.end(), std::inserter(allUsers, allUsers.begin())); } @@ -389,7 +388,7 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe std::set allNotifiedUsers; Array::Ptr notifiedUsers = GetNotifiedUsers(); - BOOST_FOREACH(const User::Ptr& user, allUsers) { + for (const User::Ptr& user : allUsers) { String userName = user->GetName(); if (!user->GetEnableNotifications()) { @@ -566,7 +565,7 @@ String Notification::NotificationFilterToString(int filter, const std::map sFilters; typedef std::pair kv_pair; - BOOST_FOREACH(const kv_pair& kv, filterMap) { + for (const kv_pair& kv : filterMap) { if (filter & kv.second) sFilters.push_back(kv.first); } diff --git a/lib/icinga/pluginutility.cpp b/lib/icinga/pluginutility.cpp index bdc4a74bb..983edb207 100644 --- a/lib/icinga/pluginutility.cpp +++ b/lib/icinga/pluginutility.cpp @@ -29,7 +29,6 @@ #include #include #include -#include using namespace icinga; @@ -70,7 +69,7 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab if (env) { ObjectLock olock(env); - BOOST_FOREACH(const Dictionary::Pair& kv, env) { + for (const Dictionary::Pair& kv : env) { String name = kv.second; Value value = MacroProcessor::ResolveMacros(name, macroResolvers, cr, @@ -119,7 +118,7 @@ std::pair PluginUtility::ParseCheckOutput(const String& output) std::vector lines; boost::algorithm::split(lines, output, boost::is_any_of("\r\n")); - BOOST_FOREACH (const String& line, lines) { + for (const String& line : lines) { size_t delim = line.FindFirstOf("|"); if (!text.IsEmpty()) @@ -202,7 +201,7 @@ String PluginUtility::FormatPerfdata(const Array::Ptr& perfdata) ObjectLock olock(perfdata); bool first = true; - BOOST_FOREACH(const Value& pdv, perfdata) { + for (const Value& pdv : perfdata) { if (!first) result << " "; else diff --git a/lib/icinga/scheduleddowntime-apply.cpp b/lib/icinga/scheduleddowntime-apply.cpp index c61e9dc51..e05777785 100644 --- a/lib/icinga/scheduleddowntime-apply.cpp +++ b/lib/icinga/scheduleddowntime-apply.cpp @@ -26,7 +26,6 @@ #include "base/logger.hpp" #include "base/context.hpp" #include "base/exception.hpp" -#include using namespace icinga; @@ -125,7 +124,7 @@ bool ScheduledDowntime::EvaluateApplyRule(const Checkable::Ptr& checkable, const Array::Ptr arr = vinstances; ObjectLock olock(arr); - BOOST_FOREACH(const Value& instance, arr) { + for (const Value& instance : arr) { String name = rule.GetName(); if (!rule.GetFKVar().IsEmpty()) { @@ -142,7 +141,7 @@ bool ScheduledDowntime::EvaluateApplyRule(const Checkable::Ptr& checkable, const Dictionary::Ptr dict = vinstances; - BOOST_FOREACH(const String& key, dict->GetKeys()) { + for (const String& key : dict->GetKeys()) { frame.Locals->Set(rule.GetFKVar(), key); frame.Locals->Set(rule.GetFVVar(), dict->Get(key)); @@ -158,7 +157,7 @@ void ScheduledDowntime::EvaluateApplyRules(const Host::Ptr& host) { CONTEXT("Evaluating 'apply' rules for host '" + host->GetName() + "'"); - BOOST_FOREACH(ApplyRule& rule, ApplyRule::GetRules("ScheduledDowntime")) { + for (ApplyRule& rule : ApplyRule::GetRules("ScheduledDowntime")) { if (rule.GetTargetType() != "Host") continue; @@ -171,7 +170,7 @@ void ScheduledDowntime::EvaluateApplyRules(const Service::Ptr& service) { CONTEXT("Evaluating 'apply' rules for service '" + service->GetName() + "'"); - BOOST_FOREACH(ApplyRule& rule, ApplyRule::GetRules("ScheduledDowntime")) { + for (ApplyRule& rule : ApplyRule::GetRules("ScheduledDowntime")) { if (rule.GetTargetType() != "Service") continue; diff --git a/lib/icinga/scheduleddowntime.cpp b/lib/icinga/scheduleddowntime.cpp index 4c03f45c9..39df705a9 100644 --- a/lib/icinga/scheduleddowntime.cpp +++ b/lib/icinga/scheduleddowntime.cpp @@ -30,7 +30,6 @@ #include "base/convert.hpp" #include "base/logger.hpp" #include "base/exception.hpp" -#include #include #include @@ -105,7 +104,7 @@ void ScheduledDowntime::Start(bool runtimeCreated) void ScheduledDowntime::TimerProc(void) { - BOOST_FOREACH(const ScheduledDowntime::Ptr& sd, ConfigType::GetObjectsByType()) { + for (const ScheduledDowntime::Ptr& sd : ConfigType::GetObjectsByType()) { if (sd->IsActive()) sd->CreateNextDowntime(); } @@ -141,7 +140,7 @@ std::pair ScheduledDowntime::FindNextSegment(void) double now = Utility::GetTime(); ObjectLock olock(ranges); - BOOST_FOREACH(const Dictionary::Pair& kv, ranges) { + for (const Dictionary::Pair& kv : ranges) { Log(LogDebug, "ScheduledDowntime") << "Evaluating segment: " << kv.first << ": " << kv.second << " at "; @@ -172,7 +171,7 @@ std::pair ScheduledDowntime::FindNextSegment(void) void ScheduledDowntime::CreateNextDowntime(void) { - BOOST_FOREACH(const Downtime::Ptr& downtime, GetCheckable()->GetDowntimes()) { + for (const Downtime::Ptr& downtime : GetCheckable()->GetDowntimes()) { if (downtime->GetScheduledBy() != GetName() || downtime->GetStartTime() < Utility::GetTime()) continue; @@ -209,7 +208,7 @@ void ScheduledDowntime::ValidateRanges(const Dictionary::Ptr& value, const Valid Array::Ptr segments = new Array(); ObjectLock olock(value); - BOOST_FOREACH(const Dictionary::Pair& kv, value) { + for (const Dictionary::Pair& kv : value) { try { tm begin_tm, end_tm; int stride; diff --git a/lib/icinga/service-apply.cpp b/lib/icinga/service-apply.cpp index 6fa495664..ba89d71e9 100644 --- a/lib/icinga/service-apply.cpp +++ b/lib/icinga/service-apply.cpp @@ -26,7 +26,6 @@ #include "base/context.hpp" #include "base/workqueue.hpp" #include "base/exception.hpp" -#include using namespace icinga; @@ -113,7 +112,7 @@ bool Service::EvaluateApplyRule(const Host::Ptr& host, const ApplyRule& rule) Array::Ptr arr = vinstances; ObjectLock olock(arr); - BOOST_FOREACH(const Value& instance, arr) { + for (const Value& instance : arr) { String name = rule.GetName(); if (!rule.GetFKVar().IsEmpty()) { @@ -130,7 +129,7 @@ bool Service::EvaluateApplyRule(const Host::Ptr& host, const ApplyRule& rule) Dictionary::Ptr dict = vinstances; - BOOST_FOREACH(const String& key, dict->GetKeys()) { + for (const String& key : dict->GetKeys()) { frame.Locals->Set(rule.GetFKVar(), key); frame.Locals->Set(rule.GetFVVar(), dict->Get(key)); @@ -144,7 +143,7 @@ bool Service::EvaluateApplyRule(const Host::Ptr& host, const ApplyRule& rule) void Service::EvaluateApplyRules(const Host::Ptr& host) { - BOOST_FOREACH(ApplyRule& rule, ApplyRule::GetRules("Service")) { + for (ApplyRule& rule : ApplyRule::GetRules("Service")) { CONTEXT("Evaluating 'apply' rules for host '" + host->GetName() + "'"); if (EvaluateApplyRule(host, rule)) diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index dfd94c8f7..3c76b1416 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -25,7 +25,6 @@ #include "base/objectlock.hpp" #include "base/convert.hpp" #include "base/utility.hpp" -#include #include #include #include @@ -86,7 +85,7 @@ void Service::OnAllConfigLoaded(void) ObjectLock olock(groups); - BOOST_FOREACH(const String& name, groups) { + for (const String& name : groups) { ServiceGroup::Ptr sg = ServiceGroup::GetByName(name); if (sg) diff --git a/lib/icinga/servicegroup.cpp b/lib/icinga/servicegroup.cpp index 314ca9ddd..ac75565e8 100644 --- a/lib/icinga/servicegroup.cpp +++ b/lib/icinga/servicegroup.cpp @@ -26,7 +26,6 @@ #include "base/logger.hpp" #include "base/context.hpp" #include "base/workqueue.hpp" -#include using namespace icinga; @@ -69,7 +68,7 @@ void ServiceGroup::EvaluateObjectRules(const Service::Ptr& service) { CONTEXT("Evaluating group membership for service '" + service->GetName() + "'"); - BOOST_FOREACH(const ConfigItem::Ptr& group, ConfigItem::GetItems("ServiceGroup")) + for (const ConfigItem::Ptr& group : ConfigItem::GetItems("ServiceGroup")) { if (!group->GetFilter()) continue; @@ -113,7 +112,7 @@ bool ServiceGroup::ResolveGroupMembership(const Service::Ptr& service, bool add, if (groups && groups->GetLength() > 0) { ObjectLock olock(groups); - BOOST_FOREACH(const String& name, groups) { + for (const String& name : groups) { ServiceGroup::Ptr group = ServiceGroup::GetByName(name); if (group && !group->ResolveGroupMembership(service, add, rstack + 1)) diff --git a/lib/icinga/timeperiod.cpp b/lib/icinga/timeperiod.cpp index ccb938557..b44ac10ac 100644 --- a/lib/icinga/timeperiod.cpp +++ b/lib/icinga/timeperiod.cpp @@ -26,7 +26,6 @@ #include "base/logger.hpp" #include "base/timer.hpp" #include "base/utility.hpp" -#include using namespace icinga; @@ -75,7 +74,7 @@ void TimePeriod::AddSegment(double begin, double end) if (segments) { /* Try to merge the new segment into an existing segment. */ ObjectLock dlock(segments); - BOOST_FOREACH(const Dictionary::Ptr& segment, segments) { + for (const Dictionary::Ptr& segment : segments) { if (segment->Get("begin") <= begin && segment->Get("end") >= end) return; /* New segment is fully contained in this segment. */ @@ -139,7 +138,7 @@ void TimePeriod::RemoveSegment(double begin, double end) /* Try to split or adjust an existing segment. */ ObjectLock dlock(segments); - BOOST_FOREACH(const Dictionary::Ptr& segment, segments) { + for (const Dictionary::Ptr& segment : segments) { /* Fully contained in the specified range? */ if (segment->Get("begin") >= begin && segment->Get("end") <= end) continue; @@ -210,7 +209,7 @@ void TimePeriod::PurgeSegments(double end) /* Remove old segments. */ ObjectLock dlock(segments); - BOOST_FOREACH(const Dictionary::Ptr& segment, segments) { + for (const Dictionary::Ptr& segment : segments) { if (segment->Get("end") >= end) newSegments->Add(segment); } @@ -229,7 +228,7 @@ void TimePeriod::Merge(const TimePeriod::Ptr& timeperiod, bool include) if (segments) { ObjectLock dlock(segments); ObjectLock ilock(this); - BOOST_FOREACH(const Dictionary::Ptr& segment, segments) { + for (const Dictionary::Ptr& segment : segments) { include ? AddSegment(segment) : RemoveSegment(segment); } } @@ -258,7 +257,7 @@ void TimePeriod::UpdateRegion(double begin, double end, bool clearExisting) if (segments) { ObjectLock dlock(segments); - BOOST_FOREACH(const Dictionary::Ptr& segment, segments) { + for (const Dictionary::Ptr& segment : segments) { AddSegment(segment); } } @@ -271,7 +270,7 @@ void TimePeriod::UpdateRegion(double begin, double end, bool clearExisting) if (timeranges) { ObjectLock olock(timeranges); - BOOST_FOREACH(const String& name, timeranges) { + for (const String& name : timeranges) { const TimePeriod::Ptr timeperiod = TimePeriod::GetByName(name); if (timeperiod) @@ -284,7 +283,7 @@ void TimePeriod::UpdateRegion(double begin, double end, bool clearExisting) if (timeranges) { ObjectLock olock(timeranges); - BOOST_FOREACH(const String& name, timeranges) { + for (const String& name : timeranges) { const TimePeriod::Ptr timeperiod = TimePeriod::GetByName(name); if (timeperiod) @@ -309,7 +308,7 @@ bool TimePeriod::IsInside(double ts) const if (segments) { ObjectLock dlock(segments); - BOOST_FOREACH(const Dictionary::Ptr& segment, segments) { + for (const Dictionary::Ptr& segment : segments) { if (ts > segment->Get("begin") && ts < segment->Get("end")) return true; } @@ -328,7 +327,7 @@ double TimePeriod::FindNextTransition(double begin) if (segments) { ObjectLock dlock(segments); - BOOST_FOREACH(const Dictionary::Ptr& segment, segments) { + for (const Dictionary::Ptr& segment : segments) { if (segment->Get("begin") > begin && (segment->Get("begin") < closestTransition || closestTransition == -1)) closestTransition = segment->Get("begin"); @@ -344,7 +343,7 @@ void TimePeriod::UpdateTimerHandler(void) { double now = Utility::GetTime(); - BOOST_FOREACH(const TimePeriod::Ptr& tp, ConfigType::GetObjectsByType()) { + for (const TimePeriod::Ptr& tp : ConfigType::GetObjectsByType()) { if (!tp->IsActive()) continue; @@ -377,7 +376,7 @@ void TimePeriod::Dump(void) if (segments) { ObjectLock dlock(segments); - BOOST_FOREACH(const Dictionary::Ptr& segment, segments) { + for (const Dictionary::Ptr& segment : segments) { Log(LogDebug, "TimePeriod") << "Segment: " << Utility::FormatDateTime("%c", segment->Get("begin")) << " <-> " << Utility::FormatDateTime("%c", segment->Get("end")); @@ -398,7 +397,7 @@ void TimePeriod::ValidateRanges(const Dictionary::Ptr& value, const ValidationUt Array::Ptr segments = new Array(); ObjectLock olock(value); - BOOST_FOREACH(const Dictionary::Pair& kv, value) { + for (const Dictionary::Pair& kv : value) { try { tm begin_tm, end_tm; int stride; diff --git a/lib/icinga/user.cpp b/lib/icinga/user.cpp index e99513531..948af2500 100644 --- a/lib/icinga/user.cpp +++ b/lib/icinga/user.cpp @@ -24,7 +24,6 @@ #include "icinga/usergroup.hpp" #include "base/objectlock.hpp" #include "base/exception.hpp" -#include using namespace icinga; @@ -51,7 +50,7 @@ void User::OnAllConfigLoaded(void) ObjectLock olock(groups); - BOOST_FOREACH(const String& name, groups) { + for (const String& name : groups) { UserGroup::Ptr ug = UserGroup::GetByName(name); if (ug) @@ -69,7 +68,7 @@ void User::Stop(bool runtimeRemoved) if (groups) { ObjectLock olock(groups); - BOOST_FOREACH(const String& name, groups) { + for (const String& name : groups) { UserGroup::Ptr ug = UserGroup::GetByName(name); if (ug) diff --git a/lib/icinga/usergroup.cpp b/lib/icinga/usergroup.cpp index 0af6e9d79..f48a19b04 100644 --- a/lib/icinga/usergroup.cpp +++ b/lib/icinga/usergroup.cpp @@ -26,7 +26,6 @@ #include "base/logger.hpp" #include "base/context.hpp" #include "base/workqueue.hpp" -#include using namespace icinga; @@ -66,7 +65,7 @@ void UserGroup::EvaluateObjectRules(const User::Ptr& user) { CONTEXT("Evaluating group membership for user '" + user->GetName() + "'"); - BOOST_FOREACH(const ConfigItem::Ptr& group, ConfigItem::GetItems("UserGroup")) + for (const ConfigItem::Ptr& group : ConfigItem::GetItems("UserGroup")) { if (!group->GetFilter()) continue; @@ -110,7 +109,7 @@ bool UserGroup::ResolveGroupMembership(const User::Ptr& user, bool add, int rsta if (groups && groups->GetLength() > 0) { ObjectLock olock(groups); - BOOST_FOREACH(const String& name, groups) { + for (const String& name : groups) { UserGroup::Ptr group = UserGroup::GetByName(name); if (group && !group->ResolveGroupMembership(user, add, rstack + 1)) diff --git a/lib/livestatus/andfilter.cpp b/lib/livestatus/andfilter.cpp index 8a47657ba..7a2ed90ec 100644 --- a/lib/livestatus/andfilter.cpp +++ b/lib/livestatus/andfilter.cpp @@ -18,7 +18,6 @@ ******************************************************************************/ #include "livestatus/andfilter.hpp" -#include using namespace icinga; @@ -27,7 +26,7 @@ AndFilter::AndFilter(void) bool AndFilter::Apply(const Table::Ptr& table, const Value& row) { - BOOST_FOREACH(const Filter::Ptr& filter, m_Filters) { + for (const Filter::Ptr& filter : m_Filters) { if (!filter->Apply(table, row)) return false; } diff --git a/lib/livestatus/attributefilter.cpp b/lib/livestatus/attributefilter.cpp index 95f08138f..e82552027 100644 --- a/lib/livestatus/attributefilter.cpp +++ b/lib/livestatus/attributefilter.cpp @@ -22,7 +22,6 @@ #include "base/array.hpp" #include "base/objectlock.hpp" #include "base/logger.hpp" -#include #include #include @@ -45,7 +44,7 @@ bool AttributeFilter::Apply(const Table::Ptr& table, const Value& row) bool negate = (m_Operator == "<"); ObjectLock olock(array); - BOOST_FOREACH(const String& item, array) { + for (const String& item : array) { if (item == m_Operand) return !negate; /* Item found in list. */ } diff --git a/lib/livestatus/commandstable.cpp b/lib/livestatus/commandstable.cpp index e64f18a9f..fc1a1fb95 100644 --- a/lib/livestatus/commandstable.cpp +++ b/lib/livestatus/commandstable.cpp @@ -26,7 +26,6 @@ #include "base/configtype.hpp" #include "base/objectlock.hpp" #include "base/convert.hpp" -#include #include using namespace icinga; @@ -60,17 +59,17 @@ String CommandsTable::GetPrefix(void) const void CommandsTable::FetchRows(const AddRowFunction& addRowFn) { - BOOST_FOREACH(const ConfigObject::Ptr& object, ConfigType::GetObjectsByType()) { + for (const ConfigObject::Ptr& object : ConfigType::GetObjectsByType()) { if (!addRowFn(object, LivestatusGroupByNone, Empty)) return; } - BOOST_FOREACH(const ConfigObject::Ptr& object, ConfigType::GetObjectsByType()) { + for (const ConfigObject::Ptr& object : ConfigType::GetObjectsByType()) { if (!addRowFn(object, LivestatusGroupByNone, Empty)) return; } - BOOST_FOREACH(const ConfigObject::Ptr& object, ConfigType::GetObjectsByType()) { + for (const ConfigObject::Ptr& object : ConfigType::GetObjectsByType()) { if (!addRowFn(object, LivestatusGroupByNone, Empty)) return; } @@ -112,12 +111,11 @@ Value CommandsTable::CustomVariableNamesAccessor(const Value& row) Array::Ptr cv = new Array(); - String key; - Value value; - - ObjectLock xlock(vars); - BOOST_FOREACH(tie(key, value), vars) { - cv->Add(key); + { + ObjectLock xlock(vars); + for (const auto& kv : vars) { + cv->Add(kv.first); + } } return cv; @@ -142,12 +140,11 @@ Value CommandsTable::CustomVariableValuesAccessor(const Value& row) Array::Ptr cv = new Array(); - String key; - Value value; - - ObjectLock xlock(vars); - BOOST_FOREACH(tie(key, value), vars) { - cv->Add(value); + { + ObjectLock xlock(vars); + for (const auto& kv : vars) { + cv->Add(kv.second); + } } return cv; @@ -172,15 +169,14 @@ Value CommandsTable::CustomVariablesAccessor(const Value& row) Array::Ptr cv = new Array(); - String key; - Value value; - - ObjectLock xlock(vars); - BOOST_FOREACH(tie(key, value), vars) { - Array::Ptr key_val = new Array(); - key_val->Add(key); - key_val->Add(value); - cv->Add(key_val); + { + ObjectLock xlock(vars); + for (const auto& kv : vars) { + Array::Ptr key_val = new Array(); + key_val->Add(kv.first); + key_val->Add(kv.second); + cv->Add(key_val); + } } return cv; diff --git a/lib/livestatus/commentstable.cpp b/lib/livestatus/commentstable.cpp index 2ead3971e..1f979d17c 100644 --- a/lib/livestatus/commentstable.cpp +++ b/lib/livestatus/commentstable.cpp @@ -24,7 +24,6 @@ #include "base/configtype.hpp" #include "base/objectlock.hpp" #include -#include using namespace icinga; @@ -65,7 +64,7 @@ String CommentsTable::GetPrefix(void) const void CommentsTable::FetchRows(const AddRowFunction& addRowFn) { - BOOST_FOREACH(const Comment::Ptr& comment, ConfigType::GetObjectsByType()) { + for (const Comment::Ptr& comment : ConfigType::GetObjectsByType()) { if (!addRowFn(comment, LivestatusGroupByNone, Empty)) return; } diff --git a/lib/livestatus/contactgroupstable.cpp b/lib/livestatus/contactgroupstable.cpp index 0dfd3cf9f..5db67cad3 100644 --- a/lib/livestatus/contactgroupstable.cpp +++ b/lib/livestatus/contactgroupstable.cpp @@ -20,7 +20,6 @@ #include "livestatus/contactgroupstable.hpp" #include "icinga/usergroup.hpp" #include "base/configtype.hpp" -#include using namespace icinga; @@ -49,7 +48,7 @@ String ContactGroupsTable::GetPrefix(void) const void ContactGroupsTable::FetchRows(const AddRowFunction& addRowFn) { - BOOST_FOREACH(const UserGroup::Ptr& ug, ConfigType::GetObjectsByType()) { + for (const UserGroup::Ptr& ug : ConfigType::GetObjectsByType()) { if (!addRowFn(ug, LivestatusGroupByNone, Empty)) return; } @@ -84,7 +83,7 @@ Value ContactGroupsTable::MembersAccessor(const Value& row) Array::Ptr members = new Array(); - BOOST_FOREACH(const User::Ptr& user, user_group->GetMembers()) { + for (const User::Ptr& user : user_group->GetMembers()) { members->Add(user->GetName()); } diff --git a/lib/livestatus/contactstable.cpp b/lib/livestatus/contactstable.cpp index c4542ffda..173cacd9d 100644 --- a/lib/livestatus/contactstable.cpp +++ b/lib/livestatus/contactstable.cpp @@ -25,7 +25,6 @@ #include "base/objectlock.hpp" #include "base/json.hpp" #include "base/utility.hpp" -#include #include using namespace icinga; @@ -70,7 +69,7 @@ String ContactsTable::GetPrefix(void) const void ContactsTable::FetchRows(const AddRowFunction& addRowFn) { - BOOST_FOREACH(const User::Ptr& user, ConfigType::GetObjectsByType()) { + for (const User::Ptr& user : ConfigType::GetObjectsByType()) { if (!addRowFn(user, LivestatusGroupByNone, Empty)) return; } @@ -217,7 +216,7 @@ Value ContactsTable::CustomVariableNamesAccessor(const Value& row) Array::Ptr cv = new Array(); ObjectLock olock(vars); - BOOST_FOREACH(const Dictionary::Pair& kv, vars) { + for (const Dictionary::Pair& kv : vars) { cv->Add(kv.first); } @@ -244,7 +243,7 @@ Value ContactsTable::CustomVariableValuesAccessor(const Value& row) Array::Ptr cv = new Array(); ObjectLock olock(vars); - BOOST_FOREACH(const Dictionary::Pair& kv, vars) { + for (const Dictionary::Pair& kv : vars) { if (kv.second.IsObjectType() || kv.second.IsObjectType()) cv->Add(JsonEncode(kv.second)); else @@ -274,7 +273,7 @@ Value ContactsTable::CustomVariablesAccessor(const Value& row) Array::Ptr cv = new Array(); ObjectLock olock(vars); - BOOST_FOREACH(const Dictionary::Pair& kv, vars) { + for (const Dictionary::Pair& kv : vars) { Array::Ptr key_val = new Array(); key_val->Add(kv.first); @@ -309,7 +308,7 @@ Value ContactsTable::CVIsJsonAccessor(const Value& row) bool cv_is_json = false; ObjectLock olock(vars); - BOOST_FOREACH(const Dictionary::Pair& kv, vars) { + for (const Dictionary::Pair& kv : vars) { if (kv.second.IsObjectType() || kv.second.IsObjectType()) cv_is_json = true; } diff --git a/lib/livestatus/downtimestable.cpp b/lib/livestatus/downtimestable.cpp index db02a9e4e..d8f89d02d 100644 --- a/lib/livestatus/downtimestable.cpp +++ b/lib/livestatus/downtimestable.cpp @@ -24,7 +24,6 @@ #include "base/configtype.hpp" #include "base/objectlock.hpp" #include -#include using namespace icinga; @@ -65,7 +64,7 @@ String DowntimesTable::GetPrefix(void) const void DowntimesTable::FetchRows(const AddRowFunction& addRowFn) { - BOOST_FOREACH(const Downtime::Ptr& downtime, ConfigType::GetObjectsByType()) { + for (const Downtime::Ptr& downtime : ConfigType::GetObjectsByType()) { if (!addRowFn(downtime, LivestatusGroupByNone, Empty)) return; } diff --git a/lib/livestatus/endpointstable.cpp b/lib/livestatus/endpointstable.cpp index fa9062f27..2447de927 100644 --- a/lib/livestatus/endpointstable.cpp +++ b/lib/livestatus/endpointstable.cpp @@ -28,7 +28,6 @@ #include "base/convert.hpp" #include "base/utility.hpp" #include -#include #include #include #include @@ -62,7 +61,7 @@ String EndpointsTable::GetPrefix(void) const void EndpointsTable::FetchRows(const AddRowFunction& addRowFn) { - BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType()) { + for (const Endpoint::Ptr& endpoint : ConfigType::GetObjectsByType()) { if (!addRowFn(endpoint, LivestatusGroupByNone, Empty)) return; } diff --git a/lib/livestatus/hostgroupstable.cpp b/lib/livestatus/hostgroupstable.cpp index b995ca126..5a4beff8f 100644 --- a/lib/livestatus/hostgroupstable.cpp +++ b/lib/livestatus/hostgroupstable.cpp @@ -22,7 +22,6 @@ #include "icinga/host.hpp" #include "icinga/service.hpp" #include "base/configtype.hpp" -#include using namespace icinga; @@ -73,7 +72,7 @@ String HostGroupsTable::GetPrefix(void) const void HostGroupsTable::FetchRows(const AddRowFunction& addRowFn) { - BOOST_FOREACH(const HostGroup::Ptr& hg, ConfigType::GetObjectsByType()) { + for (const HostGroup::Ptr& hg : ConfigType::GetObjectsByType()) { if (!addRowFn(hg, LivestatusGroupByNone, Empty)) return; } @@ -138,7 +137,7 @@ Value HostGroupsTable::MembersAccessor(const Value& row) Array::Ptr members = new Array(); - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const Host::Ptr& host : hg->GetMembers()) { members->Add(host->GetName()); } @@ -154,7 +153,7 @@ Value HostGroupsTable::MembersWithStateAccessor(const Value& row) Array::Ptr members = new Array(); - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const Host::Ptr& host : hg->GetMembers()) { Array::Ptr member_state = new Array(); member_state->Add(host->GetName()); member_state->Add(host->GetState()); @@ -173,7 +172,7 @@ Value HostGroupsTable::WorstHostStateAccessor(const Value& row) int worst_host = HostUp; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const Host::Ptr& host : hg->GetMembers()) { if (host->GetState() > worst_host) worst_host = host->GetState(); } @@ -200,7 +199,7 @@ Value HostGroupsTable::NumHostsPendingAccessor(const Value& row) int num_hosts = 0; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const Host::Ptr& host : hg->GetMembers()) { /* no checkresult */ if (!host->GetLastCheckResult()) num_hosts++; @@ -218,7 +217,7 @@ Value HostGroupsTable::NumHostsUpAccessor(const Value& row) int num_hosts = 0; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const Host::Ptr& host : hg->GetMembers()) { if (host->GetState() == HostUp) num_hosts++; } @@ -235,7 +234,7 @@ Value HostGroupsTable::NumHostsDownAccessor(const Value& row) int num_hosts = 0; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const Host::Ptr& host : hg->GetMembers()) { if (host->GetState() == HostDown) num_hosts++; } @@ -252,7 +251,7 @@ Value HostGroupsTable::NumHostsUnreachAccessor(const Value& row) int num_hosts = 0; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const Host::Ptr& host : hg->GetMembers()) { if (!host->IsReachable()) num_hosts++; } @@ -272,7 +271,7 @@ Value HostGroupsTable::NumServicesAccessor(const Value& row) if (hg->GetMembers().size() == 0) return 0; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const Host::Ptr& host : hg->GetMembers()) { num_services += host->GetServices().size(); } @@ -288,8 +287,8 @@ Value HostGroupsTable::WorstServicesStateAccessor(const Value& row) Value worst_service = ServiceOK; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetState() > worst_service) worst_service = service->GetState(); } @@ -307,8 +306,8 @@ Value HostGroupsTable::NumServicesPendingAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { if (!service->GetLastCheckResult()) num_services++; } @@ -326,8 +325,8 @@ Value HostGroupsTable::NumServicesOkAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetState() == ServiceOK) num_services++; } @@ -345,8 +344,8 @@ Value HostGroupsTable::NumServicesWarnAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetState() == ServiceWarning) num_services++; } @@ -364,8 +363,8 @@ Value HostGroupsTable::NumServicesCritAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetState() == ServiceCritical) num_services++; } @@ -383,8 +382,8 @@ Value HostGroupsTable::NumServicesUnknownAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetState() == ServiceUnknown) num_services++; } @@ -402,8 +401,8 @@ Value HostGroupsTable::WorstServiceHardStateAccessor(const Value& row) Value worst_service = ServiceOK; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetStateType() == StateTypeHard) { if (service->GetState() > worst_service) worst_service = service->GetState(); @@ -423,8 +422,8 @@ Value HostGroupsTable::NumServicesHardOkAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceOK) num_services++; } @@ -442,8 +441,8 @@ Value HostGroupsTable::NumServicesHardWarnAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceWarning) num_services++; } @@ -461,8 +460,8 @@ Value HostGroupsTable::NumServicesHardCritAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceCritical) num_services++; } @@ -480,8 +479,8 @@ Value HostGroupsTable::NumServicesHardUnknownAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Host::Ptr& host : hg->GetMembers()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceUnknown) num_services++; } diff --git a/lib/livestatus/hoststable.cpp b/lib/livestatus/hoststable.cpp index a7322547d..1ebe99f4e 100644 --- a/lib/livestatus/hoststable.cpp +++ b/lib/livestatus/hoststable.cpp @@ -34,7 +34,6 @@ #include "base/json.hpp" #include "base/convert.hpp" #include "base/utility.hpp" -#include #include #include @@ -188,15 +187,15 @@ String HostsTable::GetPrefix(void) const void HostsTable::FetchRows(const AddRowFunction& addRowFn) { if (GetGroupByType() == LivestatusGroupByHostGroup) { - BOOST_FOREACH(const HostGroup::Ptr& hg, ConfigType::GetObjectsByType()) { - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const HostGroup::Ptr& hg : ConfigType::GetObjectsByType()) { + for (const Host::Ptr& host : hg->GetMembers()) { /* the caller must know which groupby type and value are set for this row */ if (!addRowFn(host, LivestatusGroupByHostGroup, hg)) return; } } } else { - BOOST_FOREACH(const Host::Ptr& host, ConfigType::GetObjectsByType()) { + for (const Host::Ptr& host : ConfigType::GetObjectsByType()) { if (!addRowFn(host, LivestatusGroupByNone, Empty)) return; } @@ -888,7 +887,7 @@ Value HostsTable::ContactsAccessor(const Value& row) Array::Ptr contact_names = new Array(); - BOOST_FOREACH(const User::Ptr& user, CompatUtility::GetCheckableNotificationUsers(host)) { + for (const User::Ptr& user : CompatUtility::GetCheckableNotificationUsers(host)) { contact_names->Add(user->GetName()); } @@ -904,7 +903,7 @@ Value HostsTable::DowntimesAccessor(const Value& row) Array::Ptr results = new Array(); - BOOST_FOREACH(const Downtime::Ptr& downtime, host->GetDowntimes()) { + for (const Downtime::Ptr& downtime : host->GetDowntimes()) { if (downtime->IsExpired()) continue; @@ -923,7 +922,7 @@ Value HostsTable::DowntimesWithInfoAccessor(const Value& row) Array::Ptr results = new Array(); - BOOST_FOREACH(const Downtime::Ptr& downtime, host->GetDowntimes()) { + for (const Downtime::Ptr& downtime : host->GetDowntimes()) { if (downtime->IsExpired()) continue; @@ -945,7 +944,7 @@ Value HostsTable::CommentsAccessor(const Value& row) return Empty; Array::Ptr results = new Array(); - BOOST_FOREACH(const Comment::Ptr& comment, host->GetComments()) { + for (const Comment::Ptr& comment : host->GetComments()) { if (comment->IsExpired()) continue; @@ -964,7 +963,7 @@ Value HostsTable::CommentsWithInfoAccessor(const Value& row) Array::Ptr results = new Array(); - BOOST_FOREACH(const Comment::Ptr& comment, host->GetComments()) { + for (const Comment::Ptr& comment : host->GetComments()) { if (comment->IsExpired()) continue; @@ -987,7 +986,7 @@ Value HostsTable::CommentsWithExtraInfoAccessor(const Value& row) Array::Ptr results = new Array(); - BOOST_FOREACH(const Comment::Ptr& comment, host->GetComments()) { + for (const Comment::Ptr& comment : host->GetComments()) { if (comment->IsExpired()) continue; @@ -1023,7 +1022,7 @@ Value HostsTable::CustomVariableNamesAccessor(const Value& row) Array::Ptr cv = new Array(); ObjectLock olock(vars); - BOOST_FOREACH(const Dictionary::Pair& kv, vars) { + for (const Dictionary::Pair& kv : vars) { cv->Add(kv.first); } @@ -1050,7 +1049,7 @@ Value HostsTable::CustomVariableValuesAccessor(const Value& row) Array::Ptr cv = new Array(); ObjectLock olock(vars); - BOOST_FOREACH(const Dictionary::Pair& kv, vars) { + for (const Dictionary::Pair& kv : vars) { if (kv.second.IsObjectType() || kv.second.IsObjectType()) cv->Add(JsonEncode(kv.second)); else @@ -1080,7 +1079,7 @@ Value HostsTable::CustomVariablesAccessor(const Value& row) Array::Ptr cv = new Array(); ObjectLock olock(vars); - BOOST_FOREACH(const Dictionary::Pair& kv, vars) { + for (const Dictionary::Pair& kv : vars) { Array::Ptr key_val = new Array(); key_val->Add(kv.first); @@ -1115,7 +1114,7 @@ Value HostsTable::CVIsJsonAccessor(const Value& row) bool cv_is_json = false; ObjectLock olock(vars); - BOOST_FOREACH(const Dictionary::Pair& kv, vars) { + for (const Dictionary::Pair& kv : vars) { if (kv.second.IsObjectType() || kv.second.IsObjectType()) cv_is_json = true; } @@ -1132,7 +1131,7 @@ Value HostsTable::ParentsAccessor(const Value& row) Array::Ptr parents = new Array(); - BOOST_FOREACH(const Checkable::Ptr& parent, host->GetParents()) { + for (const Checkable::Ptr& parent : host->GetParents()) { Host::Ptr parent_host = dynamic_pointer_cast(parent); if (!parent_host) @@ -1153,7 +1152,7 @@ Value HostsTable::ChildsAccessor(const Value& row) Array::Ptr childs = new Array(); - BOOST_FOREACH(const Checkable::Ptr& child, host->GetChildren()) { + for (const Checkable::Ptr& child : host->GetChildren()) { Host::Ptr child_host = dynamic_pointer_cast(child); if (!child_host) @@ -1185,7 +1184,7 @@ Value HostsTable::WorstServiceStateAccessor(const Value& row) Value worst_service = ServiceOK; - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetState() > worst_service) worst_service = service->GetState(); } @@ -1202,7 +1201,7 @@ Value HostsTable::NumServicesOkAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetState() == ServiceOK) num_services++; } @@ -1219,7 +1218,7 @@ Value HostsTable::NumServicesWarnAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetState() == ServiceWarning) num_services++; } @@ -1236,7 +1235,7 @@ Value HostsTable::NumServicesCritAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetState() == ServiceCritical) num_services++; } @@ -1253,7 +1252,7 @@ Value HostsTable::NumServicesUnknownAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetState() == ServiceUnknown) num_services++; } @@ -1270,7 +1269,7 @@ Value HostsTable::NumServicesPendingAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { if (!service->GetLastCheckResult()) num_services++; } @@ -1287,7 +1286,7 @@ Value HostsTable::WorstServiceHardStateAccessor(const Value& row) Value worst_service = ServiceOK; - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetStateType() == StateTypeHard) { if (service->GetState() > worst_service) worst_service = service->GetState(); @@ -1306,7 +1305,7 @@ Value HostsTable::NumServicesHardOkAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceOK) num_services++; } @@ -1323,7 +1322,7 @@ Value HostsTable::NumServicesHardWarnAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceWarning) num_services++; } @@ -1340,7 +1339,7 @@ Value HostsTable::NumServicesHardCritAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceCritical) num_services++; } @@ -1357,7 +1356,7 @@ Value HostsTable::NumServicesHardUnknownAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceUnknown) num_services++; } @@ -1414,7 +1413,7 @@ Value HostsTable::ContactGroupsAccessor(const Value& row) Array::Ptr contactgroup_names = new Array(); - BOOST_FOREACH(const UserGroup::Ptr& usergroup, CompatUtility::GetCheckableNotificationUserGroups(host)) { + for (const UserGroup::Ptr& usergroup : CompatUtility::GetCheckableNotificationUserGroups(host)) { contactgroup_names->Add(usergroup->GetName()); } @@ -1433,7 +1432,7 @@ Value HostsTable::ServicesAccessor(const Value& row) Array::Ptr services = new Array(); services->Reserve(rservices.size()); - BOOST_FOREACH(const Service::Ptr& service, rservices) { + for (const Service::Ptr& service : rservices) { services->Add(service->GetShortName()); } @@ -1452,7 +1451,7 @@ Value HostsTable::ServicesWithStateAccessor(const Value& row) Array::Ptr services = new Array(); services->Reserve(rservices.size()); - BOOST_FOREACH(const Service::Ptr& service, rservices) { + for (const Service::Ptr& service : rservices) { Array::Ptr svc_add = new Array(); svc_add->Add(service->GetShortName()); @@ -1476,7 +1475,7 @@ Value HostsTable::ServicesWithInfoAccessor(const Value& row) Array::Ptr services = new Array(); services->Reserve(rservices.size()); - BOOST_FOREACH(const Service::Ptr& service, rservices) { + for (const Service::Ptr& service : rservices) { Array::Ptr svc_add = new Array(); svc_add->Add(service->GetShortName()); diff --git a/lib/livestatus/livestatuslistener.cpp b/lib/livestatus/livestatuslistener.cpp index b306da31b..9fadff0c3 100644 --- a/lib/livestatus/livestatuslistener.cpp +++ b/lib/livestatus/livestatuslistener.cpp @@ -47,7 +47,7 @@ void LivestatusListener::StatsFunc(const Dictionary::Ptr& status, const Array::P { Dictionary::Ptr nodes = new Dictionary(); - BOOST_FOREACH(const LivestatusListener::Ptr& livestatuslistener, ConfigType::GetObjectsByType()) { + for (const LivestatusListener::Ptr& livestatuslistener : ConfigType::GetObjectsByType()) { Dictionary::Ptr stats = new Dictionary(); stats->Set("connections", l_Connections); diff --git a/lib/livestatus/livestatuslogutility.cpp b/lib/livestatus/livestatuslogutility.cpp index a45fa2147..9326ae7b5 100644 --- a/lib/livestatus/livestatuslogutility.cpp +++ b/lib/livestatus/livestatuslogutility.cpp @@ -27,7 +27,6 @@ #include "base/utility.hpp" #include "base/convert.hpp" #include "base/logger.hpp" -#include #include #include #include @@ -80,9 +79,10 @@ void LivestatusLogUtility::CreateLogCache(std::map index, Histor ASSERT(table); /* m_LogFileIndex map tells which log files are involved ordered by their start timestamp */ - unsigned int ts; unsigned long line_count = 0; - BOOST_FOREACH(boost::tie(ts, boost::tuples::ignore), index) { + for (const auto& kv : index) { + unsigned int ts = kv.first; + /* skip log files not in range (performance optimization) */ if (ts < from || ts > until) continue; diff --git a/lib/livestatus/livestatusquery.cpp b/lib/livestatus/livestatusquery.cpp index 832233708..010a93367 100644 --- a/lib/livestatus/livestatusquery.cpp +++ b/lib/livestatus/livestatusquery.cpp @@ -42,7 +42,6 @@ #include "base/timer.hpp" #include "base/initialize.hpp" #include -#include #include #include #include @@ -64,7 +63,7 @@ LivestatusQuery::LivestatusQuery(const std::vector& lines, const String& } String msg; - BOOST_FOREACH(const String& line, lines) { + for (const String& line : lines) { msg += line + "\n"; } Log(LogDebug, "LivestatusQuery", msg); @@ -272,7 +271,7 @@ LivestatusQuery::LivestatusQuery(const std::vector& lines, const String& /* Combine all top-level filters into a single filter. */ AndFilter::Ptr top_filter = new AndFilter(); - BOOST_FOREACH(const Filter::Ptr& filter, filters) { + for (const Filter::Ptr& filter : filters) { top_filter->AddSubFilter(filter); } @@ -380,7 +379,7 @@ void LivestatusQuery::AppendResultRow(std::ostream& fp, const Array::Ptr& row, b bool first = true; ObjectLock rlock(row); - BOOST_FOREACH(const Value& value, row) { + for (const Value& value : row) { if (first) first = false; else @@ -413,7 +412,7 @@ void LivestatusQuery::PrintCsvArray(std::ostream& fp, const Array::Ptr& array, i bool first = true; ObjectLock olock(array); - BOOST_FOREACH(const Value& value, array) { + for (const Value& value : array) { if (first) first = false; else @@ -434,7 +433,7 @@ void LivestatusQuery::PrintPythonArray(std::ostream& fp, const Array::Ptr& rs) c bool first = true; - BOOST_FOREACH(const Value& value, rs) { + for (const Value& value : rs) { if (first) first = false; else @@ -490,15 +489,15 @@ void LivestatusQuery::ExecuteGetHelper(const Stream::Ptr& stream) std::vector column_objs; column_objs.reserve(columns.size()); - BOOST_FOREACH(const String& columnName, columns) + for (const String& columnName : columns) column_objs.push_back(std::make_pair(columnName, table->GetColumn(columnName))); - BOOST_FOREACH(const LivestatusRowValue& object, objects) { + for (const LivestatusRowValue& object : objects) { Array::Ptr row = new Array(); row->Reserve(column_objs.size()); - BOOST_FOREACH(const ColumnPair& cv, column_objs) { + for (const ColumnPair& cv : column_objs) { if (m_ColumnHeaders) header->Add(cv.first); @@ -517,8 +516,8 @@ void LivestatusQuery::ExecuteGetHelper(const Stream::Ptr& stream) int index = 0; /* add aggregated stats */ - BOOST_FOREACH(const Aggregator::Ptr aggregator, m_Aggregators) { - BOOST_FOREACH(const LivestatusRowValue& object, objects) { + for (const Aggregator::Ptr aggregator : m_Aggregators) { + for (const LivestatusRowValue& object : objects) { aggregator->Apply(table, object.Row); } @@ -530,7 +529,7 @@ void LivestatusQuery::ExecuteGetHelper(const Stream::Ptr& stream) if (m_ColumnHeaders) { Array::Ptr header = new Array(); - BOOST_FOREACH(const String& columnName, m_Columns) { + for (const String& columnName : m_Columns) { header->Add(columnName); } @@ -550,7 +549,7 @@ void LivestatusQuery::ExecuteGetHelper(const Stream::Ptr& stream) * may not be accurate for grouping! */ if (objects.size() > 0 && m_Columns.size() > 0) { - BOOST_FOREACH(const String& columnName, m_Columns) { + for (const String& columnName : m_Columns) { Column column = table->GetColumn(columnName); LivestatusRowValue object = objects[0]; //first object wins diff --git a/lib/livestatus/logtable.cpp b/lib/livestatus/logtable.cpp index d5150e847..6458f1b00 100644 --- a/lib/livestatus/logtable.cpp +++ b/lib/livestatus/logtable.cpp @@ -36,7 +36,6 @@ #include "base/logger.hpp" #include "base/application.hpp" #include "base/objectlock.hpp" -#include #include #include #include diff --git a/lib/livestatus/orfilter.cpp b/lib/livestatus/orfilter.cpp index 501c82d65..4a7989435 100644 --- a/lib/livestatus/orfilter.cpp +++ b/lib/livestatus/orfilter.cpp @@ -18,7 +18,6 @@ ******************************************************************************/ #include "livestatus/orfilter.hpp" -#include using namespace icinga; @@ -30,7 +29,7 @@ bool OrFilter::Apply(const Table::Ptr& table, const Value& row) if (m_Filters.empty()) return true; - BOOST_FOREACH(const Filter::Ptr& filter, m_Filters) { + for (const Filter::Ptr& filter : m_Filters) { if (filter->Apply(table, row)) return true; } diff --git a/lib/livestatus/servicegroupstable.cpp b/lib/livestatus/servicegroupstable.cpp index 3cb4b5a38..5d964abab 100644 --- a/lib/livestatus/servicegroupstable.cpp +++ b/lib/livestatus/servicegroupstable.cpp @@ -20,7 +20,6 @@ #include "livestatus/servicegroupstable.hpp" #include "icinga/servicegroup.hpp" #include "base/configtype.hpp" -#include using namespace icinga; @@ -64,7 +63,7 @@ String ServiceGroupsTable::GetPrefix(void) const void ServiceGroupsTable::FetchRows(const AddRowFunction& addRowFn) { - BOOST_FOREACH(const ServiceGroup::Ptr& sg, ConfigType::GetObjectsByType()) { + for (const ServiceGroup::Ptr& sg : ConfigType::GetObjectsByType()) { if (!addRowFn(sg, LivestatusGroupByNone, Empty)) return; } @@ -129,7 +128,7 @@ Value ServiceGroupsTable::MembersAccessor(const Value& row) Array::Ptr members = new Array(); - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Array::Ptr host_svc = new Array(); host_svc->Add(service->GetHost()->GetName()); host_svc->Add(service->GetShortName()); @@ -148,7 +147,7 @@ Value ServiceGroupsTable::MembersWithStateAccessor(const Value& row) Array::Ptr members = new Array(); - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { Array::Ptr host_svc = new Array(); host_svc->Add(service->GetHost()->GetName()); host_svc->Add(service->GetShortName()); @@ -169,7 +168,7 @@ Value ServiceGroupsTable::WorstServiceStateAccessor(const Value& row) Value worst_service = ServiceOK; - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { if (service->GetState() > worst_service) worst_service = service->GetState(); } @@ -196,7 +195,7 @@ Value ServiceGroupsTable::NumServicesOkAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { if (service->GetState() == ServiceOK) num_services++; } @@ -213,7 +212,7 @@ Value ServiceGroupsTable::NumServicesWarnAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { if (service->GetState() == ServiceWarning) num_services++; } @@ -230,7 +229,7 @@ Value ServiceGroupsTable::NumServicesCritAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { if (service->GetState() == ServiceCritical) num_services++; } @@ -247,7 +246,7 @@ Value ServiceGroupsTable::NumServicesUnknownAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { if (service->GetState() == ServiceUnknown) num_services++; } @@ -264,7 +263,7 @@ Value ServiceGroupsTable::NumServicesPendingAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { if (!service->GetLastCheckResult()) num_services++; } @@ -281,7 +280,7 @@ Value ServiceGroupsTable::NumServicesHardOkAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceOK) num_services++; } @@ -298,7 +297,7 @@ Value ServiceGroupsTable::NumServicesHardWarnAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceWarning) num_services++; } @@ -315,7 +314,7 @@ Value ServiceGroupsTable::NumServicesHardCritAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceCritical) num_services++; } @@ -332,7 +331,7 @@ Value ServiceGroupsTable::NumServicesHardUnknownAccessor(const Value& row) int num_services = 0; - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const Service::Ptr& service : sg->GetMembers()) { if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceUnknown) num_services++; } diff --git a/lib/livestatus/servicestable.cpp b/lib/livestatus/servicestable.cpp index ce707717a..afd1f1b3c 100644 --- a/lib/livestatus/servicestable.cpp +++ b/lib/livestatus/servicestable.cpp @@ -36,7 +36,6 @@ #include "base/json.hpp" #include "base/convert.hpp" #include "base/utility.hpp" -#include #include #include @@ -168,19 +167,19 @@ String ServicesTable::GetPrefix(void) const void ServicesTable::FetchRows(const AddRowFunction& addRowFn) { if (GetGroupByType() == LivestatusGroupByServiceGroup) { - BOOST_FOREACH(const ServiceGroup::Ptr& sg, ConfigType::GetObjectsByType()) { - BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) { + for (const ServiceGroup::Ptr& sg : ConfigType::GetObjectsByType()) { + for (const Service::Ptr& service : sg->GetMembers()) { /* the caller must know which groupby type and value are set for this row */ if (!addRowFn(service, LivestatusGroupByServiceGroup, sg)) return; } } } else if (GetGroupByType() == LivestatusGroupByHostGroup) { - BOOST_FOREACH(const HostGroup::Ptr& hg, ConfigType::GetObjectsByType()) { + for (const HostGroup::Ptr& hg : ConfigType::GetObjectsByType()) { ObjectLock ylock(hg); - BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { + for (const Host::Ptr& host : hg->GetMembers()) { ObjectLock ylock(host); - BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) { + for (const Service::Ptr& service : host->GetServices()) { /* the caller must know which groupby type and value are set for this row */ if (!addRowFn(service, LivestatusGroupByHostGroup, hg)) return; @@ -188,7 +187,7 @@ void ServicesTable::FetchRows(const AddRowFunction& addRowFn) } } } else { - BOOST_FOREACH(const Service::Ptr& service, ConfigType::GetObjectsByType()) { + for (const Service::Ptr& service : ConfigType::GetObjectsByType()) { if (!addRowFn(service, LivestatusGroupByNone, Empty)) return; } @@ -926,7 +925,7 @@ Value ServicesTable::ContactsAccessor(const Value& row) Array::Ptr contact_names = new Array(); - BOOST_FOREACH(const User::Ptr& user, CompatUtility::GetCheckableNotificationUsers(service)) { + for (const User::Ptr& user : CompatUtility::GetCheckableNotificationUsers(service)) { contact_names->Add(user->GetName()); } @@ -942,7 +941,7 @@ Value ServicesTable::DowntimesAccessor(const Value& row) Array::Ptr results = new Array(); - BOOST_FOREACH(const Downtime::Ptr& downtime, service->GetDowntimes()) { + for (const Downtime::Ptr& downtime : service->GetDowntimes()) { if (downtime->IsExpired()) continue; @@ -961,7 +960,7 @@ Value ServicesTable::DowntimesWithInfoAccessor(const Value& row) Array::Ptr results = new Array(); - BOOST_FOREACH(const Downtime::Ptr& downtime, service->GetDowntimes()) { + for (const Downtime::Ptr& downtime : service->GetDowntimes()) { if (downtime->IsExpired()) continue; @@ -984,7 +983,7 @@ Value ServicesTable::CommentsAccessor(const Value& row) Array::Ptr results = new Array(); - BOOST_FOREACH(const Comment::Ptr& comment, service->GetComments()) { + for (const Comment::Ptr& comment : service->GetComments()) { if (comment->IsExpired()) continue; @@ -1003,7 +1002,7 @@ Value ServicesTable::CommentsWithInfoAccessor(const Value& row) Array::Ptr results = new Array(); - BOOST_FOREACH(const Comment::Ptr& comment, service->GetComments()) { + for (const Comment::Ptr& comment : service->GetComments()) { if (comment->IsExpired()) continue; @@ -1026,7 +1025,7 @@ Value ServicesTable::CommentsWithExtraInfoAccessor(const Value& row) Array::Ptr results = new Array(); - BOOST_FOREACH(const Comment::Ptr& comment, service->GetComments()) { + for (const Comment::Ptr& comment : service->GetComments()) { if (comment->IsExpired()) continue; @@ -1062,7 +1061,7 @@ Value ServicesTable::CustomVariableNamesAccessor(const Value& row) Array::Ptr cv = new Array(); ObjectLock olock(vars); - BOOST_FOREACH(const Dictionary::Pair& kv, vars) { + for (const Dictionary::Pair& kv : vars) { cv->Add(kv.first); } @@ -1089,7 +1088,7 @@ Value ServicesTable::CustomVariableValuesAccessor(const Value& row) Array::Ptr cv = new Array(); ObjectLock olock(vars); - BOOST_FOREACH(const Dictionary::Pair& kv, vars) { + for (const Dictionary::Pair& kv : vars) { if (kv.second.IsObjectType() || kv.second.IsObjectType()) cv->Add(JsonEncode(kv.second)); else @@ -1119,7 +1118,7 @@ Value ServicesTable::CustomVariablesAccessor(const Value& row) Array::Ptr cv = new Array(); ObjectLock olock(vars); - BOOST_FOREACH(const Dictionary::Pair& kv, vars) { + for (const Dictionary::Pair& kv : vars) { Array::Ptr key_val = new Array(); key_val->Add(kv.first); @@ -1154,7 +1153,7 @@ Value ServicesTable::CVIsJsonAccessor(const Value& row) bool cv_is_json = false; ObjectLock olock(vars); - BOOST_FOREACH(const Dictionary::Pair& kv, vars) { + for (const Dictionary::Pair& kv : vars) { if (kv.second.IsObjectType() || kv.second.IsObjectType()) cv_is_json = true; } @@ -1186,7 +1185,7 @@ Value ServicesTable::ContactGroupsAccessor(const Value& row) Array::Ptr contactgroup_names = new Array(); - BOOST_FOREACH(const UserGroup::Ptr& usergroup, CompatUtility::GetCheckableNotificationUserGroups(service)) { + for (const UserGroup::Ptr& usergroup : CompatUtility::GetCheckableNotificationUserGroups(service)) { contactgroup_names->Add(usergroup->GetName()); } diff --git a/lib/livestatus/statehisttable.cpp b/lib/livestatus/statehisttable.cpp index 87de4439c..84b50d60e 100644 --- a/lib/livestatus/statehisttable.cpp +++ b/lib/livestatus/statehisttable.cpp @@ -36,7 +36,6 @@ #include "base/logger.hpp" #include "base/application.hpp" #include "base/objectlock.hpp" -#include #include #include #include @@ -127,7 +126,7 @@ void StateHistTable::UpdateLogEntries(const Dictionary::Ptr& log_entry_attrs, in /* determine service notifications notification_period and compare against current timestamp */ bool in_notification_period = true; String notification_period_name; - BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) { + for (const Notification::Ptr& notification : checkable->GetNotifications()) { TimePeriod::Ptr notification_period = notification->GetPeriod(); if (notification_period) { @@ -268,8 +267,8 @@ void StateHistTable::FetchRows(const AddRowFunction& addRowFn) Checkable::Ptr checkable; - BOOST_FOREACH(boost::tie(checkable, boost::tuples::ignore), m_CheckablesCache) { - BOOST_FOREACH(const Dictionary::Ptr& state_hist_bag, m_CheckablesCache[checkable]) { + for (const auto& kv : m_CheckablesCache) { + for (const Dictionary::Ptr& state_hist_bag : kv.second) { /* pass a dictionary from state history array */ if (!addRowFn(state_hist_bag, LivestatusGroupByNone, Empty)) return; diff --git a/lib/livestatus/statustable.cpp b/lib/livestatus/statustable.cpp index d4087b8ad..93ce52e95 100644 --- a/lib/livestatus/statustable.cpp +++ b/lib/livestatus/statustable.cpp @@ -26,7 +26,6 @@ #include "base/configtype.hpp" #include "base/utility.hpp" #include "base/application.hpp" -#include using namespace icinga; @@ -239,10 +238,11 @@ Value StatusTable::CustomVariableNamesAccessor(const Value&) Array::Ptr cv = new Array(); - String key; - Value value; - BOOST_FOREACH(tie(key, value), vars) { - cv->Add(key); + { + ObjectLock olock(vars); + for (const auto& kv : vars) { + cv->Add(kv.first); + } } return cv; @@ -257,10 +257,11 @@ Value StatusTable::CustomVariableValuesAccessor(const Value&) Array::Ptr cv = new Array(); - String key; - Value value; - BOOST_FOREACH(tie(key, value), vars) { - cv->Add(value); + { + ObjectLock olock(vars); + for (const auto& kv : vars) { + cv->Add(kv.second); + } } return cv; @@ -275,13 +276,14 @@ Value StatusTable::CustomVariablesAccessor(const Value&) Array::Ptr cv = new Array(); - String key; - Value value; - BOOST_FOREACH(tie(key, value), vars) { - Array::Ptr key_val = new Array(); - key_val->Add(key); - key_val->Add(value); - cv->Add(key_val); + { + ObjectLock olock(vars); + for (const auto& kv : vars) { + Array::Ptr key_val = new Array(); + key_val->Add(kv.first); + key_val->Add(kv.second); + cv->Add(key_val); + } } return cv; diff --git a/lib/livestatus/table.cpp b/lib/livestatus/table.cpp index acec7be53..45f616d74 100644 --- a/lib/livestatus/table.cpp +++ b/lib/livestatus/table.cpp @@ -38,7 +38,6 @@ #include "base/dictionary.hpp" #include #include -#include #include using namespace icinga; @@ -119,9 +118,8 @@ std::vector Table::GetColumnNames(void) const { std::vector names; - String name; - BOOST_FOREACH(boost::tie(name, boost::tuples::ignore), m_Columns) { - names.push_back(name); + for (const auto& kv : m_Columns) { + names.push_back(kv.first); } return names; diff --git a/lib/livestatus/timeperiodstable.cpp b/lib/livestatus/timeperiodstable.cpp index f97195c5e..81cede735 100644 --- a/lib/livestatus/timeperiodstable.cpp +++ b/lib/livestatus/timeperiodstable.cpp @@ -24,7 +24,6 @@ #include "base/objectlock.hpp" #include "base/convert.hpp" #include "base/utility.hpp" -#include #include using namespace icinga; @@ -54,7 +53,7 @@ String TimePeriodsTable::GetPrefix(void) const void TimePeriodsTable::FetchRows(const AddRowFunction& addRowFn) { - BOOST_FOREACH(const TimePeriod::Ptr& tp, ConfigType::GetObjectsByType()) { + for (const TimePeriod::Ptr& tp : ConfigType::GetObjectsByType()) { if (!addRowFn(tp, LivestatusGroupByNone, Empty)) return; } diff --git a/lib/livestatus/zonestable.cpp b/lib/livestatus/zonestable.cpp index 436a78de6..25ff3149a 100644 --- a/lib/livestatus/zonestable.cpp +++ b/lib/livestatus/zonestable.cpp @@ -20,7 +20,6 @@ #include "livestatus/zonestable.hpp" #include "remote/zone.hpp" #include "base/configtype.hpp" -#include using namespace icinga; @@ -50,7 +49,7 @@ String ZonesTable::GetPrefix(void) const void ZonesTable::FetchRows(const AddRowFunction& addRowFn) { - BOOST_FOREACH(const Zone::Ptr& zone, ConfigType::GetObjectsByType()) { + for (const Zone::Ptr& zone : ConfigType::GetObjectsByType()) { if (!addRowFn(zone, LivestatusGroupByNone, Empty)) return; } @@ -92,7 +91,7 @@ Value ZonesTable::EndpointsAccessor(const Value& row) Array::Ptr endpoint_names = new Array(); - BOOST_FOREACH(const Endpoint::Ptr endpoint, endpoints) { + for (const Endpoint::Ptr endpoint : endpoints) { endpoint_names->Add(endpoint->GetName()); } diff --git a/lib/methods/clrchecktask.cpp b/lib/methods/clrchecktask.cpp index 6e3580c82..6bc8ad1a6 100644 --- a/lib/methods/clrchecktask.cpp +++ b/lib/methods/clrchecktask.cpp @@ -29,7 +29,6 @@ #include "base/process.hpp" #include #include -#include #include #include #include @@ -91,7 +90,7 @@ static variant_t InvokeClrMethod(const variant_t& vtObject, const String& method CoCreateInstance(clsid, NULL, CLSCTX_ALL, __uuidof(mscorlib::IDictionary), (void **)&pHashtable); ObjectLock olock(args); - BOOST_FOREACH(const Dictionary::Pair& kv, args) { + for (const Dictionary::Pair& kv : args) { String value = kv.second; pHashtable->Add(kv.first.CStr(), value.CStr()); } @@ -168,7 +167,7 @@ void ClrCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult if (env) { ObjectLock olock(env); - BOOST_FOREACH(const Dictionary::Pair& kv, env) { + for (const Dictionary::Pair& kv : env) { String name = kv.second; Value value = MacroProcessor::ResolveMacros(name, resolvers, checkable->GetLastCheckResult(), diff --git a/lib/methods/clusterchecktask.cpp b/lib/methods/clusterchecktask.cpp index 99ebda29c..8af1558fd 100644 --- a/lib/methods/clusterchecktask.cpp +++ b/lib/methods/clusterchecktask.cpp @@ -30,7 +30,6 @@ #include "base/function.hpp" #include "base/configtype.hpp" #include -#include using namespace icinga; @@ -82,7 +81,7 @@ String ClusterCheckTask::FormatArray(const Array::Ptr& arr) if (arr) { ObjectLock olock(arr); - BOOST_FOREACH(const Value& value, arr) { + for (const Value& value : arr) { if (first) first = false; else diff --git a/lib/methods/clusterzonechecktask.cpp b/lib/methods/clusterzonechecktask.cpp index b31444547..f80fb5175 100644 --- a/lib/methods/clusterzonechecktask.cpp +++ b/lib/methods/clusterzonechecktask.cpp @@ -26,7 +26,6 @@ #include "remote/zone.hpp" #include "base/function.hpp" #include "base/utility.hpp" -#include using namespace icinga; @@ -92,7 +91,7 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che bool connected = false; double zoneLag = 0; - BOOST_FOREACH(const Endpoint::Ptr& endpoint, zone->GetEndpoints()) { + for (const Endpoint::Ptr& endpoint : zone->GetEndpoints()) { if (endpoint->GetConnected()) connected = true; diff --git a/lib/methods/pluginchecktask.cpp b/lib/methods/pluginchecktask.cpp index 83ad4610a..85f126b5d 100644 --- a/lib/methods/pluginchecktask.cpp +++ b/lib/methods/pluginchecktask.cpp @@ -30,7 +30,6 @@ #include "base/convert.hpp" #include #include -#include using namespace icinga; diff --git a/lib/methods/plugineventtask.cpp b/lib/methods/plugineventtask.cpp index 3e6f72f4f..ed64ec5f3 100644 --- a/lib/methods/plugineventtask.cpp +++ b/lib/methods/plugineventtask.cpp @@ -28,7 +28,6 @@ #include "base/utility.hpp" #include "base/process.hpp" #include "base/convert.hpp" -#include using namespace icinga; diff --git a/lib/methods/pluginnotificationtask.cpp b/lib/methods/pluginnotificationtask.cpp index 28708684b..8247b7ee8 100644 --- a/lib/methods/pluginnotificationtask.cpp +++ b/lib/methods/pluginnotificationtask.cpp @@ -29,7 +29,6 @@ #include "base/utility.hpp" #include "base/process.hpp" #include "base/convert.hpp" -#include using namespace icinga; diff --git a/lib/notification/notificationcomponent.cpp b/lib/notification/notificationcomponent.cpp index 69d227fc1..5dd911535 100644 --- a/lib/notification/notificationcomponent.cpp +++ b/lib/notification/notificationcomponent.cpp @@ -27,7 +27,6 @@ #include "base/utility.hpp" #include "base/exception.hpp" #include "base/statsfunction.hpp" -#include using namespace icinga; @@ -39,7 +38,7 @@ void NotificationComponent::StatsFunc(const Dictionary::Ptr& status, const Array { Dictionary::Ptr nodes = new Dictionary(); - BOOST_FOREACH(const NotificationComponent::Ptr& notification_component, ConfigType::GetObjectsByType()) { + for (const NotificationComponent::Ptr& notification_component : ConfigType::GetObjectsByType()) { nodes->Set(notification_component->GetName(), 1); //add more stats } @@ -71,7 +70,7 @@ void NotificationComponent::NotificationTimerHandler(void) { double now = Utility::GetTime(); - BOOST_FOREACH(const Notification::Ptr& notification, ConfigType::GetObjectsByType()) { + for (const Notification::Ptr& notification : ConfigType::GetObjectsByType()) { if (!notification->IsActive()) continue; diff --git a/lib/perfdata/gelfwriter.cpp b/lib/perfdata/gelfwriter.cpp index 154aaa13d..430545ccb 100644 --- a/lib/perfdata/gelfwriter.cpp +++ b/lib/perfdata/gelfwriter.cpp @@ -33,7 +33,6 @@ #include "base/networkstream.hpp" #include "base/json.hpp" #include "base/context.hpp" -#include #include using namespace icinga; @@ -125,7 +124,7 @@ void GelfWriter::CheckResultHandler(const Checkable::Ptr& checkable, const Check if (perfdata) { ObjectLock olock(perfdata); - BOOST_FOREACH(const Value& val, perfdata) { + for (const Value& val : perfdata) { PerfdataValue::Ptr pdv; if (val.IsObjectType()) diff --git a/lib/perfdata/graphitewriter.cpp b/lib/perfdata/graphitewriter.cpp index 6b518a722..5cb08d63f 100644 --- a/lib/perfdata/graphitewriter.cpp +++ b/lib/perfdata/graphitewriter.cpp @@ -37,7 +37,6 @@ #include "base/statsfunction.hpp" #include #include -#include #include #include @@ -51,7 +50,7 @@ void GraphiteWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&) { Dictionary::Ptr nodes = new Dictionary(); - BOOST_FOREACH(const GraphiteWriter::Ptr& graphitewriter, ConfigType::GetObjectsByType()) { + for (const GraphiteWriter::Ptr& graphitewriter : ConfigType::GetObjectsByType()) { nodes->Set(graphitewriter->GetName(), 1); //add more stats } @@ -176,7 +175,7 @@ void GraphiteWriter::SendPerfdata(const String& prefix, const CheckResult::Ptr& return; ObjectLock olock(perfdata); - BOOST_FOREACH(const Value& val, perfdata) { + for (const Value& val : perfdata) { PerfdataValue::Ptr pdv; if (val.IsObjectType()) @@ -287,7 +286,7 @@ Value GraphiteWriter::EscapeMacroMetric(const Value& value, bool legacyMode) Array::Ptr result = new Array(); ObjectLock olock(arr); - BOOST_FOREACH(const Value& arg, arr) { + for (const Value& arg : arr) { result->Add(EscapeMetric(arg, legacyMode)); } diff --git a/lib/perfdata/influxdbwriter.cpp b/lib/perfdata/influxdbwriter.cpp index d401bf0ba..5163f0d38 100644 --- a/lib/perfdata/influxdbwriter.cpp +++ b/lib/perfdata/influxdbwriter.cpp @@ -42,7 +42,6 @@ #include "base/tlsutility.hpp" #include #include -#include #include #include #include @@ -57,7 +56,7 @@ void InfluxdbWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&) { Dictionary::Ptr nodes = new Dictionary(); - BOOST_FOREACH(const InfluxdbWriter::Ptr& influxdbwriter, ConfigType::GetObjectsByType()) { + for (const InfluxdbWriter::Ptr& influxdbwriter : ConfigType::GetObjectsByType()) { nodes->Set(influxdbwriter->GetName(), 1); //add more stats } @@ -148,7 +147,7 @@ void InfluxdbWriter::CheckResultHandler(const Checkable::Ptr& checkable, const C Dictionary::Ptr tags = tmpl->Get("tags"); if (tags) { ObjectLock olock(tags); - BOOST_FOREACH(const Dictionary::Pair& pair, tags) { + for (const Dictionary::Pair& pair : tags) { // Prevent missing macros from warning; will return an empty value // which will be filtered out in SendMetric() String missing_macro; @@ -177,7 +176,7 @@ void InfluxdbWriter::SendPerfdata(const Dictionary::Ptr& tmpl, const Checkable:: return; ObjectLock olock(perfdata); - BOOST_FOREACH(const Value& val, perfdata) { + for (const Value& val : perfdata) { PerfdataValue::Ptr pdv; if (val.IsObjectType()) @@ -287,7 +286,7 @@ void InfluxdbWriter::SendMetric(const Dictionary::Ptr& tmpl, const String& label Dictionary::Ptr tags = tmpl->Get("tags"); if (tags) { ObjectLock olock(tags); - BOOST_FOREACH(const Dictionary::Pair& pair, tags) { + for (const Dictionary::Pair& pair : tags) { // Empty macro expansion, no tag if (!pair.second.IsEmpty()) { msgbuf << "," << EscapeKey(pair.first) << "=" << EscapeKey(pair.second); @@ -299,7 +298,7 @@ void InfluxdbWriter::SendMetric(const Dictionary::Ptr& tmpl, const String& label bool first = true; ObjectLock fieldLock(fields); - BOOST_FOREACH(const Dictionary::Pair& pair, fields) { + for (const Dictionary::Pair& pair : fields) { if (first) first = false; else @@ -411,7 +410,7 @@ void InfluxdbWriter::ValidateHostTemplate(const Dictionary::Ptr& value, const Va Dictionary::Ptr tags = value->Get("tags"); if (tags) { ObjectLock olock(tags); - BOOST_FOREACH(const Dictionary::Pair& pair, tags) { + for (const Dictionary::Pair& pair : tags) { if (!MacroProcessor::ValidateMacroString(pair.second)) BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("host_template")("tags")(pair.first), "Closing $ not found in macro format string '" + pair.second)); } @@ -429,7 +428,7 @@ void InfluxdbWriter::ValidateServiceTemplate(const Dictionary::Ptr& value, const Dictionary::Ptr tags = value->Get("tags"); if (tags) { ObjectLock olock(tags); - BOOST_FOREACH(const Dictionary::Pair& pair, tags) { + for (const Dictionary::Pair& pair : tags) { if (!MacroProcessor::ValidateMacroString(pair.second)) BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of("service_template")("tags")(pair.first), "Closing $ not found in macro format string '" + pair.second)); } diff --git a/lib/perfdata/opentsdbwriter.cpp b/lib/perfdata/opentsdbwriter.cpp index 494e62903..1d4da33d1 100644 --- a/lib/perfdata/opentsdbwriter.cpp +++ b/lib/perfdata/opentsdbwriter.cpp @@ -37,7 +37,6 @@ #include "base/statsfunction.hpp" #include #include -#include #include #include @@ -51,7 +50,7 @@ void OpenTsdbWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&) { Dictionary::Ptr nodes = new Dictionary(); - BOOST_FOREACH(const OpenTsdbWriter::Ptr& opentsdbwriter, ConfigType::GetObjectsByType()) { + for (const OpenTsdbWriter::Ptr& opentsdbwriter : ConfigType::GetObjectsByType()) { nodes->Set(opentsdbwriter->GetName(), 1); //add more stats } @@ -158,7 +157,7 @@ void OpenTsdbWriter::SendPerfdata(const String& metric, const std::map()) @@ -192,7 +191,7 @@ void OpenTsdbWriter::SendPerfdata(const String& metric, const std::map& tags, double value, double ts) { String tags_string = ""; - BOOST_FOREACH(const Dictionary::Pair& tag, tags) { + for (const Dictionary::Pair& tag : tags) { tags_string += " " + tag.first + "=" + Convert::ToString(tag.second); } diff --git a/lib/perfdata/perfdatawriter.cpp b/lib/perfdata/perfdatawriter.cpp index 304ce2605..12565be24 100644 --- a/lib/perfdata/perfdatawriter.cpp +++ b/lib/perfdata/perfdatawriter.cpp @@ -42,7 +42,7 @@ void PerfdataWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&) { Dictionary::Ptr nodes = new Dictionary(); - BOOST_FOREACH(const PerfdataWriter::Ptr& perfdatawriter, ConfigType::GetObjectsByType()) { + for (const PerfdataWriter::Ptr& perfdatawriter : ConfigType::GetObjectsByType()) { nodes->Set(perfdatawriter->GetName(), 1); //add more stats } diff --git a/lib/remote/actionshandler.cpp b/lib/remote/actionshandler.cpp index 998c765d7..04642922e 100644 --- a/lib/remote/actionshandler.cpp +++ b/lib/remote/actionshandler.cpp @@ -77,7 +77,7 @@ bool ActionsHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& reques Log(LogNotice, "ApiActionHandler") << "Running action " << actionName; - BOOST_FOREACH(const ConfigObject::Ptr& obj, objs) { + for (const ConfigObject::Ptr& obj : objs) { try { results->Add(action->Invoke(obj, params)); } catch (const std::exception& ex) { diff --git a/lib/remote/apiclient.cpp b/lib/remote/apiclient.cpp index 272065cfa..34ebb4508 100644 --- a/lib/remote/apiclient.cpp +++ b/lib/remote/apiclient.cpp @@ -23,7 +23,6 @@ #include "base/logger.hpp" #include "base/exception.hpp" #include "base/convert.hpp" -#include using namespace icinga; @@ -84,7 +83,7 @@ void ApiClient::TypesHttpCompletionCallback(HttpRequest& request, HttpResponse& Array::Ptr results = result->Get("results"); ObjectLock olock(results); - BOOST_FOREACH(const Dictionary::Ptr typeInfo, results) + for (const Dictionary::Ptr typeInfo : results) { ApiType::Ptr type = new ApiType();; type->Abstract = typeInfo->Get("abstract"); @@ -120,15 +119,15 @@ void ApiClient::GetObjects(const String& pluralType, const ObjectsCompletionCall std::map > params; - BOOST_FOREACH(const String& name, names) { + for (const String& name : names) { params[pluralType.ToLower()].push_back(name); } - BOOST_FOREACH(const String& attr, attrs) { + for (const String& attr : attrs) { params["attrs"].push_back(attr); } - BOOST_FOREACH(const String& join, joins) { + for (const String& join : joins) { params["joins"].push_back(join); } @@ -175,7 +174,7 @@ void ApiClient::ObjectsHttpCompletionCallback(HttpRequest& request, if (results) { ObjectLock olock(results); - BOOST_FOREACH(const Dictionary::Ptr objectInfo, results) { + for (const Dictionary::Ptr objectInfo : results) { ApiObject::Ptr object = new ApiObject(); object->Name = objectInfo->Get("name"); @@ -185,7 +184,7 @@ void ApiClient::ObjectsHttpCompletionCallback(HttpRequest& request, if (attrs) { ObjectLock olock(attrs); - BOOST_FOREACH(const Dictionary::Pair& kv, attrs) { + for (const Dictionary::Pair& kv : attrs) { object->Attrs[object->Type.ToLower() + "." + kv.first] = kv.second; } } @@ -194,12 +193,12 @@ void ApiClient::ObjectsHttpCompletionCallback(HttpRequest& request, if (joins) { ObjectLock olock(joins); - BOOST_FOREACH(const Dictionary::Pair& kv, joins) { + for (const Dictionary::Pair& kv : joins) { Dictionary::Ptr attrs = kv.second; if (attrs) { ObjectLock olock(attrs); - BOOST_FOREACH(const Dictionary::Pair& kv2, attrs) { + for (const Dictionary::Pair& kv2 : attrs) { object->Attrs[kv.first + "." + kv2.first] = kv2.second; } } @@ -210,7 +209,7 @@ void ApiClient::ObjectsHttpCompletionCallback(HttpRequest& request, if (used_by) { ObjectLock olock(used_by); - BOOST_FOREACH(const Dictionary::Ptr& refInfo, used_by) { + for (const Dictionary::Ptr& refInfo : used_by) { ApiObjectReference ref; ref.Name = refInfo->Get("name"); ref.Type = refInfo->Get("type"); diff --git a/lib/remote/apilistener-configsync.cpp b/lib/remote/apilistener-configsync.cpp index 7e5ead4a3..20f08230b 100644 --- a/lib/remote/apilistener-configsync.cpp +++ b/lib/remote/apilistener-configsync.cpp @@ -25,7 +25,6 @@ #include "base/json.hpp" #include "base/convert.hpp" #include "config/vmops.hpp" -#include #include #include #include @@ -122,7 +121,7 @@ Value ApiListener::ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin << "Could not create object '" << objName << "':"; ObjectLock olock(errors); - BOOST_FOREACH(const String& error, errors) { + for (const String& error : errors) { Log(LogCritical, "ApiListener", error); } @@ -160,7 +159,7 @@ Value ApiListener::ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin if (modified_attributes) { ObjectLock olock(modified_attributes); - BOOST_FOREACH(const Dictionary::Pair& kv, modified_attributes) { + for (const Dictionary::Pair& kv : modified_attributes) { /* update all modified attributes * but do not update the object version yet. * This triggers cluster events otherwise. @@ -178,14 +177,14 @@ Value ApiListener::ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin { ObjectLock xlock(objOriginalAttributes); - BOOST_FOREACH(const Dictionary::Pair& kv, objOriginalAttributes) { + for (const Dictionary::Pair& kv : objOriginalAttributes) { /* original attribute was removed, restore it */ if (!newOriginalAttributes->Contains(kv.first)) restoreAttrs.push_back(kv.first); } } - BOOST_FOREACH(const String& key, restoreAttrs) { + for (const String& key : restoreAttrs) { /* do not update the object version yet. */ object->RestoreAttribute(key, false); } @@ -260,7 +259,7 @@ Value ApiListener::ConfigDeleteObjectAPIHandler(const MessageOrigin::Ptr& origin Log(LogCritical, "ApiListener", "Could not delete object:"); ObjectLock olock(errors); - BOOST_FOREACH(const String& error, errors) { + for (const String& error : errors) { Log(LogCritical, "ApiListener", error); } } @@ -313,12 +312,12 @@ void ApiListener::UpdateConfigObject(const ConfigObject::Ptr& object, const Mess if (original_attributes) { ObjectLock olock(original_attributes); - BOOST_FOREACH(const Dictionary::Pair& kv, original_attributes) { + for (const Dictionary::Pair& kv : original_attributes) { std::vector tokens; boost::algorithm::split(tokens, kv.first, boost::is_any_of(".")); Value value = object; - BOOST_FOREACH(const String& token, tokens) { + for (const String& token : tokens) { value = VMOps::GetField(value, token); } @@ -399,13 +398,13 @@ void ApiListener::SendRuntimeConfigObjects(const JsonRpcConnection::Ptr& aclient Log(LogInformation, "ApiListener") << "Syncing runtime objects to endpoint '" << endpoint->GetName() << "'."; - BOOST_FOREACH(const Type::Ptr& type, Type::GetAllTypes()) { + for (const Type::Ptr& type : Type::GetAllTypes()) { ConfigType *dtype = dynamic_cast(type.get()); if (!dtype) continue; - BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) { + for (const ConfigObject::Ptr& object : dtype->GetObjects()) { /* don't sync objects with an older version time than the endpoint's log position */ if (object->GetVersion() < endpoint->GetLocalLogPosition()) continue; diff --git a/lib/remote/apilistener-filesync.cpp b/lib/remote/apilistener-filesync.cpp index 66906f3c3..d262fefc3 100644 --- a/lib/remote/apilistener-filesync.cpp +++ b/lib/remote/apilistener-filesync.cpp @@ -24,7 +24,6 @@ #include "base/logger.hpp" #include "base/convert.hpp" #include "base/exception.hpp" -#include #include #include @@ -104,7 +103,7 @@ bool ApiListener::UpdateConfigDir(const ConfigDirInformation& oldConfigInfo, con { ObjectLock olock(newConfig); - BOOST_FOREACH(const Dictionary::Pair& kv, newConfig) { + for (const Dictionary::Pair& kv : newConfig) { if (oldConfig->Get(kv.first) != kv.second) { if (!Utility::Match("*/.timestamp", kv.first)) configChange = true; @@ -123,7 +122,7 @@ bool ApiListener::UpdateConfigDir(const ConfigDirInformation& oldConfigInfo, con } ObjectLock xlock(oldConfig); - BOOST_FOREACH(const Dictionary::Pair& kv, oldConfig) { + for (const Dictionary::Pair& kv : oldConfig) { if (!newConfig->Contains(kv.first)) { configChange = true; @@ -156,19 +155,19 @@ void ApiListener::SyncZoneDir(const Zone::Ptr& zone) const newConfigInfo.UpdateV1 = new Dictionary(); newConfigInfo.UpdateV2 = new Dictionary(); - BOOST_FOREACH(const ZoneFragment& zf, ConfigCompiler::GetZoneDirs(zone->GetName())) { + for (const ZoneFragment& zf : ConfigCompiler::GetZoneDirs(zone->GetName())) { ConfigDirInformation newConfigPart = LoadConfigDir(zf.Path); { ObjectLock olock(newConfigPart.UpdateV1); - BOOST_FOREACH(const Dictionary::Pair& kv, newConfigPart.UpdateV1) { + for (const Dictionary::Pair& kv : newConfigPart.UpdateV1) { newConfigInfo.UpdateV1->Set("/" + zf.Tag + kv.first, kv.second); } } { ObjectLock olock(newConfigPart.UpdateV2); - BOOST_FOREACH(const Dictionary::Pair& kv, newConfigPart.UpdateV2) { + for (const Dictionary::Pair& kv : newConfigPart.UpdateV2) { newConfigInfo.UpdateV2->Set("/" + zf.Tag + kv.first, kv.second); } } @@ -193,7 +192,7 @@ void ApiListener::SyncZoneDir(const Zone::Ptr& zone) const void ApiListener::SyncZoneDirs(void) const { - BOOST_FOREACH(const Zone::Ptr& zone, ConfigType::GetObjectsByType()) { + for (const Zone::Ptr& zone : ConfigType::GetObjectsByType()) { try { SyncZoneDir(zone); } catch (const std::exception&) { @@ -219,7 +218,7 @@ void ApiListener::SendConfigUpdate(const JsonRpcConnection::Ptr& aclient) String zonesDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones"; - BOOST_FOREACH(const Zone::Ptr& zone, ConfigType::GetObjectsByType()) { + for (const Zone::Ptr& zone : ConfigType::GetObjectsByType()) { String zoneDir = zonesDir + "/" + zone->GetName(); if (!zone->IsChildOf(azone) && !zone->IsGlobal()) @@ -273,7 +272,7 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin::Ptr& origin, const D bool configChange = false; ObjectLock olock(updateV1); - BOOST_FOREACH(const Dictionary::Pair& kv, updateV1) { + for (const Dictionary::Pair& kv : updateV1) { Zone::Ptr zone = Zone::GetByName(kv.first); if (!zone) { diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 41c98c01d..8ade19fff 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -183,7 +183,7 @@ Endpoint::Ptr ApiListener::GetMaster(void) const std::vector names; - BOOST_FOREACH(const Endpoint::Ptr& endpoint, zone->GetEndpoints()) + for (const Endpoint::Ptr& endpoint : zone->GetEndpoints()) if (endpoint->GetConnected() || endpoint->GetName() == GetIdentity()) names.push_back(endpoint->GetName()); @@ -503,10 +503,10 @@ void ApiListener::ApiTimerHandler(void) Utility::Glob(GetApiDir() + "log/*", boost::bind(&ApiListener::LogGlobHandler, boost::ref(files), _1), GlobFile); std::sort(files.begin(), files.end()); - BOOST_FOREACH(int ts, files) { + for (int ts : files) { bool need = false; - BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType()) { + for (const Endpoint::Ptr& endpoint : ConfigType::GetObjectsByType()) { if (endpoint == GetLocalEndpoint()) continue; @@ -527,7 +527,7 @@ void ApiListener::ApiTimerHandler(void) } } - BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType()) { + for (const Endpoint::Ptr& endpoint : ConfigType::GetObjectsByType()) { if (!endpoint->GetConnected()) continue; @@ -546,12 +546,12 @@ void ApiListener::ApiTimerHandler(void) double maxTs = 0; - BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) { + for (const JsonRpcConnection::Ptr& client : endpoint->GetClients()) { if (client->GetTimestamp() > maxTs) maxTs = client->GetTimestamp(); } - BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) { + for (const JsonRpcConnection::Ptr& client : endpoint->GetClients()) { if (client->GetTimestamp() != maxTs) client->Disconnect(); else @@ -569,7 +569,7 @@ void ApiListener::ApiReconnectTimerHandler(void) { Zone::Ptr my_zone = Zone::GetLocalZone(); - BOOST_FOREACH(const Zone::Ptr& zone, ConfigType::GetObjectsByType()) { + for (const Zone::Ptr& zone : ConfigType::GetObjectsByType()) { /* don't connect to global zones */ if (zone->GetGlobal()) continue; @@ -582,7 +582,7 @@ void ApiListener::ApiReconnectTimerHandler(void) continue; } - BOOST_FOREACH(const Endpoint::Ptr& endpoint, zone->GetEndpoints()) { + for (const Endpoint::Ptr& endpoint : zone->GetEndpoints()) { /* don't connect to ourselves */ if (endpoint == GetLocalEndpoint()) { Log(LogDebug, "ApiListener") @@ -626,7 +626,7 @@ void ApiListener::ApiReconnectTimerHandler(void) << "Current zone master: " << master->GetName(); std::vector names; - BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType()) + for (const Endpoint::Ptr& endpoint : ConfigType::GetObjectsByType()) if (endpoint->GetConnected()) names.push_back(endpoint->GetName() + " (" + Convert::ToString(endpoint->GetClients().size()) + ")"); @@ -685,12 +685,12 @@ void ApiListener::SyncSendMessage(const Endpoint::Ptr& endpoint, const Dictionar double maxTs = 0; - BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) { + for (const JsonRpcConnection::Ptr& client : endpoint->GetClients()) { if (client->GetTimestamp() > maxTs) maxTs = client->GetTimestamp(); } - BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) { + for (const JsonRpcConnection::Ptr& client : endpoint->GetClients()) { if (client->GetTimestamp() != maxTs) continue; @@ -715,7 +715,7 @@ bool ApiListener::RelayMessageOne(const Zone::Ptr& targetZone, const MessageOrig bool relayed = false, log_needed = false, log_done = false; - BOOST_FOREACH(const Endpoint::Ptr& endpoint, targetZone->GetEndpoints()) { + for (const Endpoint::Ptr& endpoint : targetZone->GetEndpoints()) { /* don't relay messages to ourselves */ if (endpoint == GetLocalEndpoint()) continue; @@ -764,7 +764,7 @@ bool ApiListener::RelayMessageOne(const Zone::Ptr& targetZone, const MessageOrig if (!skippedEndpoints.empty()) { double ts = message->Get("ts"); - BOOST_FOREACH(const Endpoint::Ptr& endpoint, skippedEndpoints) + for (const Endpoint::Ptr& endpoint : skippedEndpoints) endpoint->SetLocalLogPosition(ts); } @@ -799,7 +799,7 @@ void ApiListener::SyncRelayMessage(const MessageOrigin::Ptr& origin, bool need_log = !RelayMessageOne(target_zone, origin, message, master); - BOOST_FOREACH(const Zone::Ptr& zone, target_zone->GetAllParents()) { + for (const Zone::Ptr& zone : target_zone->GetAllParents()) { if (!RelayMessageOne(zone, origin, message, master)) need_log = true; } @@ -919,7 +919,7 @@ void ApiListener::ReplayLog(const JsonRpcConnection::Ptr& client) Utility::Glob(GetApiDir() + "log/*", boost::bind(&ApiListener::LogGlobHandler, boost::ref(files), _1), GlobFile); std::sort(files.begin(), files.end()); - BOOST_FOREACH(int ts, files) { + for (int ts : files) { String path = GetApiDir() + "log/" + Convert::ToString(ts); if (ts < peer_ts) @@ -1031,7 +1031,7 @@ void ApiListener::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& per stats = listener->GetStatus(); ObjectLock olock(stats.second); - BOOST_FOREACH(const Dictionary::Pair& kv, stats.second) + for (const Dictionary::Pair& kv : stats.second) perfdata->Add("'api_" + kv.first + "'=" + Convert::ToString(kv.second)); status->Set("api", stats.first); @@ -1053,7 +1053,7 @@ std::pair ApiListener::GetStatus(void) Dictionary::Ptr connectedZones = new Dictionary(); - BOOST_FOREACH(const Zone::Ptr& zone, ConfigType::GetObjectsByType()) { + for (const Zone::Ptr& zone : ConfigType::GetObjectsByType()) { /* only check endpoints in a) the same zone b) our parent zone c) immediate child zones */ if (my_zone != zone && my_zone != zone->GetParent() && zone != my_zone->GetParent()) { Log(LogDebug, "ApiListener") @@ -1067,7 +1067,7 @@ std::pair ApiListener::GetStatus(void) Array::Ptr zoneEndpoints = new Array(); - BOOST_FOREACH(const Endpoint::Ptr& endpoint, zone->GetEndpoints()) { + for (const Endpoint::Ptr& endpoint : zone->GetEndpoints()) { zoneEndpoints->Add(endpoint->GetName()); if (endpoint->GetName() == GetIdentity()) diff --git a/lib/remote/apiuser.cpp b/lib/remote/apiuser.cpp index 0a01b83b7..35375073c 100644 --- a/lib/remote/apiuser.cpp +++ b/lib/remote/apiuser.cpp @@ -27,7 +27,7 @@ REGISTER_TYPE(ApiUser); ApiUser::Ptr ApiUser::GetByClientCN(const String& cn) { - BOOST_FOREACH(const ApiUser::Ptr& user, ConfigType::GetObjectsByType()) { + for (const ApiUser::Ptr& user : ConfigType::GetObjectsByType()) { if (user->GetClientCN() == cn) return user; } diff --git a/lib/remote/authority.cpp b/lib/remote/authority.cpp index 5a26090e0..daca94ab5 100644 --- a/lib/remote/authority.cpp +++ b/lib/remote/authority.cpp @@ -21,7 +21,6 @@ #include "remote/apilistener.hpp" #include "base/configtype.hpp" #include "base/utility.hpp" -#include using namespace icinga; @@ -42,7 +41,7 @@ void ApiListener::UpdateObjectAuthority(void) int num_total = 0; - BOOST_FOREACH(const Endpoint::Ptr& endpoint, my_zone->GetEndpoints()) { + for (const Endpoint::Ptr& endpoint : my_zone->GetEndpoints()) { num_total++; if (endpoint != my_endpoint && !endpoint->GetConnected()) @@ -59,13 +58,13 @@ void ApiListener::UpdateObjectAuthority(void) std::sort(endpoints.begin(), endpoints.end(), ObjectNameLessComparer); } - BOOST_FOREACH(const Type::Ptr& type, Type::GetAllTypes()) { + for (const Type::Ptr& type : Type::GetAllTypes()) { ConfigType *dtype = dynamic_cast(type.get()); if (!dtype) continue; - BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) { + for (const ConfigObject::Ptr& object : dtype->GetObjects()) { if (!object->IsActive() || object->GetHAMode() != HARunOnce) continue; diff --git a/lib/remote/configobjectutility.cpp b/lib/remote/configobjectutility.cpp index 107caa4d1..f14b68096 100644 --- a/lib/remote/configobjectutility.cpp +++ b/lib/remote/configobjectutility.cpp @@ -71,7 +71,7 @@ String ConfigObjectUtility::CreateObjectConfig(const Type::Ptr& type, const Stri attrs->CopyTo(allAttrs); ObjectLock olock(attrs); - BOOST_FOREACH(const Dictionary::Pair& kv, attrs) { + for (const Dictionary::Pair& kv : attrs) { int fid = type->GetFieldId(kv.first.SubStr(0, kv.first.FindFirstOf("."))); if (fid < 0) @@ -143,7 +143,7 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full << boost::errinfo_file_name(path)); } - BOOST_FOREACH(const boost::exception_ptr& ex, upq.GetExceptions()) { + for (const boost::exception_ptr& ex : upq.GetExceptions()) { errors->Add(DiagnosticInformation(ex)); } } @@ -183,7 +183,7 @@ bool ConfigObjectUtility::DeleteObjectHelper(const ConfigObject::Ptr& object, bo return false; } - BOOST_FOREACH(const Object::Ptr& pobj, parents) { + for (const Object::Ptr& pobj : parents) { ConfigObject::Ptr parentObj = dynamic_pointer_cast(pobj); if (!parentObj) diff --git a/lib/remote/configpackageshandler.cpp b/lib/remote/configpackageshandler.cpp index dde0350f9..6663e4646 100644 --- a/lib/remote/configpackageshandler.cpp +++ b/lib/remote/configpackageshandler.cpp @@ -53,7 +53,7 @@ void ConfigPackagesHandler::HandleGet(const ApiUser::Ptr& user, HttpRequest& req Array::Ptr results = new Array(); - BOOST_FOREACH(const String& package, packages) { + for (const String& package : packages) { Dictionary::Ptr packageInfo = new Dictionary(); packageInfo->Set("name", package); packageInfo->Set("stages", Array::FromVector(ConfigPackageUtility::GetStages(package))); diff --git a/lib/remote/configpackageutility.cpp b/lib/remote/configpackageutility.cpp index 465c500ba..7b74e03b4 100644 --- a/lib/remote/configpackageutility.cpp +++ b/lib/remote/configpackageutility.cpp @@ -22,7 +22,6 @@ #include "base/exception.hpp" #include "base/scriptglobal.hpp" #include "base/utility.hpp" -#include "boost/foreach.hpp" #include #include #include @@ -96,7 +95,7 @@ String ConfigPackageUtility::CreateStage(const String& packageName, const Dictio if (files) { ObjectLock olock(files); - BOOST_FOREACH(const Dictionary::Pair& kv, files) { + for (const Dictionary::Pair& kv : files) { if (ContainsDotDot(kv.first)) { foundDotDot = true; break; @@ -292,7 +291,7 @@ bool ConfigPackageUtility::ContainsDotDot(const String& path) std::vector tokens; boost::algorithm::split(tokens, path, boost::is_any_of("/\\")); - BOOST_FOREACH(const String& part, tokens) { + for (const String& part : tokens) { if (part == "..") return true; } diff --git a/lib/remote/configstageshandler.cpp b/lib/remote/configstageshandler.cpp index 390a176d2..fcb71411a 100644 --- a/lib/remote/configstageshandler.cpp +++ b/lib/remote/configstageshandler.cpp @@ -23,7 +23,6 @@ #include "remote/filterutility.hpp" #include "base/application.hpp" #include "base/exception.hpp" -#include #include using namespace icinga; @@ -73,7 +72,7 @@ void ConfigStagesHandler::HandleGet(const ApiUser::Ptr& user, HttpRequest& reque String prefixPath = ConfigPackageUtility::GetPackageDir() + "/" + packageName + "/" + stageName + "/"; typedef std::pair kv_pair; - BOOST_FOREACH(const kv_pair& kv, paths) { + for (const kv_pair& kv : paths) { Dictionary::Ptr stageInfo = new Dictionary(); stageInfo->Set("type", (kv.second ? "directory" : "file")); stageInfo->Set("name", kv.first.SubStr(prefixPath.GetLength())); diff --git a/lib/remote/consolehandler.cpp b/lib/remote/consolehandler.cpp index d7b1321c6..69e7698b7 100644 --- a/lib/remote/consolehandler.cpp +++ b/lib/remote/consolehandler.cpp @@ -48,12 +48,12 @@ static void ScriptFrameCleanupHandler(void) typedef std::pair KVPair; - BOOST_FOREACH(const KVPair& kv, l_ApiScriptFrames) { + for (const KVPair& kv : l_ApiScriptFrames) { if (kv.second.Seen < Utility::GetTime() - 1800) cleanup_keys.push_back(kv.first); } - BOOST_FOREACH(const String& key, cleanup_keys) + for (const String& key : cleanup_keys) l_ApiScriptFrames.erase(key); } @@ -226,7 +226,7 @@ static void AddSuggestions(std::vector& matches, const String& word, con Dictionary::Ptr dict = value; ObjectLock olock(dict); - BOOST_FOREACH(const Dictionary::Pair& kv, dict) { + for (const Dictionary::Pair& kv : dict) { AddSuggestion(matches, word, prefix + kv.first); } } @@ -246,7 +246,7 @@ static void AddSuggestions(std::vector& matches, const String& word, con if (dict) { ObjectLock olock(dict); - BOOST_FOREACH(const Dictionary::Pair& kv, dict) { + for (const Dictionary::Pair& kv : dict) { AddSuggestion(matches, word, prefix + kv.first); } } @@ -260,20 +260,20 @@ std::vector ConsoleHandler::GetAutocompletionSuggestions(const String& w { std::vector matches; - BOOST_FOREACH(const String& keyword, ConfigWriter::GetKeywords()) { + for (const String& keyword : ConfigWriter::GetKeywords()) { AddSuggestion(matches, word, keyword); } { ObjectLock olock(frame.Locals); - BOOST_FOREACH(const Dictionary::Pair& kv, frame.Locals) { + for (const Dictionary::Pair& kv : frame.Locals) { AddSuggestion(matches, word, kv.first); } } { ObjectLock olock(ScriptGlobal::GetGlobals()); - BOOST_FOREACH(const Dictionary::Pair& kv, ScriptGlobal::GetGlobals()) { + for (const Dictionary::Pair& kv : ScriptGlobal::GetGlobals()) { AddSuggestion(matches, word, kv.first); } } @@ -281,7 +281,7 @@ std::vector ConsoleHandler::GetAutocompletionSuggestions(const String& w { Array::Ptr imports = ScriptFrame::GetImports(); ObjectLock olock(imports); - BOOST_FOREACH(const Value& import, imports) { + for (const Value& import : imports) { AddSuggestions(matches, word, "", false, import); } } diff --git a/lib/remote/deleteobjecthandler.cpp b/lib/remote/deleteobjecthandler.cpp index 4e3356187..bbf08e16c 100644 --- a/lib/remote/deleteobjecthandler.cpp +++ b/lib/remote/deleteobjecthandler.cpp @@ -76,7 +76,7 @@ bool DeleteObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r bool success = true; - BOOST_FOREACH(const ConfigObject::Ptr& obj, objs) { + for (const ConfigObject::Ptr& obj : objs) { Dictionary::Ptr result1 = new Dictionary(); result1->Set("type", type->GetName()); result1->Set("name", obj->GetName()); diff --git a/lib/remote/endpoint.cpp b/lib/remote/endpoint.cpp index e90e15042..af9959473 100644 --- a/lib/remote/endpoint.cpp +++ b/lib/remote/endpoint.cpp @@ -26,7 +26,6 @@ #include "base/utility.hpp" #include "base/exception.hpp" #include "base/convert.hpp" -#include using namespace icinga; diff --git a/lib/remote/eventqueue.cpp b/lib/remote/eventqueue.cpp index 2b502e329..0e08265f5 100644 --- a/lib/remote/eventqueue.cpp +++ b/lib/remote/eventqueue.cpp @@ -50,7 +50,7 @@ void EventQueue::ProcessEvent(const Dictionary::Ptr& event) boost::mutex::scoped_lock lock(m_Mutex); typedef std::pair > kv_pair; - BOOST_FOREACH(kv_pair& kv, m_Events) { + for (kv_pair& kv : m_Events) { kv.second.push_back(event); } @@ -121,7 +121,7 @@ std::vector EventQueue::GetQueuesForType(const String& type) std::vector availQueues; typedef std::pair kv_pair; - BOOST_FOREACH(const kv_pair& kv, queues) { + for (const kv_pair& kv : queues) { if (kv.second->CanProcessEvent(type)) availQueues.push_back(kv.second); } diff --git a/lib/remote/eventshandler.cpp b/lib/remote/eventshandler.cpp index 9129b625d..d782a8088 100644 --- a/lib/remote/eventshandler.cpp +++ b/lib/remote/eventshandler.cpp @@ -24,7 +24,6 @@ #include "config/expression.hpp" #include "base/objectlock.hpp" #include "base/json.hpp" -#include #include using namespace icinga; @@ -53,7 +52,7 @@ bool EventsHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request { ObjectLock olock(types); - BOOST_FOREACH(const String& type, types) { + for (const String& type : types) { FilterUtility::CheckPermission(user, "events/" + type); } } diff --git a/lib/remote/filterutility.cpp b/lib/remote/filterutility.cpp index 759cb4663..2859ade64 100644 --- a/lib/remote/filterutility.cpp +++ b/lib/remote/filterutility.cpp @@ -24,7 +24,6 @@ #include "base/json.hpp" #include "base/configtype.hpp" #include "base/logger.hpp" -#include #include using namespace icinga; @@ -34,7 +33,7 @@ Type::Ptr FilterUtility::TypeFromPluralName(const String& pluralName) String uname = pluralName; boost::algorithm::to_lower(uname); - BOOST_FOREACH(const Type::Ptr&type, Type::GetAllTypes()) { + for (const Type::Ptr&type : Type::GetAllTypes()) { String pname = type->GetPluralName(); boost::algorithm::to_lower(pname); @@ -51,7 +50,7 @@ void ConfigObjectTargetProvider::FindTargets(const String& type, const boost::fu ConfigType *ctype = dynamic_cast(ptype.get()); if (ctype) { - BOOST_FOREACH(const ConfigObject::Ptr& object, ctype->GetObjects()) { + for (const ConfigObject::Ptr& object : ctype->GetObjects()) { addTarget(object); } } @@ -145,7 +144,7 @@ void FilterUtility::CheckPermission(const ApiUser::Ptr& user, const String& perm Array::Ptr permissions = user->GetPermissions(); if (permissions) { ObjectLock olock(permissions); - BOOST_FOREACH(const Value& item, permissions) { + for (const Value& item : permissions) { String permission; Function::Ptr filter; if (item.IsObjectType()) { @@ -195,7 +194,7 @@ std::vector FilterUtility::GetFilterTargets(const QueryDescription& qd, c ScriptFrame permissionFrame; - BOOST_FOREACH(const String& type, qd.Types) { + for (const String& type : qd.Types) { String attr = type; boost::algorithm::to_lower(attr); @@ -219,7 +218,7 @@ std::vector FilterUtility::GetFilterTargets(const QueryDescription& qd, c Array::Ptr names = query->Get(attr); if (names) { ObjectLock olock(names); - BOOST_FOREACH(const String& name, names) { + for (const String& name : names) { Object::Ptr target = provider->GetTargetByName(type, name); if (!FilterUtility::EvaluateFilter(permissionFrame, permissionFilter, target, variableName)) @@ -257,7 +256,7 @@ std::vector FilterUtility::GetFilterTargets(const QueryDescription& qd, c Dictionary::Ptr filter_vars = query->Get("filter_vars"); if (filter_vars) { ObjectLock olock(filter_vars); - BOOST_FOREACH(const Dictionary::Pair& kv, filter_vars) { + for (const Dictionary::Pair& kv : filter_vars) { uvars->Set(kv.first, kv.second); } } diff --git a/lib/remote/httphandler.cpp b/lib/remote/httphandler.cpp index 041136b47..9d3434731 100644 --- a/lib/remote/httphandler.cpp +++ b/lib/remote/httphandler.cpp @@ -34,7 +34,7 @@ void HttpHandler::Register(const Url::Ptr& url, const HttpHandler::Ptr& handler) Dictionary::Ptr node = m_UrlTree; - BOOST_FOREACH(const String& elem, url->GetPath()) { + for (const String& elem : url->GetPath()) { Dictionary::Ptr children = node->Get("children"); if (!children) { @@ -72,7 +72,7 @@ void HttpHandler::ProcessRequest(const ApiUser::Ptr& user, HttpRequest& request, if (current_handlers) { ObjectLock olock(current_handlers); - BOOST_FOREACH(const HttpHandler::Ptr current_handler, current_handlers) { + for (const HttpHandler::Ptr current_handler : current_handlers) { handlers.push_back(current_handler); } } @@ -105,7 +105,7 @@ void HttpHandler::ProcessRequest(const ApiUser::Ptr& user, HttpRequest& request, } bool processed = false; - BOOST_FOREACH(const HttpHandler::Ptr& handler, handlers) { + for (const HttpHandler::Ptr& handler : handlers) { if (handler->HandleRequest(user, request, response, params)) { processed = true; break; diff --git a/lib/remote/httprequest.cpp b/lib/remote/httprequest.cpp index cc8a1b610..93ce83be1 100644 --- a/lib/remote/httprequest.cpp +++ b/lib/remote/httprequest.cpp @@ -25,7 +25,6 @@ #include #include #include -#include using namespace icinga; @@ -178,7 +177,7 @@ void HttpRequest::FinishHeaders(void) } ObjectLock olock(Headers); - BOOST_FOREACH(const Dictionary::Pair& kv, Headers) + for (const Dictionary::Pair& kv : Headers) { String header = kv.first + ": " + kv.second + "\n"; m_Stream->Write(header.CStr(), header.GetLength()); diff --git a/lib/remote/httpserverconnection.cpp b/lib/remote/httpserverconnection.cpp index 140fbde01..c22d17025 100644 --- a/lib/remote/httpserverconnection.cpp +++ b/lib/remote/httpserverconnection.cpp @@ -239,7 +239,7 @@ void HttpServerConnection::TimeoutTimerHandler(void) { ApiListener::Ptr listener = ApiListener::GetInstance(); - BOOST_FOREACH(const HttpServerConnection::Ptr& client, listener->GetHttpClients()) { + for (const HttpServerConnection::Ptr& client : listener->GetHttpClients()) { client->CheckLiveness(); } } diff --git a/lib/remote/httputility.cpp b/lib/remote/httputility.cpp index 879f86fba..0b5316cc6 100644 --- a/lib/remote/httputility.cpp +++ b/lib/remote/httputility.cpp @@ -20,7 +20,6 @@ #include "remote/httputility.hpp" #include "base/json.hpp" #include "base/logger.hpp" -#include using namespace icinga; @@ -47,7 +46,7 @@ Dictionary::Ptr HttpUtility::FetchRequestParameters(HttpRequest& request) result = new Dictionary(); typedef std::pair > kv_pair; - BOOST_FOREACH(const kv_pair& kv, request.RequestUrl->GetQuery()) { + for (const kv_pair& kv : request.RequestUrl->GetQuery()) { result->Set(kv.first, Array::FromVector(kv.second)); } diff --git a/lib/remote/infohandler.cpp b/lib/remote/infohandler.cpp index 868dcbf54..a117c66e3 100644 --- a/lib/remote/infohandler.cpp +++ b/lib/remote/infohandler.cpp @@ -49,7 +49,7 @@ bool InfoHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request, if (permissions) { ObjectLock olock(permissions); - BOOST_FOREACH(const Value& permission, permissions) { + for (const Value& permission : permissions) { String name; bool hasFilter = false; if (permission.IsObjectType()) { @@ -90,7 +90,7 @@ bool InfoHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request, if (!permInfo.empty()) { body += "Your user has the following permissions:

    "; - BOOST_FOREACH(const String& perm, permInfo) { + for (const String& perm : permInfo) { body += "
  • " + perm + "
  • "; } diff --git a/lib/remote/jsonrpcconnection-heartbeat.cpp b/lib/remote/jsonrpcconnection-heartbeat.cpp index e09162c58..587cb875c 100644 --- a/lib/remote/jsonrpcconnection-heartbeat.cpp +++ b/lib/remote/jsonrpcconnection-heartbeat.cpp @@ -24,7 +24,6 @@ #include "base/configtype.hpp" #include "base/logger.hpp" #include "base/utility.hpp" -#include using namespace icinga; @@ -44,8 +43,8 @@ INITIALIZE_ONCE(StartHeartbeatTimer); void JsonRpcConnection::HeartbeatTimerHandler(void) { - BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType()) { - BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) { + for (const Endpoint::Ptr& endpoint : ConfigType::GetObjectsByType()) { + for (const JsonRpcConnection::Ptr& client : endpoint->GetClients()) { if (client->m_NextHeartbeat != 0 && client->m_NextHeartbeat < Utility::GetTime()) { Log(LogWarning, "JsonRpcConnection") << "Client for endpoint '" << endpoint->GetName() << "' has requested " diff --git a/lib/remote/jsonrpcconnection.cpp b/lib/remote/jsonrpcconnection.cpp index ccc090bd5..d6c1b073c 100644 --- a/lib/remote/jsonrpcconnection.cpp +++ b/lib/remote/jsonrpcconnection.cpp @@ -329,12 +329,12 @@ void JsonRpcConnection::TimeoutTimerHandler(void) { ApiListener::Ptr listener = ApiListener::GetInstance(); - BOOST_FOREACH(const JsonRpcConnection::Ptr& client, listener->GetAnonymousClients()) { + for (const JsonRpcConnection::Ptr& client : listener->GetAnonymousClients()) { client->CheckLiveness(); } - BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType()) { - BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) { + for (const Endpoint::Ptr& endpoint : ConfigType::GetObjectsByType()) { + for (const JsonRpcConnection::Ptr& client : endpoint->GetClients()) { client->CheckLiveness(); } } diff --git a/lib/remote/modifyobjecthandler.cpp b/lib/remote/modifyobjecthandler.cpp index b97a7d176..409559866 100644 --- a/lib/remote/modifyobjecthandler.cpp +++ b/lib/remote/modifyobjecthandler.cpp @@ -72,7 +72,7 @@ bool ModifyObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r Array::Ptr results = new Array(); - BOOST_FOREACH(const ConfigObject::Ptr& obj, objs) { + for (const ConfigObject::Ptr& obj : objs) { Dictionary::Ptr result1 = new Dictionary(); result1->Set("type", type->GetName()); @@ -83,7 +83,7 @@ bool ModifyObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r try { if (attrs) { ObjectLock olock(attrs); - BOOST_FOREACH(const Dictionary::Pair& kv, attrs) { + for (const Dictionary::Pair& kv : attrs) { key = kv.first; obj->ModifyAttribute(kv.first, kv.second); } diff --git a/lib/remote/objectqueryhandler.cpp b/lib/remote/objectqueryhandler.cpp index 85a7c75f1..06684b156 100644 --- a/lib/remote/objectqueryhandler.cpp +++ b/lib/remote/objectqueryhandler.cpp @@ -39,7 +39,7 @@ Dictionary::Ptr ObjectQueryHandler::SerializeObjectAttrs(const Object::Ptr& obje if (isJoin && attrs) { ObjectLock olock(attrs); - BOOST_FOREACH(const String& attr, attrs) { + for (const String& attr : attrs) { if (attr == attrPrefix) { allAttrs = true; break; @@ -56,7 +56,7 @@ Dictionary::Ptr ObjectQueryHandler::SerializeObjectAttrs(const Object::Ptr& obje } } else if (attrs) { ObjectLock olock(attrs); - BOOST_FOREACH(const String& attr, attrs) { + for (const String& attr : attrs) { String userAttr; if (isJoin) { @@ -83,7 +83,7 @@ Dictionary::Ptr ObjectQueryHandler::SerializeObjectAttrs(const Object::Ptr& obje Dictionary::Ptr resultAttrs = new Dictionary(); - BOOST_FOREACH(int& fid, fids) + for (int& fid : fids) { Field field = type->GetFieldInfo(fid); @@ -155,7 +155,7 @@ bool ObjectQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& re if (ujoins) { ObjectLock olock(ujoins); - BOOST_FOREACH(const String& ujoin, ujoins) { + for (const String& ujoin : ujoins) { userJoinAttrs.insert(ujoin.SubStr(0, ujoin.FindFirstOf("."))); } } @@ -172,7 +172,7 @@ bool ObjectQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& re joinAttrs.insert(field.Name); } - BOOST_FOREACH(const ConfigObject::Ptr& obj, objs) { + for (const ConfigObject::Ptr& obj : objs) { Dictionary::Ptr result1 = new Dictionary(); results->Add(result1); @@ -184,12 +184,12 @@ bool ObjectQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& re if (umetas) { ObjectLock olock(umetas); - BOOST_FOREACH(const String& meta, umetas) { + for (const String& meta : umetas) { if (meta == "used_by") { Array::Ptr used_by = new Array(); metaAttrs->Set("used_by", used_by); - BOOST_FOREACH(const Object::Ptr& pobj, DependencyGraph::GetParents((obj))) + for (const Object::Ptr& pobj : DependencyGraph::GetParents((obj))) { ConfigObject::Ptr configObj = dynamic_pointer_cast(pobj); @@ -218,7 +218,7 @@ bool ObjectQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& re Dictionary::Ptr joins = new Dictionary(); result1->Set("joins", joins); - BOOST_FOREACH(const String& joinAttr, joinAttrs) { + for (const String& joinAttr : joinAttrs) { Object::Ptr joinedObj; int fid = type->GetFieldId(joinAttr); diff --git a/lib/remote/statushandler.cpp b/lib/remote/statushandler.cpp index f8966b5f4..e02b87c5a 100644 --- a/lib/remote/statushandler.cpp +++ b/lib/remote/statushandler.cpp @@ -36,7 +36,7 @@ public: const boost::function& addTarget) const override { typedef std::pair kv_pair; - BOOST_FOREACH(const kv_pair& kv, StatsFunctionRegistry::GetInstance()->GetItems()) { + for (const kv_pair& kv : StatsFunctionRegistry::GetInstance()->GetItems()) { addTarget(GetTargetByName("Status", kv.first)); } } diff --git a/lib/remote/templatequeryhandler.cpp b/lib/remote/templatequeryhandler.cpp index 0494b21bd..0645cf4ae 100644 --- a/lib/remote/templatequeryhandler.cpp +++ b/lib/remote/templatequeryhandler.cpp @@ -47,7 +47,7 @@ public: virtual void FindTargets(const String& type, const boost::function& addTarget) const override { - BOOST_FOREACH(const ConfigItem::Ptr& item, ConfigItem::GetItems(type)) { + for (const ConfigItem::Ptr& item : ConfigItem::GetItems(type)) { if (item->IsAbstract()) addTarget(GetTargetForTemplate(item)); } @@ -120,7 +120,7 @@ bool TemplateQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& Array::Ptr results = new Array(); - BOOST_FOREACH(const Dictionary::Ptr& obj, objs) { + for (const Dictionary::Ptr& obj : objs) { results->Add(obj); } diff --git a/lib/remote/typequeryhandler.cpp b/lib/remote/typequeryhandler.cpp index c76cc32f8..e79ed7a1f 100644 --- a/lib/remote/typequeryhandler.cpp +++ b/lib/remote/typequeryhandler.cpp @@ -38,7 +38,7 @@ public: virtual void FindTargets(const String& type, const boost::function& addTarget) const override { - BOOST_FOREACH(const Type::Ptr& target, Type::GetAllTypes()) { + for (const Type::Ptr& target : Type::GetAllTypes()) { addTarget(target); } } @@ -98,7 +98,7 @@ bool TypeQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& requ Array::Ptr results = new Array(); - BOOST_FOREACH(const Type::Ptr& obj, objs) { + for (const Type::Ptr& obj : objs) { Dictionary::Ptr result1 = new Dictionary(); results->Add(result1); @@ -116,7 +116,7 @@ bool TypeQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& requ if (prototype) { ObjectLock olock(prototype); - BOOST_FOREACH(const Dictionary::Pair& kv, prototype) { + for (const Dictionary::Pair& kv : prototype) { prototypeKeys->Add(kv.first); } } diff --git a/lib/remote/url.cpp b/lib/remote/url.cpp index f79b1101e..e9ceac605 100644 --- a/lib/remote/url.cpp +++ b/lib/remote/url.cpp @@ -23,7 +23,6 @@ #include "remote/url.hpp" #include "remote/url-characters.hpp" #include -#include using namespace icinga; @@ -241,7 +240,7 @@ String Url::Format(bool print_credentials) const if (m_Path.empty()) url += "/"; else { - BOOST_FOREACH (const String& segment, m_Path) { + for (const String& segment : m_Path) { url += "/"; url += Utility::EscapeString(segment, ACPATHSEGMENT_ENCODE, false); } @@ -251,7 +250,7 @@ String Url::Format(bool print_credentials) const if (!m_Query.empty()) { typedef std::pair > kv_pair; - BOOST_FOREACH (const kv_pair& kv, m_Query) { + for (const kv_pair& kv : m_Query) { String key = Utility::EscapeString(kv.first, ACQUERY_ENCODE, false); if (param.IsEmpty()) param = "?"; @@ -259,7 +258,7 @@ String Url::Format(bool print_credentials) const param += "&"; String temp; - BOOST_FOREACH (const String s, kv.second) { + for (const String s : kv.second) { if (!temp.IsEmpty()) temp += "&"; @@ -344,7 +343,7 @@ bool Url::ParsePath(const String& path) boost::char_separator sep("/"); boost::tokenizer > tokens(pathStr, sep); - BOOST_FOREACH(const String& token, tokens) { + for (const String& token : tokens) { if (token.IsEmpty()) continue; @@ -366,7 +365,7 @@ bool Url::ParseQuery(const String& query) boost::char_separator sep("&"); boost::tokenizer > tokens(queryStr, sep); - BOOST_FOREACH(const String& token, tokens) { + for (const String& token : tokens) { size_t pHelper = token.Find("="); if (pHelper == 0) @@ -418,8 +417,8 @@ bool Url::ParseFragment(const String& fragment) bool Url::ValidateToken(const String& token, const String& symbols) { - BOOST_FOREACH (const char c, token.CStr()) { - if (symbols.FindFirstOf(c) == String::NPos) + for (const char ch : token) { + if (symbols.FindFirstOf(ch) == String::NPos) return false; } diff --git a/lib/remote/variablequeryhandler.cpp b/lib/remote/variablequeryhandler.cpp index 37409eccd..8cc6f1faf 100644 --- a/lib/remote/variablequeryhandler.cpp +++ b/lib/remote/variablequeryhandler.cpp @@ -51,7 +51,7 @@ public: { Dictionary::Ptr globals = ScriptGlobal::GetGlobals(); ObjectLock olock(globals); - BOOST_FOREACH(const Dictionary::Pair& kv, globals) { + for (const Dictionary::Pair& kv : globals) { addTarget(GetTargetForVar(kv.first, kv.second)); } } @@ -104,7 +104,7 @@ bool VariableQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& Array::Ptr results = new Array(); - BOOST_FOREACH(const Dictionary::Ptr& var, objs) { + for (const Dictionary::Ptr& var : objs) { Dictionary::Ptr result1 = new Dictionary(); results->Add(result1); diff --git a/lib/remote/zone.cpp b/lib/remote/zone.cpp index a9045c33c..d6a6973f9 100644 --- a/lib/remote/zone.cpp +++ b/lib/remote/zone.cpp @@ -22,7 +22,6 @@ #include "remote/jsonrpcconnection.hpp" #include "base/objectlock.hpp" #include "base/logger.hpp" -#include using namespace icinga; @@ -41,7 +40,7 @@ void Zone::OnAllConfigLoaded(void) if (endpoints) { ObjectLock olock(endpoints); - BOOST_FOREACH(const String& endpoint, endpoints) { + for (const String& endpoint : endpoints) { Endpoint::GetByName(endpoint)->SetCachedZone(this); } } @@ -71,7 +70,7 @@ std::set Zone::GetEndpoints(void) const if (endpoints) { ObjectLock olock(endpoints); - BOOST_FOREACH(const String& name, endpoints) { + for (const String& name : endpoints) { Endpoint::Ptr endpoint = Endpoint::GetByName(name); if (!endpoint) diff --git a/test/base-array.cpp b/test/base-array.cpp index f9b424436..61b2043df 100644 --- a/test/base-array.cpp +++ b/test/base-array.cpp @@ -21,7 +21,6 @@ #include "base/objectlock.hpp" #include "base/json.hpp" #include -#include using namespace icinga; @@ -114,7 +113,7 @@ BOOST_AUTO_TEST_CASE(foreach) int n = 0; - BOOST_FOREACH(const Value& item, array) { + for (const Value& item : array) { BOOST_CHECK(n != 0 || item == 7); BOOST_CHECK(n != 1 || item == 2); BOOST_CHECK(n != 2 || item == 5); diff --git a/test/base-dictionary.cpp b/test/base-dictionary.cpp index f847741dc..bd336b4c2 100644 --- a/test/base-dictionary.cpp +++ b/test/base-dictionary.cpp @@ -21,7 +21,6 @@ #include "base/objectlock.hpp" #include "base/json.hpp" #include -#include #include using namespace icinga; @@ -82,7 +81,7 @@ BOOST_AUTO_TEST_CASE(foreach) bool seen_test1 = false, seen_test2 = false; - BOOST_FOREACH(const Dictionary::Pair& kv, dictionary) { + for (const Dictionary::Pair& kv : dictionary) { BOOST_CHECK(kv.first == "test1" || kv.first == "test2"); if (kv.first == "test1") { diff --git a/test/base-fifo.cpp b/test/base-fifo.cpp index a9fe3f924..06385f1b6 100644 --- a/test/base-fifo.cpp +++ b/test/base-fifo.cpp @@ -20,7 +20,6 @@ #include "base/fifo.hpp" #include "base/objectlock.hpp" #include -#include using namespace icinga; diff --git a/test/base-json.cpp b/test/base-json.cpp index 1a901b9fc..3bb70153f 100644 --- a/test/base-json.cpp +++ b/test/base-json.cpp @@ -22,7 +22,6 @@ #include "base/objectlock.hpp" #include "base/json.hpp" #include -#include #include using namespace icinga; diff --git a/test/base-serialize.cpp b/test/base-serialize.cpp index 9931a7751..4373b2ec0 100644 --- a/test/base-serialize.cpp +++ b/test/base-serialize.cpp @@ -24,7 +24,6 @@ #include "base/array.hpp" #include "base/dictionary.hpp" #include -#include #include using namespace icinga; diff --git a/test/base-stream.cpp b/test/base-stream.cpp index a23515934..c093b06e9 100644 --- a/test/base-stream.cpp +++ b/test/base-stream.cpp @@ -20,7 +20,6 @@ #include "base/stdiostream.hpp" #include "base/string.hpp" #include -#include #include using namespace icinga; diff --git a/test/base-string.cpp b/test/base-string.cpp index c12c53864..f61a9382f 100644 --- a/test/base-string.cpp +++ b/test/base-string.cpp @@ -19,7 +19,6 @@ #include "base/string.hpp" #include -#include using namespace icinga; @@ -106,7 +105,7 @@ BOOST_AUTO_TEST_CASE(index) s[0] = 'x'; BOOST_CHECK(s == "xello"); - BOOST_FOREACH(char& ch, s) { + for (char& ch : s) { ch = 'y'; } BOOST_CHECK(s == "yyyyy"); diff --git a/test/base-timer.cpp b/test/base-timer.cpp index 821b29e98..14a39b86f 100644 --- a/test/base-timer.cpp +++ b/test/base-timer.cpp @@ -21,7 +21,6 @@ #include "base/utility.hpp" #include "base/application.hpp" #include -#include using namespace icinga; diff --git a/test/base-type.cpp b/test/base-type.cpp index 996247c97..0c726f4cf 100644 --- a/test/base-type.cpp +++ b/test/base-type.cpp @@ -23,7 +23,6 @@ #include "base/application.hpp" #include "base/type.hpp" #include -#include #include using namespace icinga; diff --git a/test/remote-base64.cpp b/test/remote-base64.cpp index 298bb3996..b0c78cc09 100644 --- a/test/remote-base64.cpp +++ b/test/remote-base64.cpp @@ -19,9 +19,6 @@ #include "remote/base64.hpp" #include -#include - -#include using namespace icinga; @@ -56,7 +53,7 @@ BOOST_AUTO_TEST_CASE(base64) // 1024 chars - BOOST_FOREACH(const String str, clearText) { + for (const String& str : clearText) { String enc = Base64::Encode(str); String dec = Base64::Decode(enc); BOOST_CHECK(str == dec); diff --git a/test/remote-url.cpp b/test/remote-url.cpp index d41c76613..7ba9640d4 100644 --- a/test/remote-url.cpp +++ b/test/remote-url.cpp @@ -20,7 +20,6 @@ #include "base/array.hpp" #include "remote/url.hpp" #include -#include #include using namespace icinga; diff --git a/tools/mkclass/classcompiler.cpp b/tools/mkclass/classcompiler.cpp index 6f88c8751..a4a6cc28c 100644 --- a/tools/mkclass/classcompiler.cpp +++ b/tools/mkclass/classcompiler.cpp @@ -113,8 +113,8 @@ void ClassCompiler::HandleLibrary(const std::string& library, const ClassDebugIn std::string libName = m_Library; std::locale locale; - for (std::string::size_type i = 0; i < libName.size(); i++) - libName[i] = std::toupper(libName[i], locale); + for (auto& ch : libName) + ch = std::toupper(ch, locale); m_Header << "#ifndef I2_" << libName << "_API" << std::endl << "# ifdef I2_" << libName << "_BUILD" << std::endl @@ -215,8 +215,8 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&) std::string libName = m_Library; std::locale locale; - for (std::string::size_type i = 0; i < libName.size(); i++) - libName[i] = std::toupper(libName[i], locale); + for (auto& ch : libName) + ch = std::toupper(ch, locale); apiMacro = "I2_" + libName + "_API "; } @@ -522,7 +522,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&) if (field.Type.ArrayRank > 0) { m_Impl << "\t" << "if (value) {" << std::endl << "\t\t" << "ObjectLock olock(value);" << std::endl - << "\t\t" << "BOOST_FOREACH(const Value& avalue, value) {" << std::endl; + << "\t\t" << "for (const Value& avalue : value) {" << std::endl; } else m_Impl << "\t" << "Value avalue = value;" << std::endl; @@ -863,7 +863,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&) if (it->Type.ArrayRank > 0) { m_Impl << "\t" << "if (oldValue) {" << std::endl << "\t\t" << "ObjectLock olock(oldValue);" << std::endl - << "\t\t" << "BOOST_FOREACH(const String& ref, oldValue) {" << std::endl + << "\t\t" << "for (const String& ref : oldValue) {" << std::endl << "\t\t\t" << "DependencyGraph::RemoveDependency(this, ConfigObject::GetObject"; /* Ew */ @@ -877,7 +877,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&) << "\t" << "}" << std::endl << "\t" << "if (newValue) {" << std::endl << "\t\t" << "ObjectLock olock(newValue);" << std::endl - << "\t\t" << "BOOST_FOREACH(const String& ref, newValue) {" << std::endl + << "\t\t" << "for (const String& ref : newValue) {" << std::endl << "\t\t\t" << "DependencyGraph::AddDependency(this, ConfigObject::GetObject"; /* Ew */ @@ -1066,9 +1066,7 @@ void ClassCompiler::CodeGenValidator(const std::string& name, const std::string& if (validatorType == ValidatorField) { bool required = false; - for (std::vector::size_type i = 0; i < rules.size(); i++) { - const Rule& rule = rules[i]; - + for (const Rule& rule : rules) { if ((rule.Attributes & RARequired) && rule.Pattern == field) { required = true; break; @@ -1094,13 +1092,14 @@ void ClassCompiler::CodeGenValidator(const std::string& name, const std::string& m_Impl << "\t" << "bool known_attribute = false;" << std::endl; bool type_check = false; + int i = 0; - for (std::vector::size_type i = 0; i < rules.size(); i++) { - const Rule& rule = rules[i]; - + for (const Rule& rule : rules) { if (rule.Attributes & RARequired) continue; + i++; + if (validatorType == ValidatorField && rule.Pattern != field) continue; @@ -1160,7 +1159,7 @@ void ClassCompiler::CodeGenValidator(const std::string& name, const std::string& m_Impl << (type_check ? "\t" : "") << "\t\t" << "{" << std::endl << (type_check ? "\t" : "") << "\t\t\t" << "ObjectLock olock(dict);" << std::endl - << (type_check ? "\t" : "") << "\t\t\t" << "BOOST_FOREACH(const Dictionary::Pair& kv, dict) {" << std::endl + << (type_check ? "\t" : "") << "\t\t\t" << "for (const Dictionary::Pair& kv : dict) {" << std::endl << (type_check ? "\t" : "") << "\t\t\t\t" << "const String& akey = kv.first;" << std::endl << (type_check ? "\t" : "") << "\t\t\t\t" << "const Value& avalue = kv.second;" << std::endl; indent = true; @@ -1173,7 +1172,7 @@ void ClassCompiler::CodeGenValidator(const std::string& name, const std::string& m_Impl << (type_check ? "\t" : "") << "\t\t" << "Array::SizeType anum = 0;" << std::endl << (type_check ? "\t" : "") << "\t\t" << "{" << std::endl << (type_check ? "\t" : "") << "\t\t\t" << "ObjectLock olock(arr);" << std::endl - << (type_check ? "\t" : "") << "\t\t\t" << "BOOST_FOREACH(const Value& avalue, arr) {" << std::endl + << (type_check ? "\t" : "") << "\t\t\t" << "for (const Value& avalue : arr) {" << std::endl << (type_check ? "\t" : "") << "\t\t\t\t" << "String akey = Convert::ToString(anum);" << std::endl; indent = true; } else { @@ -1200,9 +1199,7 @@ void ClassCompiler::CodeGenValidator(const std::string& name, const std::string& << (type_check ? "\t" : "") << "\t\t" << "}" << std::endl; } - for (std::vector::size_type i = 0; i < rule.Rules.size(); i++) { - const Rule& srule = rule.Rules[i]; - + for (const Rule& srule : rule.Rules) { if ((srule.Attributes & RARequired) == 0) continue; @@ -1250,12 +1247,14 @@ void ClassCompiler::CodeGenValidator(const std::string& name, const std::string& void ClassCompiler::CodeGenValidatorSubrules(const std::string& name, const std::string& klass, const std::vector& rules) { - for (std::vector::size_type i = 0; i < rules.size(); i++) { - const Rule& rule = rules[i]; + int i = 0; + for (const Rule& rule : rules) { if (rule.Attributes & RARequired) continue; + i++; + if (!rule.Rules.empty()) { ValidatorType subtype; @@ -1390,12 +1389,13 @@ std::string ClassCompiler::BaseName(const std::string& path) std::string ClassCompiler::FileNameToGuardName(const std::string& fname) { std::string result = fname; + std::locale locale; - for (std::string::size_type i = 0; i < result.size(); i++) { - result[i] = toupper(result[i]); + for (auto& ch : result) { + ch = std::toupper(ch, locale); - if (result[i] == '.') - result[i] = '_'; + if (ch == '.') + ch = '_'; } return result; @@ -1426,7 +1426,6 @@ void ClassCompiler::CompileStream(const std::string& path, std::istream& input, << "#include \"base/logger.hpp\"" << std::endl << "#include \"base/function.hpp\"" << std::endl << "#include \"base/configtype.hpp\"" << std::endl - << "#include " << std::endl << "#include " << std::endl << "#ifdef _MSC_VER" << std::endl << "#pragma warning( push )" << std::endl