]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3119] use range based for loop or BOOST_FOREACH
authorRazvan Becheriu <razvan@isc.org>
Fri, 12 Jan 2024 14:31:50 +0000 (16:31 +0200)
committerRazvan Becheriu <razvan@isc.org>
Mon, 22 Jan 2024 15:49:59 +0000 (17:49 +0200)
233 files changed:
src/bin/agent/ca_cfg_mgr.cc
src/bin/agent/ca_process.cc
src/bin/agent/simple_parser.cc
src/bin/agent/tests/ca_command_mgr_unittests.cc
src/bin/d2/tests/d2_cfg_mgr_unittests.cc
src/bin/d2/tests/d2_simple_parser_unittest.cc
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/json_config_parser.cc
src/bin/dhcp4/tests/callout_library_3.cc
src/bin/dhcp4/tests/config_backend_unittest.cc
src/bin/dhcp4/tests/config_parser_unittest.cc
src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/dhcp4_client.cc
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/hooks_unittest.cc
src/bin/dhcp4/tests/shared_network_unittest.cc
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/json_config_parser.cc
src/bin/dhcp6/tests/callout_library_3.cc
src/bin/dhcp6/tests/config_backend_unittest.cc
src/bin/dhcp6/tests/config_parser_unittest.cc
src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
src/bin/dhcp6/tests/dhcp6_client.cc
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
src/bin/dhcp6/tests/dhcp6_test_utils.cc
src/bin/dhcp6/tests/hooks_unittest.cc
src/bin/dhcp6/tests/shared_network_unittest.cc
src/bin/perfdhcp/pkt_transform.cc
src/bin/perfdhcp/stats_mgr.cc
src/bin/perfdhcp/stats_mgr.h
src/bin/perfdhcp/test_control.cc
src/bin/perfdhcp/test_control.h
src/bin/perfdhcp/tests/avalanche_scen_unittest.cc
src/bin/perfdhcp/tests/basic_scen_unittest.cc
src/bin/perfdhcp/tests/perf_socket_unittest.cc
src/bin/perfdhcp/tests/test_control_unittest.cc
src/hooks/dhcp/high_availability/command_creator.cc
src/hooks/dhcp/high_availability/ha_config.cc
src/hooks/dhcp/high_availability/ha_config_parser.cc
src/hooks/dhcp/high_availability/ha_service.cc
src/hooks/dhcp/high_availability/lease_sync_filter.cc
src/hooks/dhcp/high_availability/query_filter.cc
src/hooks/dhcp/high_availability/tests/communication_state_unittest.cc
src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc
src/hooks/dhcp/lease_cmds/lease_cmds.cc
src/hooks/dhcp/lease_cmds/tests/lease_cmds4_unittest.cc
src/hooks/dhcp/lease_cmds/tests/lease_cmds6_unittest.cc
src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.h
src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc
src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc
src/hooks/dhcp/mysql_cb/mysql_cb_impl.h
src/hooks/dhcp/pgsql_cb/pgsql_cb_dhcp4.cc
src/hooks/dhcp/pgsql_cb/pgsql_cb_dhcp6.cc
src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.h
src/hooks/dhcp/stat_cmds/stat_cmds.cc
src/hooks/dhcp/stat_cmds/tests/stat_cmds_unittest.cc
src/hooks/dhcp/user_chk/user.cc
src/hooks/dhcp/user_chk/user_file.cc
src/lib/asiolink/tests/io_address_unittest.cc
src/lib/asiolink/testutils/test_server_unix_socket.cc
src/lib/cc/command_interpreter.cc
src/lib/cc/data.cc
src/lib/cc/simple_parser.cc
src/lib/config/base_command_mgr.cc
src/lib/config/command_mgr.cc
src/lib/config/hooked_command_mgr.cc
src/lib/config/tests/command_mgr_unittests.cc
src/lib/d2srv/d2_cfg_mgr.cc
src/lib/d2srv/d2_config.cc
src/lib/d2srv/d2_config.h
src/lib/d2srv/d2_simple_parser.cc
src/lib/database/database_connection.cc
src/lib/database/tests/dbaccess_parser_unittest.cc
src/lib/dhcp/classify.cc
src/lib/dhcp/duid.h
src/lib/dhcp/duid_factory.cc
src/lib/dhcp/hwaddr.cc
src/lib/dhcp/iface_mgr_bsd.cc
src/lib/dhcp/iface_mgr_linux.cc
src/lib/dhcp/iface_mgr_sun.cc
src/lib/dhcp/libdhcp++.cc
src/lib/dhcp/option4_addrlst.cc
src/lib/dhcp/option6_addrlst.cc
src/lib/dhcp/option6_ia.cc
src/lib/dhcp/option6_iaaddr.cc
src/lib/dhcp/option6_iaprefix.cc
src/lib/dhcp/option_classless_static_route.cc
src/lib/dhcp/option_custom.cc
src/lib/dhcp/option_int.h
src/lib/dhcp/option_int_array.h
src/lib/dhcp/option_opaque_data_tuples.cc
src/lib/dhcp/option_vendor_class.cc
src/lib/dhcp/pkt.cc
src/lib/dhcp/pkt6.cc
src/lib/dhcp/tests/classify_unittest.cc
src/lib/dhcp/tests/iface_mgr_unittest.cc
src/lib/dhcp/tests/libdhcp++_unittest.cc
src/lib/dhcp/tests/option_copy_unittest.cc
src/lib/dhcp/tests/option_definition_unittest.cc
src/lib/dhcp/tests/pkt4_unittest.cc
src/lib/dhcp/tests/pkt6_unittest.cc
src/lib/dhcp/tests/pkt_filter6_test_utils.cc
src/lib/dhcp/testutils/iface_mgr_test_config.cc
src/lib/dhcpsrv/alloc_engine.cc
src/lib/dhcpsrv/cb_ctl_dhcp.h
src/lib/dhcpsrv/cb_ctl_dhcp4.cc
src/lib/dhcpsrv/cb_ctl_dhcp6.cc
src/lib/dhcpsrv/cfg_db_access.cc
src/lib/dhcpsrv/cfg_globals.cc
src/lib/dhcpsrv/cfg_host_operations.cc
src/lib/dhcpsrv/cfg_hosts.cc
src/lib/dhcpsrv/cfg_hosts_util.cc
src/lib/dhcpsrv/cfg_iface.cc
src/lib/dhcpsrv/cfg_mac_source.cc
src/lib/dhcpsrv/cfg_option.cc
src/lib/dhcpsrv/cfg_option.h
src/lib/dhcpsrv/cfg_option_def.cc
src/lib/dhcpsrv/cfg_rsoo.cc
src/lib/dhcpsrv/cfg_shared_networks.h
src/lib/dhcpsrv/cfg_subnets6.cc
src/lib/dhcpsrv/client_class_def.cc
src/lib/dhcpsrv/d2_client_mgr.h
src/lib/dhcpsrv/dhcp4o6_ipc.cc
src/lib/dhcpsrv/host.cc
src/lib/dhcpsrv/host_data_source_factory.cc
src/lib/dhcpsrv/host_mgr.cc
src/lib/dhcpsrv/lease_file_loader.h
src/lib/dhcpsrv/lease_mgr.cc
src/lib/dhcpsrv/lease_mgr_factory.cc
src/lib/dhcpsrv/memfile_lease_mgr.cc
src/lib/dhcpsrv/mysql_host_data_source.cc
src/lib/dhcpsrv/mysql_lease_mgr.cc
src/lib/dhcpsrv/network.cc
src/lib/dhcpsrv/parsers/client_class_def_parser.cc
src/lib/dhcpsrv/parsers/dhcp_parsers.cc
src/lib/dhcpsrv/parsers/dhcp_queue_control_parser.cc
src/lib/dhcpsrv/parsers/duid_config_parser.cc
src/lib/dhcpsrv/parsers/expiration_config_parser.cc
src/lib/dhcpsrv/parsers/host_reservation_parser.cc
src/lib/dhcpsrv/parsers/host_reservations_list_parser.h
src/lib/dhcpsrv/parsers/ifaces_config_parser.cc
src/lib/dhcpsrv/parsers/option_data_parser.cc
src/lib/dhcpsrv/parsers/shared_network_parser.cc
src/lib/dhcpsrv/parsers/shared_networks_list_parser.h
src/lib/dhcpsrv/parsers/simple_parser4.cc
src/lib/dhcpsrv/parsers/simple_parser6.cc
src/lib/dhcpsrv/pgsql_host_data_source.cc
src/lib/dhcpsrv/pgsql_lease_mgr.cc
src/lib/dhcpsrv/pool.cc
src/lib/dhcpsrv/shared_network.cc
src/lib/dhcpsrv/srv_config.cc
src/lib/dhcpsrv/tests/alloc_engine_utils.cc
src/lib/dhcpsrv/tests/cb_ctl_dhcp_unittest.cc
src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc
src/lib/dhcpsrv/tests/cfg_option_def_unittest.cc
src/lib/dhcpsrv/tests/cfg_option_unittest.cc
src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc
src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc
src/lib/dhcpsrv/tests/client_class_def_unittest.cc
src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc
src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc
src/lib/dhcpsrv/tests/host_reservations_list_parser_unittest.cc
src/lib/dhcpsrv/tests/host_unittest.cc
src/lib/dhcpsrv/tests/pool_unittest.cc
src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc
src/lib/dhcpsrv/tests/srv_config_unittest.cc
src/lib/dhcpsrv/tests/subnet_unittest.cc
src/lib/dhcpsrv/tests/timer_mgr_unittest.cc
src/lib/dhcpsrv/testutils/generic_backend_unittest.cc
src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc
src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc
src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc
src/lib/dhcpsrv/testutils/generic_lease_mgr_unittest.cc
src/lib/dhcpsrv/testutils/host_data_source_utils.cc
src/lib/dhcpsrv/testutils/memory_host_data_source.cc
src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.cc
src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.cc
src/lib/dhcpsrv/timer_mgr.cc
src/lib/dhcpsrv/tracking_lease_mgr.cc
src/lib/dns/master_lexer.cc
src/lib/dns/master_loader.cc
src/lib/dns/message.cc
src/lib/dns/name.cc
src/lib/dns/rdata/generic/detail/char_string.cc
src/lib/dns/rdata/generic/dnskey_48.cc
src/lib/dns/rdata/generic/opt_41.cc
src/lib/dns/rdataclass.cc
src/lib/dns/rrset.cc
src/lib/dns/tests/message_unittest.cc
src/lib/dns/tests/name_unittest.cc
src/lib/dns/tests/rdata_nsec_unittest.cc
src/lib/dns/tests/rdata_txt_like_unittest.cc
src/lib/dns/tests/rrset_collection_unittest.cc
src/lib/eval/dependency.cc
src/lib/eval/evaluate.cc
src/lib/hooks/callout_handle.cc
src/lib/hooks/callout_manager.cc
src/lib/hooks/hooks_config.cc
src/lib/hooks/hooks_parser.cc
src/lib/hooks/libinfo.cc
src/lib/hooks/library_handle.cc
src/lib/hooks/library_manager_collection.cc
src/lib/hooks/server_hooks.cc
src/lib/http/connection_pool.cc
src/lib/http/request.cc
src/lib/http/response.cc
src/lib/http/tests/server_client_unittests.cc
src/lib/http/tests/tls_server_unittests.cc
src/lib/log/buffer_appender_impl.cc
src/lib/log/compiler/message.cc
src/lib/log/logger_manager.cc
src/lib/log/logger_manager_impl.cc
src/lib/log/message_initializer.cc
src/lib/process/cb_ctl_base.h
src/lib/process/config_base.cc
src/lib/process/config_ctl_info.cc
src/lib/process/config_ctl_parser.cc
src/lib/process/d_cfg_mgr.cc
src/lib/process/log_parser.cc
src/lib/process/logging_info.cc
src/lib/process/tests/d_cfg_mgr_unittests.cc
src/lib/stats/observation.cc
src/lib/stats/tests/observation_unittest.cc
src/lib/tcp/tcp_connection_pool.cc
src/lib/testutils/user_context_utils.cc
src/lib/util/multi_threading_mgr.cc
src/lib/util/strutil.cc
src/lib/util/strutil.h
src/lib/util/tests/base32hex_unittest.cc
src/lib/util/tests/base64_unittest.cc
src/lib/util/unittests/testdata.cc
src/lib/yang/adaptor_host.cc
src/lib/yang/tests/config_unittests.cc

index f2f8caa92af346a926bb934347655550e0f942e8..cda267f78a1f0e361b47d9eb4188ca03d281d821 100644 (file)
@@ -77,8 +77,8 @@ CtrlAgentCfgMgr::getConfigSummary(const uint32_t /*selection*/) {
     // Finally, print the hook libraries names
     const isc::hooks::HookLibsCollection libs = ctx->getHooksConfig().get();
     s << ", " << libs.size() << " lib(s):";
-    for (auto lib = libs.begin(); lib != libs.end(); ++lib) {
-        s << lib->first << " ";
+    for (auto const& lib : libs) {
+        s << lib.first << " ";
     }
 
     return (s.str());
@@ -163,11 +163,11 @@ CtrlAgentCfgContext::setControlSocketInfo(const ConstElementPtr& control_socket,
 std::string
 CtrlAgentCfgContext::getControlSocketInfoSummary() const {
     std::ostringstream s;
-    for (auto si = ctrl_sockets_.cbegin(); si != ctrl_sockets_.end(); ++si) {
+    for (auto const& si : ctrl_sockets_) {
         if (s.tellp() != 0) {
             s << " ";
         }
-        s << si->first;
+        s << si.first;
     }
 
     if (s.tellp() == 0) {
@@ -200,9 +200,9 @@ CtrlAgentCfgContext::toElement() const {
     ca->set("hooks-libraries", hooks_config_.toElement());
     // Set control-sockets
     ElementPtr control_sockets = Element::createMap();
-    for (auto si = ctrl_sockets_.cbegin(); si != ctrl_sockets_.cend(); ++si) {
-        ConstElementPtr socket = UserContext::toElement(si->second);
-        control_sockets->set(si->first, socket);
+    for (auto const& si : ctrl_sockets_) {
+        ConstElementPtr socket = UserContext::toElement(si.second);
+        control_sockets->set(si.first, socket);
     }
     ca->set("control-sockets", control_sockets);
     // Set Control-agent
index 3a3cebae90cced6e1c4d3bb531a5e71a13a96490..1e42503065b445a31a5c24707003e09cd35d1941 100644 (file)
@@ -201,9 +201,7 @@ CtrlAgentProcess::garbageCollectListeners(size_t leaving) {
     // listeners except the most recently added.
     if (http_listeners_.size() > leaving) {
         // Stop no longer used listeners.
-        for (auto l = http_listeners_.begin();
-             l != http_listeners_.end() - leaving;
-             ++l) {
+        for (auto l = http_listeners_.begin(); l != http_listeners_.end() - leaving; ++l) {
             (*l)->stop();
         }
         // We have stopped listeners but there may be some pending handlers
@@ -215,7 +213,6 @@ CtrlAgentProcess::garbageCollectListeners(size_t leaving) {
     }
 }
 
-
 CtrlAgentCfgMgrPtr
 CtrlAgentProcess::getCtrlAgentCfgMgr() {
     return (boost::dynamic_pointer_cast<CtrlAgentCfgMgr>(getCfgMgr()));
index 9c863656d6904871680150555be89f0dd64af365..b340d4653003c74fb22becade4b615cf22df88ef 100644 (file)
@@ -12,7 +12,6 @@
 #include <hooks/hooks_manager.h>
 #include <hooks/hooks_parser.h>
 #include <http/basic_auth_config.h>
-#include <boost/foreach.hpp>
 
 using namespace isc::data;
 
@@ -147,8 +146,8 @@ AgentSimpleParser::parse(const CtrlAgentCfgContextPtr& ctx,
     ConstElementPtr ctrl_sockets = config->get("control-sockets");
     if (ctrl_sockets) {
         auto const& sockets_map = ctrl_sockets->mapValue();
-        for (auto cs = sockets_map.cbegin(); cs != sockets_map.cend(); ++cs) {
-            ctx->setControlSocketInfo(cs->second, cs->first);
+        for (auto const& cs : sockets_map) {
+            ctx->setControlSocketInfo(cs.second, cs.first);
         }
     }
 
index 939e55f063d17f6e002f5d04708db1626614be8c..6a71a2af81859987fce32d7947ca4ac31e3785c1 100644 (file)
@@ -94,14 +94,14 @@ public:
         std::vector<ElementPtr> answer_list = answer->listValue();
 
         ASSERT_EQ(expected_codes.size(), answer_list.size());
+        size_t count = 0;
         // Check all answers.
-        for (auto ans = answer_list.cbegin(); ans != answer_list.cend();
-             ++ans) {
+        for (auto const& ans : answer_list) {
             ConstElementPtr text;
-            ASSERT_NO_THROW(text = isc::config::parseAnswer(status_code, *ans));
-            EXPECT_EQ(expected_codes[std::distance(answer_list.cbegin(), ans)],
-                      status_code)
+            ASSERT_NO_THROW(text = isc::config::parseAnswer(status_code, ans));
+            EXPECT_EQ(expected_codes[count], status_code)
                 << "answer contains text: " << text->stringValue();
+            count++;
         }
     }
 
index e00afae8403d2a070135ab63e0b2b337dfe1b0b0..aad7e097570885cd302044760fe93b39aef17afa 100644 (file)
@@ -17,7 +17,6 @@
 #include <test_data_files_config.h>
 #include <util/encode/base64.h>
 
-#include <boost/foreach.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <gtest/gtest.h>
 
@@ -583,8 +582,7 @@ TEST_F(D2CfgMgrTest, fullConfig) {
     // NOTE that since prior tests have validated server parsing, we are are
     // assuming that the servers did in fact parse correctly if the correct
     // number of them are there.
-    DdnsDomainMapPair domain_pair;
-    BOOST_FOREACH(domain_pair, (*domains)) {
+    for (auto const& domain_pair : *domains) {
         DdnsDomainPtr domain = domain_pair.second;
         DnsServerInfoStoragePtr servers = domain->getServers();
         count = servers->size();
@@ -606,7 +604,7 @@ TEST_F(D2CfgMgrTest, fullConfig) {
     // NOTE that since prior tests have validated server parsing, we are are
     // assuming that the servers did in fact parse correctly if the correct
     // number of them are there.
-    BOOST_FOREACH(domain_pair, (*domains)) {
+    for (auto const& domain_pair : *domains) {
         DdnsDomainPtr domain = domain_pair.second;
         DnsServerInfoStoragePtr servers = domain->getServers();
         count = servers->size();
@@ -933,7 +931,7 @@ TEST_F(D2CfgMgrTest, configPermutations) {
     //  5. submit JSON for parsing
     isc::data::ConstElementPtr test;
     ASSERT_TRUE(tests->get("test-list"));
-    BOOST_FOREACH(test, tests->get("test-list")->listValue()) {
+    for (auto const& test : tests->get("test-list")->listValue()) {
         // Grab the description.
         std::string description = "<no desc>";
         isc::data::ConstElementPtr elem = test->get("description");
index b236469cb9e27c8f80527c227f4282a5b269f4b3..682908a0831db2235f9d9084f0420d963010b1bd 100644 (file)
@@ -277,7 +277,7 @@ TEST_F(D2SimpleParserTest, globalD2Defaults) {
     EXPECT_EQ(num, 8);
 
     // Let's go over all parameters we have defaults for.
-    BOOST_FOREACH(SimpleDefault deflt, D2SimpleParser::D2_GLOBAL_DEFAULTS) {
+    for (auto const& deflt : D2SimpleParser::D2_GLOBAL_DEFAULTS) {
         ConstElementPtr x;
         ASSERT_NO_THROW(x = empty->get(deflt.name_));
 
@@ -569,7 +569,7 @@ public:
         size_t cnt = 0;
         // We don't use SimpleParser::setListDefaults() as this does
         // not handle sub-lists or sub-maps
-        BOOST_FOREACH(ElementPtr domain, config->listValue()) {
+        for (auto const& domain : config->listValue()) {
             cnt += D2SimpleParser::
                    setDdnsDomainDefaults(domain, D2SimpleParser::
                                                  DDNS_DOMAIN_DEFAULTS);
index 8edef2d542d78dc3f93da3308879d4feb6a1dab0..f9a7ab61ec3d0a3c63df1dbfd7e6699ca758ebce 100644 (file)
@@ -65,6 +65,7 @@
 
 #include <boost/algorithm/string.hpp>
 #include <boost/foreach.hpp>
+#include <boost/range/adaptor/reversed.hpp>
 #include <boost/pointer_cast.hpp>
 #include <boost/shared_ptr.hpp>
 
@@ -402,8 +403,7 @@ Dhcpv4Exchange::setHostIdentifiers(AllocEngine::ClientContext4Ptr context) {
 
     // Collect host identifiers. The identifiers are stored in order of preference.
     // The server will use them in that order to search for host reservations.
-    BOOST_FOREACH(const Host::IdentifierType& id_type,
-                  cfg->getIdentifierTypes()) {
+    for (auto const& id_type : cfg->getIdentifierTypes()) {
         switch (id_type) {
         case Host::IDENT_HWADDR:
             if (context->hwaddr_ && !context->hwaddr_->hwaddr_.empty()) {
@@ -515,9 +515,8 @@ void
 Dhcpv4Exchange::setReservedClientClasses(AllocEngine::ClientContext4Ptr context) {
     if (context->currentHost() && context->query_) {
         const ClientClasses& classes = context->currentHost()->getClientClasses4();
-        for (ClientClasses::const_iterator cclass = classes.cbegin();
-             cclass != classes.cend(); ++cclass) {
-            context->query_->addClass(*cclass);
+        for (auto const& cclass : classes) {
+            context->query_->addClass(cclass);
         }
     }
 }
@@ -587,23 +586,22 @@ void Dhcpv4Exchange::evaluateClasses(const Pkt4Ptr& pkt, bool depend_on_known) {
     const ClientClassDictionaryPtr& dict =
         CfgMgr::instance().getCurrentCfg()->getClientClassDictionary();
     const ClientClassDefListPtr& defs_ptr = dict->getClasses();
-    for (ClientClassDefList::const_iterator it = defs_ptr->cbegin();
-         it != defs_ptr->cend(); ++it) {
+    for (auto const& it : *defs_ptr) {
         // Note second cannot be null
-        const ExpressionPtr& expr_ptr = (*it)->getMatchExpr();
+        const ExpressionPtr& expr_ptr = it->getMatchExpr();
         // Nothing to do without an expression to evaluate
         if (!expr_ptr) {
             continue;
         }
         // Not the right time if only when required
-        if ((*it)->getRequired()) {
+        if (it->getRequired()) {
             continue;
         }
         // Not the right pass.
-        if ((*it)->getDependOnKnown() != depend_on_known) {
+        if (it->getDependOnKnown() != depend_on_known) {
             continue;
         }
-        (*it)->test(pkt, expr_ptr);
+        it->test(pkt, expr_ptr);
     }
 }
 
@@ -664,9 +662,9 @@ void Dhcpv4Srv::setPacketStatisticsDefaults() {
     isc::stats::StatsMgr& stats_mgr = isc::stats::StatsMgr::instance();
 
     // Iterate over set of observed statistics
-    for (auto it = dhcp4_statistics.begin(); it != dhcp4_statistics.end(); ++it) {
+    for (auto const& it : dhcp4_statistics) {
         // Initialize them with default value 0
-        stats_mgr.setValue((*it), static_cast<int64_t>(0));
+        stats_mgr.setValue(it, static_cast<int64_t>(0));
     }
 }
 
@@ -827,7 +825,7 @@ Dhcpv4Srv::selectSubnet4o6(const Pkt4Ptr& query, bool& drop,
 
     // Initialize fields specific to relayed messages.
     if (query6 && !query6->relay_info_.empty()) {
-        BOOST_REVERSE_FOREACH(Pkt6::RelayInfo relay, query6->relay_info_) {
+        for (auto const& relay : boost::adaptors::reverse(query6->relay_info_)) {
             if (!relay.linkaddr_.isV6Zero() &&
                 !relay.linkaddr_.isV6LinkLocal()) {
                 selector.first_relay_linkaddr_ = relay.linkaddr_;
@@ -966,9 +964,8 @@ Dhcpv4Srv::earlyGHRLookup(const Pkt4Ptr& query,
 
             // Add classes from the global reservations.
             const ClientClasses& classes = global_host->getClientClasses4();
-            for (ClientClasses::const_iterator cclass = classes.cbegin();
-                 cclass != classes.cend(); ++cclass) {
-                query->addClass(*cclass);
+            for (auto const& cclass : classes) {
+                query->addClass(cclass);
             }
 
             // Evaluate classes before KNOWN.
@@ -1845,17 +1842,16 @@ Dhcpv4Srv::buildCfgOptionList(Dhcpv4Exchange& ex) {
 
     // Each class in the incoming packet
     const ClientClasses& classes = ex.getQuery()->getClasses();
-    for (ClientClasses::const_iterator cclass = classes.cbegin();
-         cclass != classes.cend(); ++cclass) {
+    for (auto const& cclass : classes) {
         // Find the client class definition for this class
         const ClientClassDefPtr& ccdef = CfgMgr::instance().getCurrentCfg()->
-            getClientClassDictionary()->findClass(*cclass);
+            getClientClassDictionary()->findClass(cclass);
         if (!ccdef) {
             // Not found: the class is built-in or not configured
-            if (!isClientClassBuiltIn(*cclass)) {
+            if (!isClientClassBuiltIn(cclass)) {
                 LOG_DEBUG(dhcp4_logger, DBG_DHCP4_BASIC, DHCP4_CLASS_UNCONFIGURED)
                     .arg(ex.getQuery()->getLabel())
-                    .arg(*cclass);
+                    .arg(cclass);
             }
             // Skip it
             continue;
@@ -1922,22 +1918,20 @@ Dhcpv4Srv::appendRequestedOptions(Dhcpv4Exchange& ex) {
         // Get persistent options.
         const OptionContainerPersistIndex& pidx = opts->get<2>();
         const OptionContainerPersistRange& prange = pidx.equal_range(true);
-        for (OptionContainerPersistIndex::const_iterator desc = prange.first;
-             desc != prange.second; ++desc) {
+        BOOST_FOREACH(auto const& desc, prange) {
             // Add the persistent option code to requested options.
-            if (desc->option_) {
-                uint8_t code = static_cast<uint8_t>(desc->option_->getType());
+            if (desc.option_) {
+                uint8_t code = static_cast<uint8_t>(desc.option_->getType());
                 static_cast<void>(requested_opts.insert(code));
             }
         }
         // Get cancelled options.
         const OptionContainerCancelIndex& cidx = opts->get<5>();
         const OptionContainerCancelRange& crange = cidx.equal_range(true);
-        for (OptionContainerCancelIndex::const_iterator desc = crange.first;
-             desc != crange.second; ++desc) {
+        BOOST_FOREACH(auto const& desc, crange) {
             // Add the cancelled option code to cancelled options.
-            if (desc->option_) {
-                uint8_t code = static_cast<uint8_t>(desc->option_->getType());
+            if (desc.option_) {
+                uint8_t code = static_cast<uint8_t>(desc.option_->getType());
                 static_cast<void>(cancelled_opts.insert(code));
             }
         }
@@ -2024,7 +2018,7 @@ Dhcpv4Srv::appendRequestedOptions(Dhcpv4Exchange& ex) {
         // Iterate on the configured option list
         for (auto const& copts : co_list) {
             for (auto const& desc : copts->getList(DHCP4_OPTION_SPACE,
-                                                        DHO_VIVSO_SUBOPTIONS)) {
+                                                   DHO_VIVSO_SUBOPTIONS)) {
                 if (!desc.option_) {
                     continue;
                 }
@@ -2153,11 +2147,10 @@ Dhcpv4Srv::appendRequestedVendorOptions(Dhcpv4Exchange& ex) {
             // Get persistent options.
             const OptionContainerPersistIndex& pidx = opts->get<2>();
             const OptionContainerPersistRange& prange = pidx.equal_range(true);
-            for (OptionContainerPersistIndex::const_iterator desc = prange.first;
-                 desc != prange.second; ++desc) {
+            BOOST_FOREACH(auto const& desc, prange) {
                 // Add the persistent option code to requested options.
-                if (desc->option_) {
-                    uint8_t code = static_cast<uint8_t>(desc->option_->getType());
+                if (desc.option_) {
+                    uint8_t code = static_cast<uint8_t>(desc.option_->getType());
                     static_cast<void>(requested_opts[vendor_id].insert(code));
                 }
             }
@@ -2165,11 +2158,10 @@ Dhcpv4Srv::appendRequestedVendorOptions(Dhcpv4Exchange& ex) {
             // Get cancelled options.
             const OptionContainerCancelIndex& cidx = opts->get<5>();
             const OptionContainerCancelRange& crange = cidx.equal_range(true);
-            for (OptionContainerCancelIndex::const_iterator desc = crange.first;
-                 desc != crange.second; ++desc) {
+            BOOST_FOREACH(auto const& desc, crange) {
                 // Add the cancelled option code to cancelled options.
-                if (desc->option_) {
-                    uint8_t code = static_cast<uint8_t>(desc->option_->getType());
+                if (desc.option_) {
+                    uint8_t code = static_cast<uint8_t>(desc.option_->getType());
                     static_cast<void>(cancelled_opts.insert(code));
                 }
             }
@@ -2762,9 +2754,9 @@ Dhcpv4Srv::assignLease(Dhcpv4Exchange& ex) {
                 // Among those returned try to find a lease that belongs to
                 // current shared network.
                 while (s) {
-                    for (auto l = leases_client_id.begin(); l != leases_client_id.end(); ++l) {
-                        if ((*l)->subnet_id_ == s->getID()) {
-                            lease = *l;
+                    for (auto const& l : leases_client_id) {
+                        if (l->subnet_id_ == s->getID()) {
+                            lease = l;
                             break;
                         }
                     }
@@ -2790,9 +2782,9 @@ Dhcpv4Srv::assignLease(Dhcpv4Exchange& ex) {
 
                 // Pick one that belongs to a subnet in this shared network.
                 while (s) {
-                    for (auto l = leases_hwaddr.begin(); l != leases_hwaddr.end(); ++l) {
-                        if ((*l)->subnet_id_ == s->getID()) {
-                            lease = *l;
+                    for (auto const& l : leases_hwaddr) {
+                        if (l->subnet_id_ == s->getID()) {
+                            lease = l;
                             break;
                         }
                     }
@@ -3400,10 +3392,13 @@ Dhcpv4Srv::setFixedFields(Dhcpv4Exchange& ex) {
         string sname;
         string filename;
         size_t found_cnt = 0;  // How many fields we have found.
-        for (ClientClasses::const_iterator name = classes.cbegin();
-             name != classes.cend() && found_cnt < 3; ++name) {
+        for (auto const& name : classes) {
+
+            if (found_cnt >= 3) {
+                break;
+            }
 
-            ClientClassDefPtr cl = dict->findClass(*name);
+            ClientClassDefPtr cl = dict->findClass(name);
             if (!cl) {
                 // Let's skip classes that don't have definitions. Currently
                 // these are automatic classes VENDOR_CLASS_something, but there
@@ -4365,11 +4360,10 @@ Dhcpv4Srv::acceptServerId(const Pkt4Ptr& query) const {
 
     // Check if the server identifier is configured at client class level.
     const ClientClasses& classes = query->getClasses();
-    for (ClientClasses::const_iterator cclass = classes.cbegin();
-         cclass != classes.cend(); ++cclass) {
+    for (auto const& cclass : classes) {
         // Find the client class definition for this class
         const ClientClassDefPtr& ccdef = CfgMgr::instance().getCurrentCfg()->
-            getClientClassDictionary()->findClass(*cclass);
+            getClientClassDictionary()->findClass(cclass);
         if (!ccdef) {
             continue;
         }
@@ -4453,17 +4447,15 @@ void Dhcpv4Srv::requiredClassify(Dhcpv4Exchange& ex) {
         subnet->getSharedNetwork(network);
         if (network) {
             const ClientClasses& to_add = network->getRequiredClasses();
-            for (ClientClasses::const_iterator cclass = to_add.cbegin();
-                 cclass != to_add.cend(); ++cclass) {
-                classes.insert(*cclass);
+            for (auto const& cclass : to_add) {
+                classes.insert(cclass);
             }
         }
 
         // Followed by the subnet
         const ClientClasses& to_add = subnet->getRequiredClasses();
-        for(ClientClasses::const_iterator cclass = to_add.cbegin();
-            cclass != to_add.cend(); ++cclass) {
-            classes.insert(*cclass);
+        for (auto const& cclass : to_add) {
+            classes.insert(cclass);
         }
 
         // And finish by the pool
@@ -4476,9 +4468,8 @@ void Dhcpv4Srv::requiredClassify(Dhcpv4Exchange& ex) {
             PoolPtr pool = subnet->getPool(Lease::TYPE_V4, addr, false);
             if (pool) {
                 const ClientClasses& to_add = pool->getRequiredClasses();
-                for (ClientClasses::const_iterator cclass = to_add.cbegin();
-                     cclass != to_add.cend(); ++cclass) {
-                    classes.insert(*cclass);
+                for (auto const& cclass : to_add) {
+                    classes.insert(cclass);
                 }
             }
         }
@@ -4490,19 +4481,18 @@ void Dhcpv4Srv::requiredClassify(Dhcpv4Exchange& ex) {
     // Note getClientClassDictionary() cannot be null
     const ClientClassDictionaryPtr& dict =
         CfgMgr::instance().getCurrentCfg()->getClientClassDictionary();
-    for (ClientClasses::const_iterator cclass = classes.cbegin();
-         cclass != classes.cend(); ++cclass) {
-        const ClientClassDefPtr class_def = dict->findClass(*cclass);
+    for (auto const& cclass : classes) {
+        const ClientClassDefPtr class_def = dict->findClass(cclass);
         if (!class_def) {
             LOG_DEBUG(dhcp4_logger, DBG_DHCP4_BASIC, DHCP4_CLASS_UNDEFINED)
-                .arg(*cclass);
+                .arg(cclass);
             continue;
         }
         const ExpressionPtr& expr_ptr = class_def->getMatchExpr();
         // Nothing to do without an expression to evaluate
         if (!expr_ptr) {
             LOG_DEBUG(dhcp4_logger, DBG_DHCP4_BASIC, DHCP4_CLASS_UNTESTABLE)
-                .arg(*cclass);
+                .arg(cclass);
             continue;
         }
         // Evaluate the expression which can return false (no match),
@@ -4511,22 +4501,22 @@ void Dhcpv4Srv::requiredClassify(Dhcpv4Exchange& ex) {
             bool status = evaluateBool(*expr_ptr, *query);
             if (status) {
                 LOG_INFO(dhcp4_logger, EVAL_RESULT)
-                    .arg(*cclass)
+                    .arg(cclass)
                     .arg("true");
                 // Matching: add the class
-                query->addClass(*cclass);
+                query->addClass(cclass);
             } else {
                 LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, EVAL_RESULT)
-                    .arg(*cclass)
+                    .arg(cclass)
                     .arg("false");
             }
         } catch (const Exception& ex) {
             LOG_ERROR(dhcp4_logger, EVAL_RESULT)
-                .arg(*cclass)
+                .arg(cclass)
                 .arg(ex.what());
         } catch (...) {
             LOG_ERROR(dhcp4_logger, EVAL_RESULT)
-                .arg(*cclass)
+                .arg(cclass)
                 .arg("get exception?");
         }
     }
@@ -4535,16 +4525,15 @@ void Dhcpv4Srv::requiredClassify(Dhcpv4Exchange& ex) {
 void
 Dhcpv4Srv::deferredUnpack(Pkt4Ptr& query) {
     // Iterate on the list of deferred option codes
-    BOOST_FOREACH(const uint16_t& code, query->getDeferredOptions()) {
+    for (auto const& code : query->getDeferredOptions()) {
         OptionDefinitionPtr def;
         // Iterate on client classes
         const ClientClasses& classes = query->getClasses();
-        for (ClientClasses::const_iterator cclass = classes.cbegin();
-             cclass != classes.cend(); ++cclass) {
+        for (auto const& cclass : classes) {
             // Get the client class definition for this class
             const ClientClassDefPtr& ccdef =
                 CfgMgr::instance().getCurrentCfg()->
-                getClientClassDictionary()->findClass(*cclass);
+                getClientClassDictionary()->findClass(cclass);
             // If not found skip it
             if (!ccdef) {
                 continue;
index b26cfc4e05b56f334909dd79b856faa75f6bcd71..a7bf06954ed18754cf02d6ba1310ed5f651ef637 100644 (file)
@@ -45,7 +45,6 @@
 #include <util/strutil.h>
 
 #include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
 
 #include <iomanip>
@@ -157,10 +156,10 @@ public:
         }
 
         // Let's go through all the networks one by one
-        for (auto net = networks->begin(); net != networks->end(); ++net) {
+        for (auto const& net : *networks) {
 
             // For each network go through all the subnets in it.
-            const Subnet4SimpleCollection* subnets = (*net)->getAllSubnets();
+            const Subnet4SimpleCollection* subnets = net->getAllSubnets();
             if (!subnets) {
                 // Shared network without subnets it weird, but we decided to
                 // accept such configurations.
@@ -168,8 +167,8 @@ public:
             }
 
             // For each subnet, add it to a list of regular subnets.
-            for (auto subnet = subnets->begin(); subnet != subnets->end(); ++subnet) {
-                dest->add(*subnet);
+            for (auto const& subnet : *subnets) {
+                dest->add(subnet);
             }
         }
     }
@@ -216,61 +215,61 @@ public:
         std::set<string> names;
 
         // Let's go through all the networks one by one
-        for (auto net = networks.begin(); net != networks.end(); ++net) {
+        for (auto const& net : networks) {
             string txt;
 
             // Let's check if all subnets have either the same interface
             // or don't have the interface specified at all.
-            bool authoritative = (*net)->getAuthoritative();
-            string iface = (*net)->getIface();
+            bool authoritative = net->getAuthoritative();
+            string iface = net->getIface();
 
-            const Subnet4SimpleCollection* subnets = (*net)->getAllSubnets();
+            const Subnet4SimpleCollection* subnets = net->getAllSubnets();
             if (subnets) {
                 // For each subnet, add it to a list of regular subnets.
-                for (auto subnet = subnets->begin(); subnet != subnets->end(); ++subnet) {
-                    if ((*subnet)->getAuthoritative() != authoritative) {
+                for (auto const& subnet : *subnets) {
+                    if (subnet->getAuthoritative() != authoritative) {
                         isc_throw(DhcpConfigError, "Subnet " << boolalpha
-                                  << (*subnet)->toText()
+                                  << subnet->toText()
                                   << " has different authoritative setting "
-                                  << (*subnet)->getAuthoritative()
+                                  << subnet->getAuthoritative()
                                   << " than the shared-network itself: "
                                   << authoritative);
                     }
 
                     if (iface.empty()) {
-                        iface = (*subnet)->getIface();
+                        iface = subnet->getIface();
                         continue;
                     }
 
-                    if ((*subnet)->getIface().empty()) {
+                    if (subnet->getIface().empty()) {
                         continue;
                     }
 
-                    if ((*subnet)->getIface() != iface) {
-                        isc_throw(DhcpConfigError, "Subnet " << (*subnet)->toText()
-                                  << " has specified interface " << (*subnet)->getIface()
+                    if (subnet->getIface() != iface) {
+                        isc_throw(DhcpConfigError, "Subnet " << subnet->toText()
+                                  << " has specified interface " << subnet->getIface()
                                   << ", but earlier subnet in the same shared-network"
                                   << " or the shared-network itself used " << iface);
                     }
 
                     // Let's collect the subnets in case we later find out the
                     // subnet doesn't have a mandatory name.
-                    txt += (*subnet)->toText() + " ";
+                    txt += subnet->toText() + " ";
                 }
             }
 
             // Next, let's check name of the shared network.
-            if ((*net)->getName().empty()) {
+            if (net->getName().empty()) {
                 isc_throw(DhcpConfigError, "Shared-network with subnets "
                           << txt << " is missing mandatory 'name' parameter");
             }
 
             // Is it unique?
-            if (names.find((*net)->getName()) != names.end()) {
+            if (names.find(net->getName()) != names.end()) {
                 isc_throw(DhcpConfigError, "A shared-network with "
-                          "name " << (*net)->getName() << " defined twice.");
+                          "name " << net->getName() << " defined twice.");
             }
-            names.insert((*net)->getName());
+            names.insert(net->getName());
 
         }
     }
@@ -563,8 +562,8 @@ processDhcp4Config(isc::data::ConstElementPtr config_set) {
             HostCollection hosts;
             HostReservationsListParser<HostReservationParser4> parser;
             parser.parse(SUBNET_ID_GLOBAL, reservations, hosts);
-            for (auto h = hosts.begin(); h != hosts.end(); ++h) {
-                srv_config->getCfgHosts()->add(*h);
+            for (auto const& h : hosts) {
+                srv_config->getCfgHosts()->add(h);
             }
         }
 
@@ -607,12 +606,10 @@ processDhcp4Config(isc::data::ConstElementPtr config_set) {
         }
 
         // Make parsers grouping.
-        ConfigPair config_pair;
         const std::map<std::string, ConstElementPtr>& values_map =
             mutable_cfg->mapValue();
 
-        BOOST_FOREACH(config_pair, values_map) {
-
+        for (auto const& config_pair : values_map) {
             parameter_name = config_pair.first;
 
             // These are converted to SimpleParser and are handled already above.
index 6bd0fa35699b43b43a96797cb779a39877b3d566..07faf514454656640ec899d6841569d07ae43367 100644 (file)
@@ -58,8 +58,8 @@ dhcp4_srv_configured(CalloutHandle& handle) {
 
     // Append argument names.
     std::vector<std::string> args = handle.getArgumentNames();
-    for (auto arg = args.begin(); arg != args.end(); ++arg) {
-        if (appendArgument(SRV_CONFIG_MARKER_FILE, arg->c_str()) != 0) {
+    for (auto const& arg : args) {
+        if (appendArgument(SRV_CONFIG_MARKER_FILE, arg.c_str()) != 0) {
             return (1);
         }
     }
index 50101778717611ba4b536d28b47b16533dc2d9f7..82fe4545f16bbb63c481a0321479e13a4de488df 100644 (file)
@@ -23,7 +23,6 @@
 #include <dhcp4/tests/dhcp4_test_utils.h>
 #include <dhcp4/tests/get_config_unittest.h>
 
-#include <boost/foreach.hpp>
 #include <boost/scoped_ptr.hpp>
 
 #include <iostream>
index eb78dbbf768410966930bf02f0075124eb4f43ac..bd5f2b361ffca553bb1d696c84cfc87ddf41db94 100644 (file)
@@ -42,7 +42,6 @@
 #include "dhcp4_test_utils.h"
 #include "get_config_unittest.h"
 
-#include <boost/foreach.hpp>
 #include <boost/scoped_ptr.hpp>
 
 #include <iostream>
@@ -438,8 +437,7 @@ public:
             "    \"subnet\": \"192.0.2.0/24\", "
             "    \"option-data\": [ {";
         bool first = true;
-        typedef std::pair<std::string, std::string> ParamPair;
-        BOOST_FOREACH(ParamPair param, params) {
+        for (auto const& param : params) {
             if (!first) {
                 stream << ", ";
             } else {
@@ -2365,18 +2363,16 @@ TEST_F(Dhcp4ParserTest, badSubnetValues) {
 
     // Iterate over the list of scenarios.  Each should fail to parse with
     // a specific error message.
-    for (auto scenario = scenarios.begin(); scenario != scenarios.end(); ++scenario) {
-        {
-            SCOPED_TRACE((*scenario).description_);
-            ConstElementPtr config;
-            ASSERT_NO_THROW(config = parseDHCP4((*scenario).config_json_))
-                            << "invalid json, broken test";
-            ConstElementPtr status;
-            EXPECT_NO_THROW(status = Dhcpv4SrvTest::configure(*srv_, config));
-            checkResult(status, 1);
-            ASSERT_TRUE(comment_);
-            EXPECT_EQ(comment_->stringValue(), (*scenario).exp_error_msg_);
-        }
+    for (auto const& scenario : scenarios) {
+        SCOPED_TRACE(scenario.description_);
+        ConstElementPtr config;
+        ASSERT_NO_THROW(config = parseDHCP4(scenario.config_json_))
+                        << "invalid json, broken test";
+        ConstElementPtr status;
+        EXPECT_NO_THROW(status = Dhcpv4SrvTest::configure(*srv_, config));
+        checkResult(status, 1);
+        ASSERT_TRUE(comment_);
+        EXPECT_EQ(comment_->stringValue(), scenario.exp_error_msg_);
     }
 }
 
index 14ffe8d4ff612c06f8af6ce0f4ad29bdb5cb3dd4..12f2c3d1f5e4b6f79dad667eed108473a034fc4e 100644 (file)
@@ -667,13 +667,16 @@ TEST_F(CtrlChannelDhcpv4SrvTest, controlChannelStats) {
     // preparing the schema which check if all statistics are set to zero
     std::ostringstream s;
     s << "{ \"arguments\": { ";
-    for (auto st = initial_stats.begin(); st != initial_stats.end();) {
-        s << "\"" << *st << "\": [ [ 0, \"";
-        s << isc::util::clockToText(StatsMgr::instance().getObservation(*st)->getInteger().second);
-        s << "\" ] ]";
-        if (++st != initial_stats.end()) {
+    bool first = true;
+    for (auto const& st : initial_stats) {
+        if (!first) {
             s << ", ";
+        } else {
+            first = false;
         }
+        s << "\"" << st << "\": [ [ 0, \"";
+        s << isc::util::clockToText(StatsMgr::instance().getObservation(st)->getInteger().second);
+        s << "\" ] ]";
     }
     s << " }, \"result\": 0 }";
 
index ae466aa97ae5d898b4edf456ede93cdb4736e9c0..75efdcbe7aae72e757bc524b62724c6ee55cef94 100644 (file)
@@ -137,9 +137,8 @@ Dhcp4Client::appendPRL() {
         // has been specified to be requested.
         OptionUint8ArrayPtr prl(new OptionUint8Array(Option::V4,
                                   DHO_DHCP_PARAMETER_REQUEST_LIST));
-        for (std::set<uint8_t>::const_iterator opt = requested_options_.begin();
-             opt != requested_options_.end(); ++opt) {
-            prl->addValue(*opt);
+        for (auto const& opt : requested_options_) {
+            prl->addValue(opt);
         }
         context_.query_->addOption(prl);
     }
@@ -235,20 +234,18 @@ void
 Dhcp4Client::appendExtraOptions() {
     // If there are any custom options specified, add them all to the message.
     if (!extra_options_.empty()) {
-        for (OptionCollection::iterator opt = extra_options_.begin();
-             opt != extra_options_.end(); ++opt) {
+        for (auto const& opt : extra_options_) {
             // Call base class function so that unittests can add multiple
             // options with the same code.
-            context_.query_->Pkt::addOption(opt->second);
+            context_.query_->Pkt::addOption(opt.second);
         }
     }
 }
 
 void
 Dhcp4Client::appendClasses() {
-    for (ClientClasses::const_iterator cclass = classes_.cbegin();
-         cclass != classes_.cend(); ++cclass) {
-        context_.query_->addClass(*cclass);
+    for (auto const& cclass : classes_) {
+        context_.query_->addClass(cclass);
     }
 }
 
@@ -556,9 +553,8 @@ Dhcp4Client::sendMsg(const Pkt4Ptr& msg) {
     msg_copy->setIndex(iface_index_);
     // Copy classes
     const ClientClasses& classes = msg->getClasses();
-    for (ClientClasses::const_iterator cclass = classes.cbegin();
-         cclass != classes.cend(); ++cclass) {
-        msg_copy->addClass(*cclass);
+    for (auto const& cclass : classes) {
+        msg_copy->addClass(cclass);
     }
     srv_->fakeReceive(msg_copy);
 
index 28d150b34381904b93bccb58f8ae9069954bf0fd..78aa950096933bce24b168287066e58d8043cb5c 100644 (file)
@@ -2898,7 +2898,7 @@ Dhcpv4SrvTest::loadConfigFile(const string& path) {
     removeTlsParameters(hosts);
     hosts = dhcp4->get("hosts-databases");
     if (hosts) {
-        for (auto& host : hosts->listValue()) {
+        for (auto const& host : hosts->listValue()) {
             removeTlsParameters(host);
         }
     }
@@ -2991,7 +2991,7 @@ Dhcpv4SrvTest::checkConfigFiles() {
         "with-ddns.json",
     };
     vector<string> files;
-    for (const string& example : examples) {
+    for (auto const& example : examples) {
         string file = path + "/" + example;
         files.push_back(file);
     }
index 8ee1a8a3dcbf2826e1dbf1bc9d76256665df0422..b30b7d5682e2ecc5cefe86cd53f0b9057e1b0207 100644 (file)
@@ -3371,7 +3371,7 @@ TEST_F(LoadUnloadDhcpv4SrvTest, failLoadIncompatibleLibraries) {
 // Checks if callouts installed on the dhcp4_srv_configured ared indeed called
 // and all the necessary parameters are passed.
 TEST_F(LoadUnloadDhcpv4SrvTest, Dhcpv4SrvConfigured) {
-    for (const string& parameters : vector<string>{
+    for (auto const& parameters : vector<string>{
         "",
         R"(, "parameters": { "mode": "fail-without-error" } )",
         R"(, "parameters": { "mode": "fail-with-error" } )"}) {
index bf5964dc1e5663b853e87e479b46b1e2fe6bb933..6cda3aabf21ae047dc9ff54af744c4dd01dbe6d5 100644 (file)
@@ -1165,10 +1165,9 @@ public:
     Subnet4Ptr getConfiguredSubnet(const IOAddress& address) {
         CfgSubnets4Ptr cfg = CfgMgr::instance().getCurrentCfg()->getCfgSubnets4();
         const Subnet4Collection* subnets = cfg->getAll();
-        for (auto subnet_it = subnets->cbegin(); subnet_it != subnets->cend();
-             ++subnet_it) {
-            if ((*subnet_it)->inRange(address)) {
-                return (*subnet_it);
+        for (auto const& subnet_it : *subnets) {
+            if (subnet_it->inRange(address)) {
+                return (subnet_it);
             }
         }
         return (Subnet4Ptr());
index a7e737958196435baae8238e204555708148f623..b415ed596f9e9b3db3f9893b1d2807e4fd5e5e23 100644 (file)
@@ -63,8 +63,8 @@
 #endif
 #include <dhcpsrv/memfile_lease_mgr.h>
 
-#include <boost/foreach.hpp>
 #include <boost/tokenizer.hpp>
+#include <boost/foreach.hpp>
 #include <boost/algorithm/string/erase.hpp>
 #include <boost/algorithm/string/join.hpp>
 #include <boost/algorithm/string/split.hpp>
@@ -261,9 +261,9 @@ void Dhcpv6Srv::setPacketStatisticsDefaults() {
     isc::stats::StatsMgr& stats_mgr = isc::stats::StatsMgr::instance();
 
     // Iterate over set of observed statistics
-    for (auto it = dhcp6_statistics.begin(); it != dhcp6_statistics.end(); ++it) {
+    for (auto const& it : dhcp6_statistics) {
         // Initialize them with default value 0
-        stats_mgr.setValue((*it), static_cast<int64_t>(0));
+        stats_mgr.setValue(it, static_cast<int64_t>(0));
     }
 }
 
@@ -364,8 +364,7 @@ void
 Dhcpv6Srv::setHostIdentifiers(AllocEngine::ClientContext6& ctx) {
     const ConstCfgHostOperationsPtr cfg =
         CfgMgr::instance().getCurrentCfg()->getCfgHostOperations6();
-    BOOST_FOREACH(const Host::IdentifierType& id_type,
-                  cfg->getIdentifierTypes()) {
+    for (auto const& id_type : cfg->getIdentifierTypes()) {
         switch (id_type) {
         case Host::IDENT_DUID:
             if (ctx.duid_) {
@@ -455,9 +454,8 @@ Dhcpv6Srv::earlyGHRLookup(const Pkt6Ptr& query,
 
             // Add classes from the global reservations.
             const ClientClasses& classes = global_host->getClientClasses6();
-            for (ClientClasses::const_iterator cclass = classes.cbegin();
-                 cclass != classes.cend(); ++cclass) {
-                query->addClass(*cclass);
+            for (auto const& cclass : classes) {
+                query->addClass(cclass);
             }
 
             // Evaluate classes before KNOWN.
@@ -1378,11 +1376,11 @@ Dhcpv6Srv::duidToString(const OptionPtr& opt) {
     OptionBuffer data = opt->getData();
 
     bool colon = false;
-    for (OptionBufferConstIter it = data.begin(); it != data.end(); ++it) {
+    for (auto const& it : data) {
         if (colon) {
             tmp << ":";
         }
-        tmp << hex << setw(2) << setfill('0') << static_cast<uint16_t>(*it);
+        tmp << hex << setw(2) << setfill('0') << static_cast<uint16_t>(it);
         if (!colon) {
             colon = true;
         }
@@ -1452,17 +1450,16 @@ Dhcpv6Srv::buildCfgOptionList(const Pkt6Ptr& question,
 
     // Each class in the incoming packet
     const ClientClasses& classes = question->getClasses();
-    for (ClientClasses::const_iterator cclass = classes.cbegin();
-         cclass != classes.cend(); ++cclass) {
+    for (auto const& cclass : classes) {
         // Find the client class definition for this class
         const ClientClassDefPtr& ccdef = CfgMgr::instance().getCurrentCfg()->
-            getClientClassDictionary()->findClass(*cclass);
+            getClientClassDictionary()->findClass(cclass);
         if (!ccdef) {
             // Not found: the class is built-in or not configured
-            if (!isClientClassBuiltIn(*cclass)) {
+            if (!isClientClassBuiltIn(cclass)) {
                 LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASS_UNCONFIGURED)
                     .arg(question->getLabel())
-                    .arg(*cclass);
+                    .arg(cclass);
             }
             // Skip it
             continue;
@@ -1516,22 +1513,20 @@ Dhcpv6Srv::appendRequestedOptions(const Pkt6Ptr& question, Pkt6Ptr& answer,
         // Get persistent options.
         const OptionContainerPersistIndex& pidx = opts->get<2>();
         const OptionContainerPersistRange& prange = pidx.equal_range(true);
-        for (OptionContainerPersistIndex::const_iterator desc = prange.first;
-             desc != prange.second; ++desc) {
+        BOOST_FOREACH(auto const& desc, prange) {
             // Add the persistent option code to requested options.
-            if (desc->option_) {
-                uint16_t code = desc->option_->getType();
+            if (desc.option_) {
+                uint16_t code = desc.option_->getType();
                 static_cast<void>(requested_opts.insert(code));
             }
         }
         // Get cancelled options.
         const OptionContainerCancelIndex& cidx = opts->get<5>();
         const OptionContainerCancelRange& crange = cidx.equal_range(true);
-        for (OptionContainerCancelIndex::const_iterator desc = crange.first;
-             desc != crange.second; ++desc) {
+        BOOST_FOREACH(auto const& desc, crange) {
             // Add the cancelled option code to the cancelled options.
-            if (desc->option_) {
-                uint16_t code = desc->option_->getType();
+            if (desc.option_) {
+                uint16_t code = desc.option_->getType();
                 static_cast<void>(cancelled_opts.insert(code));
             }
         }
@@ -1741,25 +1736,23 @@ Dhcpv6Srv::appendRequestedVendorOptions(const Pkt6Ptr& question,
             // Get persistent options.
             const OptionContainerPersistIndex& pidx = opts->get<2>();
             const OptionContainerPersistRange& prange = pidx.equal_range(true);
-            for (OptionContainerPersistIndex::const_iterator desc = prange.first;
-                 desc != prange.second; ++desc) {
-                if (!desc->option_) {
+            BOOST_FOREACH(auto const& desc, prange) {
+                if (!desc.option_) {
                     continue;
                 }
                 // Add the persistent option code to requested options
-                uint16_t code = desc->option_->getType();
+                uint16_t code = desc.option_->getType();
                 static_cast<void>(requested_opts[vendor_id].insert(code));
             }
             // Get cancelled options.
             const OptionContainerCancelIndex& cidx = opts->get<5>();
             const OptionContainerCancelRange& crange = cidx.equal_range(true);
-            for (OptionContainerCancelIndex::const_iterator desc = crange.first;
-                 desc != crange.second; ++desc) {
-                if (!desc->option_) {
+            BOOST_FOREACH(auto const& desc, crange) {
+                if (!desc.option_) {
                     continue;
                 }
                 // Add the cancelled option code to cancelled options
-                uint16_t code = desc->option_->getType();
+                uint16_t code = desc.option_->getType();
                 static_cast<void>(cancelled_opts[vendor_id].insert(code));
             }
         }
@@ -2254,22 +2247,21 @@ Dhcpv6Srv::createNameChangeRequests(const Pkt6Ptr& answer,
         // to determine if the changes included changes to the FQDN. If so
         // then we may need to do a CHG_REMOVE.
         bool extended_only = false;
-        for (Lease6Collection::const_iterator l = ctx.currentIA().changed_leases_.begin();
-             l != ctx.currentIA().changed_leases_.end(); ++l) {
+        for (auto const& l : ctx.currentIA().changed_leases_) {
 
-            if ((*l)->addr_ == iaaddr->getAddress()) {
+            if (l->addr_ == iaaddr->getAddress()) {
                 // The address is the same so this must be renewal. If we're not
                 // always updating on renew, then we only renew if DNS info has
                 // changed.
                 if (!ctx.getDdnsParams()->getUpdateOnRenew() &&
-                    ((*l)->hostname_ == opt_fqdn->getDomainName() &&
-                     (*l)->fqdn_fwd_ == do_fwd && (*l)->fqdn_rev_ == do_rev)) {
+                    (l->hostname_ == opt_fqdn->getDomainName() &&
+                     l->fqdn_fwd_ == do_fwd && l->fqdn_rev_ == do_rev)) {
                     extended_only = true;
                 } else {
                     // Queue a CHG_REMOVE of the old data.
                     // NCR will only be created if the lease hostname is not
                     // empty and at least one of the direction flags is true
-                    queueNCR(CHG_REMOVE, *l);
+                    queueNCR(CHG_REMOVE, l);
                 }
 
                 break;
@@ -2317,9 +2309,8 @@ Dhcpv6Srv::getMAC(const Pkt6Ptr& pkt) {
     CfgMACSources mac_sources = CfgMgr::instance().getCurrentCfg()->
         getMACSources().get();
     HWAddrPtr hwaddr;
-    for (CfgMACSources::const_iterator it = mac_sources.begin();
-         it != mac_sources.end(); ++it) {
-        hwaddr = pkt->getMAC(*it);
+    for (auto const& it : mac_sources) {
+        hwaddr = pkt->getMAC(it);
         if (hwaddr) {
             return (hwaddr);
         }
@@ -2537,57 +2528,56 @@ Dhcpv6Srv::assignIA_PD(const Pkt6Ptr& query,
         uint32_t min_preferred_lft = (*leases.begin())->preferred_lft_;
 
         const bool pd_exclude_requested = requestedInORO(query, D6O_PD_EXCLUDE);
-        for (Lease6Collection::iterator l = leases.begin();
-             l != leases.end(); ++l) {
+        for (auto const& l : leases) {
 
             // We have a lease! Let's wrap its content into IA_PD option
             // with IAADDR suboption.
             if (ctx.fake_allocation_) {
                 LOG_INFO(lease6_logger, DHCP6_PD_LEASE_ADVERT)
                     .arg(query->getLabel())
-                    .arg((*l)->addr_.toText())
-                    .arg(static_cast<int>((*l)->prefixlen_))
+                    .arg(l->addr_.toText())
+                    .arg(static_cast<int>(l->prefixlen_))
                     .arg(ia->getIAID());
-            } else if ((*l)->reuseable_valid_lft_ == 0) {
+            } else if (l->reuseable_valid_lft_ == 0) {
                 LOG_INFO(lease6_logger, DHCP6_PD_LEASE_ALLOC)
                     .arg(query->getLabel())
-                    .arg((*l)->addr_.toText())
-                    .arg(static_cast<int>((*l)->prefixlen_))
+                    .arg(l->addr_.toText())
+                    .arg(static_cast<int>(l->prefixlen_))
                     .arg(ia->getIAID())
-                    .arg(Lease::lifetimeToText((*l)->valid_lft_));
+                    .arg(Lease::lifetimeToText(l->valid_lft_));
             } else {
-                (*l)->valid_lft_ = (*l)->reuseable_valid_lft_;
-                (*l)->preferred_lft_ = (*l)->reuseable_preferred_lft_;
+                l->valid_lft_ = l->reuseable_valid_lft_;
+                l->preferred_lft_ = l->reuseable_preferred_lft_;
                 LOG_INFO(lease6_logger, DHCP6_PD_LEASE_REUSE)
                     .arg(query->getLabel())
-                    .arg((*l)->addr_.toText())
-                    .arg(static_cast<int>((*l)->prefixlen_))
+                    .arg(l->addr_.toText())
+                    .arg(static_cast<int>(l->prefixlen_))
                     .arg(ia->getIAID())
-                    .arg(Lease::lifetimeToText((*l)->valid_lft_));
+                    .arg(Lease::lifetimeToText(l->valid_lft_));
 
                 // Increment the reuse statistics.
                 StatsMgr::instance().addValue("v6-ia-pd-lease-reuses", int64_t(1));
-                StatsMgr::instance().addValue(StatsMgr::generateName("subnet", (*l)->subnet_id_,
+                StatsMgr::instance().addValue(StatsMgr::generateName("subnet", l->subnet_id_,
                                                                     "v6-ia-pd-lease-reuses"),
                                             int64_t(1));
             }
 
             // Check for new minimum lease time
-            if (((*l)->preferred_lft_ > 0) && (min_preferred_lft > (*l)->preferred_lft_)) {
-                min_preferred_lft = (*l)->preferred_lft_;
+            if ((l->preferred_lft_ > 0) && (min_preferred_lft > l->preferred_lft_)) {
+                min_preferred_lft = l->preferred_lft_;
             }
 
             boost::shared_ptr<Option6IAPrefix>
-                addr(new Option6IAPrefix(D6O_IAPREFIX, (*l)->addr_,
-                                         (*l)->prefixlen_, (*l)->preferred_lft_,
-                                         (*l)->valid_lft_));
+                addr(new Option6IAPrefix(D6O_IAPREFIX, l->addr_,
+                                         l->prefixlen_, l->preferred_lft_,
+                                         l->valid_lft_));
             ia_rsp->addOption(addr);
 
             if (pd_exclude_requested) {
                 // PD exclude option has been requested via ORO, thus we need to
                 // include it if the pool configuration specifies this option.
                 Pool6Ptr pool = boost::dynamic_pointer_cast<
-                    Pool6>(subnet->getPool(Lease::TYPE_PD, (*l)->addr_));
+                    Pool6>(subnet->getPool(Lease::TYPE_PD, l->addr_));
                 if (pool) {
                     Option6PDExcludePtr pd_exclude_option = pool->getPrefixExcludeOption();
                     if (pd_exclude_option) {
@@ -2660,12 +2650,11 @@ Dhcpv6Srv::extendIA_NA(const Pkt6Ptr& query,
 
     // Extract the addresses that the client is trying to obtain.
     OptionCollection addrs = ia->getOptions();
-    for (OptionCollection::const_iterator it = addrs.begin();
-         it != addrs.end(); ++it) {
-        if (it->second->getType() != D6O_IAADDR) {
+    for (auto const& it : addrs) {
+        if (it.second->getType() != D6O_IAADDR) {
             continue;
         }
-        Option6IAAddrPtr iaaddr = boost::dynamic_pointer_cast<Option6IAAddr>(it->second);
+        Option6IAAddrPtr iaaddr = boost::dynamic_pointer_cast<Option6IAAddr>(it.second);
         if (!iaaddr) {
             // That's weird. Option code was ok, but the object type was not.
             // This should never happen. The only case would be with badly
@@ -2695,82 +2684,80 @@ Dhcpv6Srv::extendIA_NA(const Pkt6Ptr& query,
     uint32_t min_preferred_lft = std::numeric_limits<uint32_t>::max();
 
     // For all leases we have now, add the IAADDR with non-zero lifetimes.
-    for (Lease6Collection::iterator l = leases.begin(); l != leases.end(); ++l) {
-        if ((*l)->reuseable_valid_lft_ == 0) {
+    for (auto const& l : leases) {
+        if (l->reuseable_valid_lft_ == 0) {
             LOG_INFO(lease6_logger, DHCP6_LEASE_RENEW)
                 .arg(query->getLabel())
-                .arg((*l)->addr_.toText())
+                .arg(l->addr_.toText())
                 .arg(ia->getIAID());
         } else {
-            (*l)->valid_lft_ = (*l)->reuseable_valid_lft_;
-            (*l)->preferred_lft_ = (*l)->reuseable_preferred_lft_;
+            l->valid_lft_ = l->reuseable_valid_lft_;
+            l->preferred_lft_ = l->reuseable_preferred_lft_;
             LOG_INFO(lease6_logger, DHCP6_LEASE_REUSE)
                 .arg(query->getLabel())
-                .arg((*l)->addr_.toText())
+                .arg(l->addr_.toText())
                 .arg(ia->getIAID())
-                .arg(Lease::lifetimeToText((*l)->valid_lft_));
+                .arg(Lease::lifetimeToText(l->valid_lft_));
 
             // Increment the reuse statistics.
             StatsMgr::instance().addValue("v6-ia-na-lease-reuses", int64_t(1));
-            StatsMgr::instance().addValue(StatsMgr::generateName("subnet", (*l)->subnet_id_,
+            StatsMgr::instance().addValue(StatsMgr::generateName("subnet", l->subnet_id_,
                                                                  "v6-ia-na-lease-reuses"),
                                           int64_t(1));
         }
 
         Option6IAAddrPtr iaaddr(new Option6IAAddr(D6O_IAADDR,
-                                (*l)->addr_, (*l)->preferred_lft_, (*l)->valid_lft_));
+                                l->addr_, l->preferred_lft_, l->valid_lft_));
         ia_rsp->addOption(iaaddr);
 
         // Check for new minimum lease time
-        if (((*l)->preferred_lft_ > 0) && (min_preferred_lft > (*l)->preferred_lft_)) {
-            min_preferred_lft = (*l)->preferred_lft_;
+        if ((l->preferred_lft_ > 0) && (min_preferred_lft > l->preferred_lft_)) {
+            min_preferred_lft = l->preferred_lft_;
         }
 
         // Now remove this address from the hints list.
-        AllocEngine::Resource hint_type((*l)->addr_);
+        AllocEngine::Resource hint_type(l->addr_);
         hints.erase(std::remove(hints.begin(), hints.end(), hint_type),
                     hints.end());
     }
 
     // For the leases that we just retired, send the addresses with 0 lifetimes.
-    for (Lease6Collection::iterator l = ctx.currentIA().old_leases_.begin();
-         l != ctx.currentIA().old_leases_.end(); ++l) {
+    for (auto const& l : ctx.currentIA().old_leases_) {
 
         // Send an address with zero lifetimes only when this lease belonged to
         // this client. Do not send it when we're reusing an old lease that belonged
         // to someone else.
-        if (equalValues(query->getClientId(), (*l)->duid_)) {
+        if (equalValues(query->getClientId(), l->duid_)) {
             Option6IAAddrPtr iaaddr(new Option6IAAddr(D6O_IAADDR,
-                                                      (*l)->addr_, 0, 0));
+                                                      l->addr_, 0, 0));
             ia_rsp->addOption(iaaddr);
         }
 
         // Now remove this address from the hints list.
-        AllocEngine::Resource hint_type((*l)->addr_);
+        AllocEngine::Resource hint_type(l->addr_);
         hints.erase(std::remove(hints.begin(), hints.end(), hint_type), hints.end());
 
         // If the new FQDN settings have changed for the lease, we need to
         // delete any existing FQDN records for this lease.
-        if (((*l)->hostname_ != ctx.hostname_) || ((*l)->fqdn_fwd_ != ctx.fwd_dns_update_) ||
-            ((*l)->fqdn_rev_ != ctx.rev_dns_update_)) {
+        if ((l->hostname_ != ctx.hostname_) || (l->fqdn_fwd_ != ctx.fwd_dns_update_) ||
+            (l->fqdn_rev_ != ctx.rev_dns_update_)) {
             LOG_DEBUG(ddns6_logger, DBG_DHCP6_DETAIL,
                       DHCP6_DDNS_REMOVE_OLD_LEASE_FQDN)
                 .arg(query->getLabel())
-                .arg((*l)->toText())
+                .arg(l->toText())
                 .arg(ctx.hostname_)
                 .arg(ctx.rev_dns_update_ ? "true" : "false")
                 .arg(ctx.fwd_dns_update_ ? "true" : "false");
 
-            queueNCR(CHG_REMOVE, *l);
+            queueNCR(CHG_REMOVE, l);
         }
     }
 
     // Finally, if there are any addresses requested that we haven't dealt with
     // already, inform the client that he can't have them.
-    for (AllocEngine::HintContainer::const_iterator hint = hints.begin();
-         hint != hints.end(); ++hint) {
+    for (auto const& hint : hints) {
         Option6IAAddrPtr iaaddr(new Option6IAAddr(D6O_IAADDR,
-                                                  hint->getAddress(), 0, 0));
+                                                  hint.getAddress(), 0, 0));
         ia_rsp->addOption(iaaddr);
     }
 
@@ -2848,12 +2835,11 @@ Dhcpv6Srv::extendIA_PD(const Pkt6Ptr& query,
 
     // Extract prefixes that the client is trying to renew.
     OptionCollection addrs = ia->getOptions();
-    for (OptionCollection::const_iterator it = addrs.begin();
-         it != addrs.end(); ++it) {
-        if (it->second->getType() != D6O_IAPREFIX) {
+    for (auto const& it : addrs) {
+        if (it.second->getType() != D6O_IAPREFIX) {
             continue;
         }
-        Option6IAPrefixPtr prf = boost::dynamic_pointer_cast<Option6IAPrefix>(it->second);
+        Option6IAPrefixPtr prf = boost::dynamic_pointer_cast<Option6IAPrefix>(it.second);
         if (!prf) {
             // That's weird. Option code was ok, but the object type was not.
             // This should never happen. The only case would be with badly
@@ -2889,40 +2875,40 @@ Dhcpv6Srv::extendIA_PD(const Pkt6Ptr& query,
     // for calculating T1 and T2.
     uint32_t min_preferred_lft = std::numeric_limits<uint32_t>::max();
 
-    for (Lease6Collection::iterator l = leases.begin(); l != leases.end(); ++l) {
-        if ((*l)->reuseable_valid_lft_ == 0) {
+    for (auto const& l : leases) {
+        if (l->reuseable_valid_lft_ == 0) {
             LOG_INFO(lease6_logger, DHCP6_PD_LEASE_RENEW)
                 .arg(query->getLabel())
-                .arg((*l)->addr_.toText())
-                .arg(static_cast<int>((*l)->prefixlen_))
+                .arg(l->addr_.toText())
+                .arg(static_cast<int>(l->prefixlen_))
                 .arg(ia->getIAID());
         } else {
-            (*l)->valid_lft_ = (*l)->reuseable_valid_lft_;
-            (*l)->preferred_lft_ = (*l)->reuseable_preferred_lft_;
+            l->valid_lft_ = l->reuseable_valid_lft_;
+            l->preferred_lft_ = l->reuseable_preferred_lft_;
             LOG_INFO(lease6_logger, DHCP6_PD_LEASE_REUSE)
                 .arg(query->getLabel())
-                .arg((*l)->addr_.toText())
-                .arg(static_cast<int>((*l)->prefixlen_))
+                .arg(l->addr_.toText())
+                .arg(static_cast<int>(l->prefixlen_))
                 .arg(ia->getIAID())
-                .arg(Lease::lifetimeToText((*l)->valid_lft_));
+                .arg(Lease::lifetimeToText(l->valid_lft_));
 
             // Increment the reuse statistics.
             StatsMgr::instance().addValue("v6-ia-pd-lease-reuses", int64_t(1));
-            StatsMgr::instance().addValue(StatsMgr::generateName("subnet", (*l)->subnet_id_,
+            StatsMgr::instance().addValue(StatsMgr::generateName("subnet", l->subnet_id_,
                                                                  "v6-ia-pd-lease-reuses"),
                                           int64_t(1));
         }
 
         Option6IAPrefixPtr prf(new Option6IAPrefix(D6O_IAPREFIX,
-                               (*l)->addr_, (*l)->prefixlen_,
-                               (*l)->preferred_lft_, (*l)->valid_lft_));
+                               l->addr_, l->prefixlen_,
+                               l->preferred_lft_, l->valid_lft_));
         ia_rsp->addOption(prf);
 
         if (pd_exclude_requested) {
             // PD exclude option has been requested via ORO, thus we need to
             // include it if the pool configuration specifies this option.
             Pool6Ptr pool = boost::dynamic_pointer_cast<
-                Pool6>(subnet->getPool(Lease::TYPE_PD, (*l)->addr_));
+                Pool6>(subnet->getPool(Lease::TYPE_PD, l->addr_));
 
             if (pool) {
                 Option6PDExcludePtr pd_exclude_option = pool->getPrefixExcludeOption();
@@ -2933,46 +2919,44 @@ Dhcpv6Srv::extendIA_PD(const Pkt6Ptr& query,
         }
 
         // Check for new minimum lease time
-        if (((*l)->preferred_lft_ > 0) && ((*l)->preferred_lft_ < min_preferred_lft)) {
-            min_preferred_lft = (*l)->preferred_lft_;
+        if ((l->preferred_lft_ > 0) && (l->preferred_lft_ < min_preferred_lft)) {
+            min_preferred_lft = l->preferred_lft_;
         }
 
         // Now remove this prefix from the hints list.
-        AllocEngine::Resource hint_type((*l)->addr_, (*l)->prefixlen_);
+        AllocEngine::Resource hint_type(l->addr_, l->prefixlen_);
         hints.erase(std::remove(hints.begin(), hints.end(), hint_type),
                     hints.end());
     }
 
     /// For the leases that we just retired, send the prefixes with 0 lifetimes.
-    for (Lease6Collection::iterator l = ctx.currentIA().old_leases_.begin();
-         l != ctx.currentIA().old_leases_.end(); ++l) {
+    for (auto const& l : ctx.currentIA().old_leases_) {
 
         // Send a prefix with zero lifetimes only when this lease belonged to
         // this client. Do not send it when we're reusing an old lease that belonged
         // to someone else.
-        if (equalValues(query->getClientId(), (*l)->duid_)) {
-            Option6IAPrefixPtr prefix(new Option6IAPrefix(D6O_IAPREFIX, (*l)->addr_,
-                                                          (*l)->prefixlen_, 0, 0));
+        if (equalValues(query->getClientId(), l->duid_)) {
+            Option6IAPrefixPtr prefix(new Option6IAPrefix(D6O_IAPREFIX, l->addr_,
+                                                          l->prefixlen_, 0, 0));
             ia_rsp->addOption(prefix);
         }
 
         // Now remove this prefix from the hints list.
-        AllocEngine::Resource hint_type((*l)->addr_, (*l)->prefixlen_);
+        AllocEngine::Resource hint_type(l->addr_, l->prefixlen_);
         hints.erase(std::remove(hints.begin(), hints.end(), hint_type), hints.end());
     }
 
     // Finally, if there are any prefixes requested that we haven't dealt with
     // already, inform the client that he can't have them.
-    for (AllocEngine::HintContainer::const_iterator prefix = hints.begin();
-         prefix != hints.end(); ++prefix) {
+    for (auto const& prefix : hints) {
 
         // Send the prefix with the zero lifetimes only if the prefix
         // contains non-zero value. A zero value indicates that the hint was
         // for the prefix length.
-        if (!prefix->getAddress().isV6Zero()) {
+        if (!prefix.getAddress().isV6Zero()) {
             OptionPtr prefix_opt(new Option6IAPrefix(D6O_IAPREFIX,
-                                                     prefix->getAddress(),
-                                                     prefix->getPrefixLength(),
+                                                     prefix.getAddress(),
+                                                     prefix.getPrefixLength(),
                                                      0, 0));
             ia_rsp->addOption(prefix_opt);
         }
@@ -3741,16 +3725,14 @@ Dhcpv6Srv::processConfirm(AllocEngine::ClientContext6& ctx) {
     // over the IA_NA options to check if they hold any addresses. If there
     // are no, the Confirm is discarded.
     // Check addresses in IA_NA options and make sure they are appropriate.
-    for (OptionCollection::const_iterator ia = ias.begin();
-         ia != ias.end(); ++ia) {
-        const OptionCollection& opts = ia->second->getOptions();
-        for (OptionCollection::const_iterator opt = opts.begin();
-             opt != opts.end(); ++opt) {
+    for (auto const& ia : ias) {
+        const OptionCollection& opts = ia.second->getOptions();
+        for (auto const& opt : opts) {
             // Ignore options other than IAAddr.
-            if (opt->second->getType() == D6O_IAADDR) {
+            if (opt.second->getType() == D6O_IAADDR) {
                 // Check that the address is in range in the subnet selected.
                 Option6IAAddrPtr iaaddr = boost::dynamic_pointer_cast<
-                    Option6IAAddr>(opt->second);
+                    Option6IAAddr>(opt.second);
                 // If there is subnet selected and the address has been included
                 // in IA_NA, mark it verified and verify that it belongs to the
                 // subnet.
@@ -3927,16 +3909,15 @@ Dhcpv6Srv::declineIA(const Pkt6Ptr& decline, const DuidPtr& duid,
 
     const OptionCollection& opts = ia->getOptions();
     int total_addrs = 0; // Let's count the total number of addresses.
-    for (OptionCollection::const_iterator opt = opts.begin(); opt != opts.end();
-         ++opt) {
+    for (auto const& opt : opts) {
 
         // Let's ignore nested options other than IAADDR (there shouldn't be anything
         // else in IA_NA in Decline message, but let's be on the safe side).
-        if (opt->second->getType() != D6O_IAADDR) {
+        if (opt.second->getType() != D6O_IAADDR) {
             continue;
         }
         Option6IAAddrPtr decline_addr = boost::dynamic_pointer_cast<Option6IAAddr>
-            (opt->second);
+            (opt.second);
         if (!decline_addr) {
             continue;
         }
@@ -4243,23 +4224,22 @@ void Dhcpv6Srv::evaluateClasses(const Pkt6Ptr& pkt, bool depend_on_known) {
     const ClientClassDictionaryPtr& dict =
         CfgMgr::instance().getCurrentCfg()->getClientClassDictionary();
     const ClientClassDefListPtr& defs_ptr = dict->getClasses();
-    for (ClientClassDefList::const_iterator it = defs_ptr->cbegin();
-         it != defs_ptr->cend(); ++it) {
+    for (auto const& it : *defs_ptr) {
         // Note second cannot be null
-        const ExpressionPtr& expr_ptr = (*it)->getMatchExpr();
+        const ExpressionPtr& expr_ptr = it->getMatchExpr();
         // Nothing to do without an expression to evaluate
         if (!expr_ptr) {
             continue;
         }
         // Not the right time if only when required
-        if ((*it)->getRequired()) {
+        if (it->getRequired()) {
             continue;
         }
         // Not the right pass.
-        if ((*it)->getDependOnKnown() != depend_on_known) {
+        if (it->getDependOnKnown() != depend_on_known) {
             continue;
         }
-        (*it)->test(pkt, expr_ptr);
+        it->test(pkt, expr_ptr);
     }
 }
 
@@ -4283,9 +4263,8 @@ Dhcpv6Srv::setReservedClientClasses(const Pkt6Ptr& pkt,
                                     const AllocEngine::ClientContext6& ctx) {
     if (ctx.currentHost() && pkt) {
         const ClientClasses& classes = ctx.currentHost()->getClientClasses6();
-        for (ClientClasses::const_iterator cclass = classes.cbegin();
-             cclass != classes.cend(); ++cclass) {
-            pkt->addClass(*cclass);
+        for (auto const& cclass : classes) {
+            pkt->addClass(cclass);
         }
     }
 }
@@ -4317,17 +4296,15 @@ Dhcpv6Srv::requiredClassify(const Pkt6Ptr& pkt, AllocEngine::ClientContext6& ctx
         subnet->getSharedNetwork(network);
         if (network) {
             const ClientClasses& to_add = network->getRequiredClasses();
-            for (ClientClasses::const_iterator cclass = to_add.cbegin();
-                 cclass != to_add.cend(); ++cclass) {
-                classes.insert(*cclass);
+            for (auto const& cclass : to_add) {
+                classes.insert(cclass);
             }
         }
 
         // Followed by the subnet
         const ClientClasses& to_add = subnet->getRequiredClasses();
-        for (ClientClasses::const_iterator cclass = to_add.cbegin();
-             cclass != to_add.cend(); ++cclass) {
-            classes.insert(*cclass);
+        for (auto const& cclass : to_add) {
+            classes.insert(cclass);
         }
 
         // And finish by pools
@@ -4339,9 +4316,8 @@ Dhcpv6Srv::requiredClassify(const Pkt6Ptr& pkt, AllocEngine::ClientContext6& ctx
                                      false);
             if (pool) {
                 const ClientClasses& to_add = pool->getRequiredClasses();
-                for (ClientClasses::const_iterator cclass = to_add.cbegin();
-                     cclass != to_add.cend(); ++cclass) {
-                    classes.insert(*cclass);
+                for (auto const& cclass : to_add) {
+                    classes.insert(cclass);
                 }
             }
         }
@@ -4353,19 +4329,18 @@ Dhcpv6Srv::requiredClassify(const Pkt6Ptr& pkt, AllocEngine::ClientContext6& ctx
     // Note getClientClassDictionary() cannot be null
     const ClientClassDictionaryPtr& dict =
         CfgMgr::instance().getCurrentCfg()->getClientClassDictionary();
-    for (ClientClasses::const_iterator cclass = classes.cbegin();
-         cclass != classes.cend(); ++cclass) {
-        const ClientClassDefPtr class_def = dict->findClass(*cclass);
+    for (auto const& cclass : classes) {
+        const ClientClassDefPtr class_def = dict->findClass(cclass);
         if (!class_def) {
             LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASS_UNDEFINED)
-                .arg(*cclass);
+                .arg(cclass);
             continue;
         }
         const ExpressionPtr& expr_ptr = class_def->getMatchExpr();
         // Nothing to do without an expression to evaluate
         if (!expr_ptr) {
             LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC, DHCP6_CLASS_UNTESTABLE)
-                .arg(*cclass);
+                .arg(cclass);
             continue;
         }
         // Evaluate the expression which can return false (no match),
@@ -4374,22 +4349,22 @@ Dhcpv6Srv::requiredClassify(const Pkt6Ptr& pkt, AllocEngine::ClientContext6& ctx
             bool status = evaluateBool(*expr_ptr, *pkt);
             if (status) {
                 LOG_INFO(dhcp6_logger, EVAL_RESULT)
-                    .arg(*cclass)
+                    .arg(cclass)
                     .arg("true");
                 // Matching: add the class
-                pkt->addClass(*cclass);
+                pkt->addClass(cclass);
             } else {
                 LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, EVAL_RESULT)
-                    .arg(*cclass)
+                    .arg(cclass)
                     .arg("false");
             }
         } catch (const Exception& ex) {
             LOG_ERROR(dhcp6_logger, EVAL_RESULT)
-                .arg(*cclass)
+                .arg(cclass)
                 .arg(ex.what());
         } catch (...) {
             LOG_ERROR(dhcp6_logger, EVAL_RESULT)
-                .arg(*cclass)
+                .arg(cclass)
                 .arg("get exception?");
         }
     }
@@ -4593,14 +4568,13 @@ void Dhcpv6Srv::processRSOO(const Pkt6Ptr& query, const Pkt6Ptr& rsp) {
             // and if it's RSOO-enabled and there's no such option provided yet,
             // copy it to the server's response
             const OptionCollection& rsoo = rsoo_container->getOptions();
-            for (OptionCollection::const_iterator opt = rsoo.begin();
-                 opt != rsoo.end(); ++opt) {
+            for (auto const& opt : rsoo) {
 
                 // Echo option if it is RSOO enabled option and there is no such
                 // option added yet.
-                if (cfg_rsoo->enabled(opt->second->getType()) &&
-                    !rsp->getOption(opt->second->getType())) {
-                    rsp->addOption(opt->second);
+                if (cfg_rsoo->enabled(opt.second->getType()) &&
+                    !rsp->getOption(opt.second->getType())) {
+                    rsp->addOption(opt.second);
                 }
             }
         }
@@ -4802,13 +4776,12 @@ Dhcpv6Srv::checkDynamicSubnetChange(const Pkt6Ptr& question, Pkt6Ptr& answer,
         ((prev_hostname != ctx.hostname_) ||
         (prev_fwd_dns_update != ctx.fwd_dns_update_) ||
         (prev_rev_dns_update != ctx.rev_dns_update_))) {
-        for (Lease6Collection::const_iterator l = ctx.new_leases_.begin();
-            l != ctx.new_leases_.end(); ++l) {
-            (*l)->hostname_ = ctx.hostname_;
-            (*l)->fqdn_fwd_ = ctx.fwd_dns_update_;
-            (*l)->fqdn_rev_ = ctx.rev_dns_update_;
-            (*l)->reuseable_valid_lft_ = 0;
-            LeaseMgrFactory::instance().updateLease6(*l);
+        for (auto const& l : ctx.new_leases_) {
+            l->hostname_ = ctx.hostname_;
+            l->fqdn_fwd_ = ctx.fwd_dns_update_;
+            l->fqdn_rev_ = ctx.rev_dns_update_;
+            l->reuseable_valid_lft_ = 0;
+            LeaseMgrFactory::instance().updateLease6(l);
         }
     }
 }
index 47a8f3f1001328501af0f72357a18e55df5f0831..e39163fe6fce66309008b226df7587d2ce76ebad 100644 (file)
@@ -49,7 +49,6 @@
 #include <util/triplet.h>
 
 #include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <boost/shared_ptr.hpp>
@@ -109,7 +108,7 @@ public:
     /// @param cfg server configuration (RSOO will be stored here)
     void parse(const SrvConfigPtr& cfg, const isc::data::ConstElementPtr& value) {
         try {
-            BOOST_FOREACH(ConstElementPtr source_elem, value->listValue()) {
+            for (auto const& source_elem : value->listValue()) {
                 std::string option_str = source_elem->stringValue();
                 // This option can be either code (integer) or name. Let's try code first
                 int64_t code = 0;
@@ -245,10 +244,10 @@ public:
         }
 
         // Let's go through all the networks one by one
-        for (auto net = networks->begin(); net != networks->end(); ++net) {
+        for (auto const& net : *networks) {
 
             // For each network go through all the subnets in it.
-            const Subnet6SimpleCollection* subnets = (*net)->getAllSubnets();
+            const Subnet6SimpleCollection* subnets = net->getAllSubnets();
             if (!subnets) {
                 // Shared network without subnets it weird, but we decided to
                 // accept such configurations.
@@ -256,8 +255,8 @@ public:
             }
 
             // For each subnet, add it to a list of regular subnets.
-            for (auto subnet = subnets->begin(); subnet != subnets->end(); ++subnet) {
-                dest->add(*subnet);
+            for (auto const& subnet : *subnets) {
+                dest->add(subnet);
             }
         }
     }
@@ -305,75 +304,74 @@ public:
         std::set<string> names;
 
         // Let's go through all the networks one by one
-        for (auto net = networks.begin(); net != networks.end(); ++net) {
+        for (auto const& net : networks) {
             string txt;
 
             // Let's check if all subnets have either the same interface
             // or don't have the interface specified at all.
-            string iface = (*net)->getIface();
+            string iface = net->getIface();
 
-            const Subnet6SimpleCollection* subnets = (*net)->getAllSubnets();
+            const Subnet6SimpleCollection* subnets = net->getAllSubnets();
             if (subnets) {
 
                 bool rapid_commit = false;
 
-                // For each subnet, add it to a list of regular subnets.
-                for (auto subnet = subnets->begin(); subnet != subnets->end(); ++subnet) {
+                // Rapid commit must either be enabled or disabled in all subnets
+                // in the shared network.
+                if (subnets->size()) {
+                    // If this is the first subnet, remember the value.
+                    rapid_commit = (*subnets->begin())->getRapidCommit();
+                }
 
-                    // Rapid commit must either be enabled or disabled in all subnets
-                    // in the shared network.
-                    if (subnet == subnets->begin()) {
-                        // If this is the first subnet, remember the value.
-                        rapid_commit = (*subnet)->getRapidCommit();
-                    } else {
-                        // Ok, this is the second or following subnets. The value
-                        // must match what was set in the first subnet.
-                        if (rapid_commit != (*subnet)->getRapidCommit()) {
-                            isc_throw(DhcpConfigError, "All subnets in a shared network "
-                                      "must have the same rapid-commit value. Subnet "
-                                      << (*subnet)->toText()
-                                      << " has specified rapid-commit "
-                                      << ( (*subnet)->getRapidCommit() ? "true" : "false")
-                                      << ", but earlier subnet in the same shared-network"
-                                      << " or the shared-network itself used rapid-commit "
-                                      << (rapid_commit ? "true" : "false"));
-                        }
+                // For each subnet, add it to a list of regular subnets.
+                for (auto const& subnet : *subnets) {
+                    // Ok, this is the second or following subnets. The value
+                    // must match what was set in the first subnet.
+                    if (rapid_commit != subnet->getRapidCommit()) {
+                        isc_throw(DhcpConfigError, "All subnets in a shared network "
+                                  "must have the same rapid-commit value. Subnet "
+                                  << subnet->toText()
+                                  << " has specified rapid-commit "
+                                  << (subnet->getRapidCommit() ? "true" : "false")
+                                  << ", but earlier subnet in the same shared-network"
+                                  << " or the shared-network itself used rapid-commit "
+                                  << (rapid_commit ? "true" : "false"));
                     }
 
                     if (iface.empty()) {
-                        iface = (*subnet)->getIface();
+                        iface = subnet->getIface();
                         continue;
                     }
 
-                    if ((*subnet)->getIface().empty()) {
+                    if (subnet->getIface().empty()) {
                         continue;
                     }
 
-                    if ((*subnet)->getIface() != iface) {
-                        isc_throw(DhcpConfigError, "Subnet " << (*subnet)->toText()
-                                  << " has specified interface " << (*subnet)->getIface()
+                    if (subnet->getIface() != iface) {
+                        isc_throw(DhcpConfigError, "Subnet " << subnet->toText()
+                                  << " has specified interface " << subnet->getIface()
                                   << ", but earlier subnet in the same shared-network"
                                   << " or the shared-network itself used " << iface);
                     }
 
                     // Let's collect the subnets in case we later find out the
                     // subnet doesn't have a mandatory name.
-                    txt += (*subnet)->toText() + " ";
+                    txt += subnet->toText() + " ";
                 }
             }
 
             // Next, let's check name of the shared network.
-            if ((*net)->getName().empty()) {
+            if (net->getName().empty()) {
                 isc_throw(DhcpConfigError, "Shared-network with subnets "
                           << txt << " is missing mandatory 'name' parameter");
             }
 
             // Is it unique?
-            if (names.find((*net)->getName()) != names.end()) {
+            if (names.find(net->getName()) != names.end()) {
                 isc_throw(DhcpConfigError, "A shared-network with "
-                          "name " << (*net)->getName() << " defined twice.");
+                          "name " << net->getName() << " defined twice.");
             }
-            names.insert((*net)->getName());
+            names.insert(net->getName());
 
         }
     }
@@ -689,8 +687,8 @@ processDhcp6Config(isc::data::ConstElementPtr config_set) {
             HostCollection hosts;
             HostReservationsListParser<HostReservationParser6> parser;
             parser.parse(SUBNET_ID_GLOBAL, reservations, hosts);
-            for (auto h = hosts.begin(); h != hosts.end(); ++h) {
-                srv_config->getCfgHosts()->add(*h);
+            for (auto const& h : hosts) {
+                srv_config->getCfgHosts()->add(h);
             }
         }
 
@@ -731,12 +729,10 @@ processDhcp6Config(isc::data::ConstElementPtr config_set) {
         }
 
         // Make parsers grouping.
-        ConfigPair config_pair;
         const std::map<std::string, ConstElementPtr>& values_map =
             mutable_cfg->mapValue();
 
-        BOOST_FOREACH(config_pair, values_map) {
-
+        for (auto const& config_pair : values_map) {
             parameter_name = config_pair.first;
 
             // These are converted to SimpleParser and are handled already above.
index c8e212eac0ea1ad521e8589117170100418f3b25..7465809d2b6ef7f16bb073bc86472c398117b9dd 100644 (file)
@@ -56,8 +56,8 @@ dhcp6_srv_configured(CalloutHandle& handle) {
 
     // Append argument names.
     std::vector<std::string> args = handle.getArgumentNames();
-    for (auto arg = args.begin(); arg != args.end(); ++arg) {
-        if (appendArgument(SRV_CONFIG_MARKER_FILE, arg->c_str()) != 0) {
+    for (auto const& arg : args) {
+        if (appendArgument(SRV_CONFIG_MARKER_FILE, arg.c_str()) != 0) {
             return (1);
         }
     }
index f1427ce5f8ed759c61dd0fe4ac2fa07846483153..52fae459b5324c73cd07cc11611f7d6092c6ce76 100644 (file)
@@ -25,7 +25,6 @@
 #include <dhcp6/tests/dhcp6_test_utils.h>
 #include <dhcp6/tests/get_config_unittest.h>
 
-#include <boost/foreach.hpp>
 #include <boost/scoped_ptr.hpp>
 
 #include <iostream>
index ef08dbdd24d04d397036da8d705124706084a2f8..6f571d52aba429d6c514a98ef1ed4d3b5e2a5ee6 100644 (file)
@@ -41,9 +41,9 @@
 #include "dhcp6_test_utils.h"
 #include "get_config_unittest.h"
 
-#include <boost/foreach.hpp>
 #include <gtest/gtest.h>
 
+#include <boost/foreach.hpp>
 #include <fstream>
 #include <iostream>
 #include <sstream>
@@ -595,8 +595,7 @@ public:
             "    \"subnet\": \"2001:db8:1::/64\", "
             "    \"option-data\": [ {";
         bool first = true;
-        typedef std::pair<std::string, std::string> ParamPair;
-        BOOST_FOREACH(ParamPair param, params) {
+        for (auto const& param : params) {
             if (!first) {
                 stream << ", ";
             } else {
@@ -2092,16 +2091,14 @@ TEST_F(Dhcp6ParserTest, badSubnetValues) {
     // Iterate over the list of scenarios.  Each should fail to parse with
     // a specific error message.
     for (auto const& scenario : scenarios) {
-        {
-            SCOPED_TRACE(scenario.description_);
-            ConstElementPtr config;
-            ASSERT_NO_THROW(config = parseDHCP6(scenario.config_json_))
-                            << "invalid json, broken test";
-            ConstElementPtr status;
-            EXPECT_NO_THROW(status = Dhcpv6SrvTest::configure(srv_, config));
-            checkResult(status, 1);
-            EXPECT_EQ(comment_->stringValue(), scenario.exp_error_msg_);
-        }
+        SCOPED_TRACE(scenario.description_);
+        ConstElementPtr config;
+        ASSERT_NO_THROW(config = parseDHCP6(scenario.config_json_))
+                        << "invalid json, broken test";
+        ConstElementPtr status;
+        EXPECT_NO_THROW(status = Dhcpv6SrvTest::configure(srv_, config));
+        checkResult(status, 1);
+        EXPECT_EQ(comment_->stringValue(), scenario.exp_error_msg_);
     }
 }
 
@@ -5424,9 +5421,8 @@ TEST_F(Dhcp6ParserTest, invalidD2ClientConfig) {
 /// @param range Range of reservations returned by the @c Host object
 /// in which the reservation will be searched.
 bool reservationExists(const IPv6Resrv& resrv, const IPv6ResrvRange& range) {
-    for (IPv6ResrvIterator it = range.first; it != range.second;
-         ++it) {
-        if (resrv == it->second) {
+    BOOST_FOREACH(auto const& it, range) {
+        if (resrv == it.second) {
             return (true);
         }
     }
index 421cf13ccff4c27b43749f3ae1a69956db8be54d..67c3b192b9e2a39921a6dc1c0d74020e1a8ebb12 100644 (file)
@@ -1426,14 +1426,17 @@ TEST_F(CtrlChannelDhcpv6SrvTest, controlChannelStats) {
     };
 
     std::ostringstream s;
+    bool first = true;
     s << "{ \"arguments\": { ";
-    for (auto st = initial_stats.begin(); st != initial_stats.end();) {
-        s << "\"" << *st << "\": [ [ 0, \"";
-        s << isc::util::clockToText(StatsMgr::instance().getObservation(*st)->getInteger().second);
-        s << "\" ] ]";
-        if (++st != initial_stats.end()) {
+    for (auto const& st : initial_stats) {
+        if (!first) {
             s << ", ";
+        } else {
+            first = false;
         }
+        s << "\"" << st << "\": [ [ 0, \"";
+        s << isc::util::clockToText(StatsMgr::instance().getObservation(st)->getInteger().second);
+        s << "\" ] ]";
     }
     s << " }, \"result\": 0 }";
 
index a797a9745df63462a6f669244610ea5516ca40ac..a1d085769df8b29992e286009b66fab0ba2f0ee9 100644 (file)
@@ -22,7 +22,6 @@
 #include <dhcp6/tests/dhcp6_client.h>
 #include <util/buffer.h>
 #include <util/multi_threading_mgr.h>
-#include <boost/foreach.hpp>
 #include <boost/pointer_cast.hpp>
 #include <algorithm>
 #include <cstdlib>
@@ -258,13 +257,12 @@ Dhcp6Client::appendFQDN() {
 
 void
 Dhcp6Client::appendRequestedIAs(const Pkt6Ptr& query) const {
-    BOOST_FOREACH(const ClientIA& ia, client_ias_) {
+    for (auto const& ia : client_ias_) {
         OptionCollection options =
             query->getOptions(ia.type_ == Lease::TYPE_NA ?
                               D6O_IA_NA : D6O_IA_PD);
-        std::pair<unsigned int, OptionPtr> option_pair;
         Option6IAPtr existing_ia;
-        BOOST_FOREACH(option_pair, options) {
+        for (auto const& option_pair : options) {
             Option6IAPtr ia_opt =
                 boost::dynamic_pointer_cast<Option6IA>(option_pair.second);
             // This shouldn't happen.
@@ -287,7 +285,7 @@ Dhcp6Client::appendRequestedIAs(const Pkt6Ptr& query) const {
         if ((ia.type_ == Lease::TYPE_NA) && !ia.prefix_.isV6Zero()) {
             Option6IAAddrPtr ia_addr(new Option6IAAddr(D6O_IAADDR, ia.prefix_,
                                                        0, 0));
-            BOOST_FOREACH(option_pair, existing_ia->getOptions()) {
+            for (auto const& option_pair : existing_ia->getOptions()) {
                 Option6IAAddrPtr existing_addr = boost::dynamic_pointer_cast<
                     Option6IAAddr>(option_pair.second);
                 if (existing_addr &&
@@ -306,7 +304,7 @@ Dhcp6Client::appendRequestedIAs(const Pkt6Ptr& query) const {
                                                              ia.prefix_,
                                                              ia.prefix_len_,
                                                              0, 0));
-            BOOST_FOREACH(option_pair, existing_ia->getOptions()) {
+            for (auto const& option_pair : existing_ia->getOptions()) {
                 Option6IAPrefixPtr existing_prefix =
                     boost::dynamic_pointer_cast<Option6IAPrefix>(option_pair.second);
                 if (existing_prefix &&
@@ -328,19 +326,19 @@ Dhcp6Client::copyIAs(const Pkt6Ptr& source, const Pkt6Ptr& dest) {
     typedef OptionCollection Opts;
     // Copy IA_NAs.
     Opts opts = source->getOptions(D6O_IA_NA);
-    for (Opts::const_iterator opt = opts.begin(); opt != opts.end(); ++opt) {
+    for (auto const& opt : opts) {
         // Only copy the entire IA_NA if there is at lease one IA Address option.
-        if (opt->second->getOption(D6O_IAADDR)) {
-            dest->addOption(opt->second);
+        if (opt.second->getOption(D6O_IAADDR)) {
+            dest->addOption(opt.second);
         }
     }
     // Copy IA_PDs.
     opts = source->getOptions(D6O_IA_PD);
-    for (Opts::const_iterator opt = opts.begin(); opt != opts.end(); ++opt) {
+    for (auto const& opt : opts) {
         // Only copy the entire IA_PD if there is at least one IA Prefix option
         // in it.
-        if (opt->second->getOption(D6O_IAPREFIX)) {
-            dest->addOption(opt->second);
+        if (opt.second->getOption(D6O_IAPREFIX)) {
+            dest->addOption(opt.second);
         }
     }
 }
@@ -350,32 +348,28 @@ Dhcp6Client::copyIAsFromLeases(const Pkt6Ptr& dest) const {
     // Go over leases and create IA_NA and IA_PD options from them.
     // Create one IA per lease.
     std::set<uint32_t> iaids = getIAIDs();
-    for (std::set<uint32_t>::const_iterator iaid = iaids.begin();
-         iaid != iaids.end(); ++iaid) {
-        std::vector<Lease6> leases = getLeasesByIAID(*iaid);
+    for (auto const& iaid : iaids) {
+        std::vector<Lease6> leases = getLeasesByIAID(iaid);
         // Only a valid lease should be included. Do not copy a
         // lease which have been marked by the server as invalid.
         if (leases[0].valid_lft_ == 0) {
             continue;
         }
         Option6IAPtr opt(new Option6IA(leases[0].type_ == Lease::TYPE_NA ?
-                                       D6O_IA_NA : D6O_IA_PD, *iaid));
-        for (std::vector<Lease6>::const_iterator lease = leases.begin();
-             lease != leases.end(); ++lease) {
-            if ((lease->preferred_lft_ != 0) && (lease->valid_lft_ != 0)) {
-                if (lease->type_ == Lease::TYPE_NA) {
-                    opt->addOption(Option6IAAddrPtr(new Option6IAAddr(
-                                                          D6O_IAADDR,
-                                                          lease->addr_,
-                                                          lease->preferred_lft_,
-                                                          lease->valid_lft_)));
-                } else if (lease->type_ == Lease::TYPE_PD) {
-                    opt->addOption(Option6IAAddrPtr(new Option6IAPrefix(
-                                                          D6O_IAPREFIX,
-                                                          lease->addr_,
-                                                          lease->prefixlen_,
-                                                          lease->preferred_lft_,
-                                                          lease->valid_lft_)));
+                                       D6O_IA_NA : D6O_IA_PD, iaid));
+        for (auto const& lease : leases) {
+            if ((lease.preferred_lft_ != 0) && (lease.valid_lft_ != 0)) {
+                if (lease.type_ == Lease::TYPE_NA) {
+                    opt->addOption(Option6IAAddrPtr(new Option6IAAddr(D6O_IAADDR,
+                                                                      lease.addr_,
+                                                                      lease.preferred_lft_,
+                                                                      lease.valid_lft_)));
+                } else if (lease.type_ == Lease::TYPE_PD) {
+                    opt->addOption(Option6IAAddrPtr(new Option6IAPrefix(D6O_IAPREFIX,
+                                                                        lease.addr_,
+                                                                        lease.prefixlen_,
+                                                                        lease.preferred_lft_,
+                                                                        lease.valid_lft_)));
                 }
             }
         }
@@ -414,16 +408,14 @@ Dhcp6Client::createMsg(const uint8_t msg_type) {
 
     // If there are any custom options specified, add them all to the message.
     if (!extra_options_.empty()) {
-        for (OptionCollection::iterator opt = extra_options_.begin();
-             opt != extra_options_.end(); ++opt) {
-            msg->addOption(opt->second);
+        for (auto const& opt : extra_options_) {
+            msg->addOption(opt.second);
         }
     }
 
     // Add classes.
-    for (ClientClasses::const_iterator cclass = classes_.cbegin();
-         cclass != classes_.cend(); ++cclass) {
-        msg->addClass(*cclass);
+    for (auto const& cclass : classes_) {
+        msg->addClass(cclass);
     }
 
     return (msg);
@@ -621,17 +613,18 @@ Dhcp6Client::generateIAFromLeases(const Pkt6Ptr& query,
                                   const bool include_address) {
     /// @todo: add support for IAPREFIX here.
 
-    for (std::vector<Lease6>::const_iterator lease = config_.leases_.begin();
-         lease != config_.leases_.end(); ++lease) {
-        if (lease->type_ != Lease::TYPE_NA) {
+    for (auto const& lease : config_.leases_) {
+        if (lease.type_ != Lease::TYPE_NA) {
             continue;
         }
 
-        Option6IAPtr ia(new Option6IA(D6O_IA_NA, lease->iaid_));
+        Option6IAPtr ia(new Option6IA(D6O_IA_NA, lease.iaid_));
 
         if (include_address) {
             ia->addOption(OptionPtr(new Option6IAAddr(D6O_IAADDR,
-                  lease->addr_, lease->preferred_lft_, lease->valid_lft_)));
+                                                      lease.addr_,
+                                                      lease.preferred_lft_,
+                                                      lease.valid_lft_)));
         }
         query->addOption(ia);
     }
@@ -681,9 +674,8 @@ Dhcp6Client::getClientId() const {
 std::set<uint32_t>
 Dhcp6Client::getIAIDs() const {
     std::set<uint32_t> iaids;
-    for (std::vector<Lease6>::const_iterator lease = config_.leases_.begin();
-         lease != config_.leases_.end(); ++lease) {
-        iaids.insert(lease->iaid_);
+    for (auto const& lease : config_.leases_) {
+        iaids.insert(lease.iaid_);
     }
     return (iaids);
 }
@@ -759,7 +751,7 @@ bool
 Dhcp6Client::hasLeaseForAddress(const asiolink::IOAddress& address,
                                 const IAID& iaid) const {
     std::vector<Lease6> leases = getLeasesByAddress(address);
-    BOOST_FOREACH(const Lease6& lease, leases) {
+    for (auto const& lease : leases) {
         if (lease.iaid_ == iaid) {
             return (true);
         }
@@ -777,7 +769,7 @@ Dhcp6Client::hasLeaseForAddressRange(const asiolink::IOAddress& first,
 bool
 Dhcp6Client::hasLeaseWithZeroLifetimeForAddress(const asiolink::IOAddress& address) const {
     std::vector<Lease6> leases = getLeasesByAddress(address);
-    BOOST_FOREACH(const Lease6& lease, leases) {
+    for (auto const& lease : leases) {
         if ((lease.preferred_lft_ == 0) && (lease.valid_lft_ == 0)) {
             return (true);
         }
@@ -790,7 +782,7 @@ bool
 Dhcp6Client::hasLeaseForPrefix(const asiolink::IOAddress& prefix,
                                const uint8_t prefix_len) const {
     std::vector<Lease6> leases = getLeasesByAddress(prefix);
-    BOOST_FOREACH(const Lease6& lease, leases) {
+    for (auto const& lease : leases) {
         if (lease.prefixlen_ == prefix_len) {
             return (true);
         }
@@ -803,7 +795,7 @@ Dhcp6Client::hasLeaseForPrefix(const asiolink::IOAddress& prefix,
                                const uint8_t prefix_len,
                                const IAID& iaid) const {
     std::vector<Lease6> leases = getLeasesByAddress(prefix);
-    BOOST_FOREACH(const Lease6& lease, leases) {
+    for (auto const& lease : leases) {
         if ((lease.prefixlen_ == prefix_len) &&
             (lease.iaid_ == iaid)) {
             return (true);
@@ -825,7 +817,7 @@ bool
 Dhcp6Client::hasLeaseWithZeroLifetimeForPrefix(const asiolink::IOAddress& prefix,
                                                const uint8_t prefix_len) const {
     std::vector<Lease6> leases = getLeasesByAddress(prefix);
-    BOOST_FOREACH(const Lease6& lease, leases) {
+    for (auto const& lease : leases) {
         if ((lease.prefixlen_ == prefix_len) && (lease.preferred_lft_ == 0) &&
             (lease.valid_lft_ == 0)) {
             return (true);
@@ -965,9 +957,8 @@ Dhcp6Client::sendMsg(const Pkt6Ptr& msg) {
 
     // Copy classes
     const ClientClasses& classes = msg->getClasses();
-    for (ClientClasses::const_iterator cclass = classes.cbegin();
-         cclass != classes.cend(); ++cclass) {
-        msg_copy->addClass(*cclass);
+    for (auto const& cclass : classes) {
+        msg_copy->addClass(cclass);
     }
 
     srv_->fakeReceive(msg_copy);
index 656711af22c475e598559641587a39b07b1a0c43..697e4f07a7982bd7a7d09ce5a4a3ef63786b00c0 100644 (file)
@@ -267,7 +267,7 @@ Dhcpv6SrvTest::loadConfigFile(const string& path) {
     removeTlsParameters(hosts);
     hosts = dhcp6->get("hosts-databases");
     if (hosts) {
-        for (auto& host : hosts->listValue()) {
+        for (auto const& host : hosts->listValue()) {
             removeTlsParameters(host);
         }
     }
@@ -362,7 +362,7 @@ Dhcpv6SrvTest::checkConfigFiles() {
         "with-ddns.json",
     };
     vector<string> files;
-    for (const string& example : examples) {
+    for (auto const& example : examples) {
         string file = path + "/" + example;
         files.push_back(file);
     }
@@ -3365,15 +3365,14 @@ TEST_F(Dhcpv6SrvTest, rsoo2relays) {
     int count120 = 0; // Let's count how many times option 120 was echoed back
     int count130 = 0; // Let's count how many times option 130 was echoed back
     OptionPtr opt120;
-    for (OptionCollection::const_iterator it = client.config_.options_.begin();
-         it != client.config_.options_.end(); ++it) {
-        switch (it->second->getType()) {
+    for (auto const& it : client.config_.options_) {
+        switch (it.second->getType()) {
         case 110:
             count110++;
             break;
         case 120:
             count120++;
-            opt120 = it->second;
+            opt120 = it.second;
             break;
         case 130:
             count130++;
index a2f9acff6145e923e3623286e1984fe7bf798d33..de4dec633cdd113af8e60ab37a70ba24b9f6c203 100644 (file)
@@ -1146,14 +1146,13 @@ NakedDhcpv6SrvTest::checkIA_NAStatusCode(
     // it will return it with zeroed lifetimes.
     if (check_addr) {
         dhcp::OptionCollection options = ia->getOptions();
-        for (isc::dhcp::OptionCollection::iterator opt = options.begin();
-             opt != options.end(); ++opt) {
-            if (opt->second->getType() != D6O_IAADDR) {
+        for (auto const& opt : options) {
+            if (opt.second->getType() != D6O_IAADDR) {
                 continue;
             }
 
             dhcp::Option6IAAddrPtr addr =
-                boost::dynamic_pointer_cast<isc::dhcp::Option6IAAddr>(opt->second);
+                boost::dynamic_pointer_cast<isc::dhcp::Option6IAAddr>(opt.second);
             ASSERT_TRUE(addr);
 
             EXPECT_EQ(0, addr->getPreferred());
index d87896eab32a6093d0320b5cd6ded71c55d880b4..0fb81725f30cbe32c00a133a74b05915433af433 100644 (file)
@@ -5589,7 +5589,7 @@ TEST_F(LoadUnloadDhcpv6SrvTest, failLoadIncompatibleLibraries) {
 // Checks if callouts installed on the dhcp6_srv_configured ared indeed called
 // and all the necessary parameters are passed.
 TEST_F(LoadUnloadDhcpv6SrvTest, Dhcpv6SrvConfigured) {
-    for (const string& parameters : vector<string>{
+    for (auto const& parameters : vector<string>{
         "",
         R"(, "parameters": { "mode": "fail-without-error" } )",
         R"(, "parameters": { "mode": "fail-with-error" } )"}) {
index 02a8283e74b34fca552f88d3c1d7a589249b5835..fa9651e4f362564d4001dbb0d58ed04380285d6c 100644 (file)
@@ -1279,9 +1279,9 @@ public:
     Subnet6Ptr getConfiguredSubnet(const Lease::Type& type, const IOAddress& resource) const {
         CfgSubnets6Ptr cfg = CfgMgr::instance().getCurrentCfg()->getCfgSubnets6();
         const Subnet6Collection* subnets = cfg->getAll();
-        for (auto subnet_it = subnets->cbegin(); subnet_it != subnets->cend(); ++subnet_it) {
-            if ((*subnet_it)->inPool(type, resource)) {
-                return (*subnet_it);
+        for (auto const& subnet_it : *subnets) {
+            if (subnet_it->inPool(type, resource)) {
+                return (subnet_it);
             }
         }
 
@@ -1380,13 +1380,13 @@ public:
     bool hasLeaseForAddressRange(Dhcp6Client& client, const IOAddress& first, const IOAddress& last,
                                  const LeaseOnServer& lease_on_server = LeaseOnServer::MUST_EXIST) {
         std::vector<Lease6> leases = client.getLeasesByAddressRange(first, last);
-        for (auto lease_it = leases.cbegin(); lease_it != leases.cend(); ++lease_it) {
+        for (auto const& lease_it : leases) {
             // Take into account only valid leases.
-            if (lease_it->valid_lft_ == 0) {
+            if (lease_it.valid_lft_ == 0) {
                 continue;
             }
 
-            Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, lease_it->addr_);
+            Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, lease_it.addr_);
             if ((lease && (lease_on_server == LeaseOnServer::MUST_NOT_EXIST)) ||
                 (!lease && (lease_on_server == LeaseOnServer::MUST_EXIST))) {
                 return (false);
@@ -1415,13 +1415,13 @@ public:
                                const LeaseOnServer& lease_on_server = LeaseOnServer::MUST_EXIST) {
         std::vector<Lease6> leases = client.getLeasesByPrefixPool(prefix, prefix_len, delegated_len);
 
-        for (auto lease_it = leases.cbegin(); lease_it != leases.cend(); ++lease_it) {
+        for (auto const& lease_it : leases) {
             // Take into account only valid leases.
-            if (lease_it->valid_lft_ == 0) {
+            if (lease_it.valid_lft_ == 0) {
                 continue;
             }
 
-            Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_PD, lease_it->addr_);
+            Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_PD, lease_it.addr_);
             if ((lease && (lease->prefixlen_ == lease->prefixlen_) &&
                  (lease_on_server == LeaseOnServer::MUST_NOT_EXIST)) ||
                 (!lease && (lease_on_server == LeaseOnServer::MUST_EXIST))) {
index 7aaf9c6c415075f663380b312bacb66a2870711d..d189161c5cc5f4b97c7333acb1f201be8ff575ac 100644 (file)
@@ -116,11 +116,10 @@ PktTransform::packOptions(const OptionBuffer& in_buffer,
         // If there are any options on the list, we will use provided
         // options offsets to override them in the output buffer
         // with new contents.
-        for (OptionCollection::const_iterator it = options.begin();
-             it != options.end(); ++it) {
+        for (auto const& it : options) {
             // Get options with their position (offset).
             boost::shared_ptr<LocalizedOption> option =
-                boost::dynamic_pointer_cast<LocalizedOption>(it->second);
+                boost::dynamic_pointer_cast<LocalizedOption>(it.second);
             if (option == NULL) {
                 isc_throw(isc::BadValue, "option is null");
             }
@@ -146,8 +145,7 @@ PktTransform::packOptions(const OptionBuffer& in_buffer,
                 out_buffer.writeUint8At(buf_data[i], offset + i);
             }
         }
-    }
-    catch (const Exception&) {
+    } catch (const Exception&) {
         isc_throw(isc::BadValue, "failed to pack options into buffer.");
     }
 }
@@ -155,11 +153,10 @@ PktTransform::packOptions(const OptionBuffer& in_buffer,
 void
 PktTransform::unpackOptions(const OptionBuffer& in_buffer,
                             const OptionCollection& options) {
-    for (OptionCollection::const_iterator it = options.begin();
-         it != options.end(); ++it) {
+    for (auto const& it : options) {
 
         boost::shared_ptr<LocalizedOption> option =
-            boost::dynamic_pointer_cast<LocalizedOption>(it->second);
+            boost::dynamic_pointer_cast<LocalizedOption>(it.second);
         if (option == NULL) {
             isc_throw(isc::BadValue, "option is null");
         }
index 1563588f65463a720872c211d5acd9be836b1910..1bb655b79173e66ec972eb2a3cfe8825f9449542 100644 (file)
@@ -14,6 +14,7 @@
 #include <dhcp/pkt4.h>
 #include <perfdhcp/stats_mgr.h>
 #include <perfdhcp/test_control.h>
+#include <boost/foreach.hpp>
 
 using isc::dhcp::DHO_DHCP_CLIENT_IDENTIFIER;
 using isc::dhcp::DUID;
@@ -313,21 +314,16 @@ ExchangeStats::printTimestamps() {
     using namespace boost::posix_time;
 
     // Iterate through all received packets.
-    for (PktListIterator it = rcvd_packets_.begin();
-         it != rcvd_packets_.end();
-         ++it) {
-        PktPtr rcvd_packet = *it;
+    for (auto const& it : rcvd_packets_) {
+        PktPtr rcvd_packet = it;
         PktListTransidHashIndex& idx =
             archived_packets_.template get<1>();
         std::pair<PktListTransidHashIterator,
                   PktListTransidHashIterator> p =
             idx.equal_range(hashTransid(rcvd_packet));
-        for (PktListTransidHashIterator it_archived = p.first;
-             it_archived != p.second;
-             ++it_archived) {
-            if ((*it_archived)->getTransid() ==
-                rcvd_packet->getTransid()) {
-                PktPtr sent_packet = *it_archived;
+        BOOST_FOREACH(auto const& it_archived, p) {
+            if (it_archived->getTransid() == rcvd_packet->getTransid()) {
+                PktPtr sent_packet = it_archived;
                 // Get sent and received packet times.
                 ptime sent_time = sent_packet->getTimestamp();
                 ptime rcvd_time = rcvd_packet->getTimestamp();
index 39718e9b795b6100f94df2c099af376158a17275..e5a3619351c1664c2b202c2d7d47c7237e112916 100644 (file)
@@ -209,10 +209,8 @@ public:
     /// \code
     /// PktList packets_collection();
     /// ...  # Add elements to the container
-    /// for (PktListIterator it = packets_collection.begin();
-    ///      it != packets_collection.end();
-    ///      ++it) {
-    ///          boost::shared_ptr<Pkt4> pkt = *it;
+    /// for (auto const& it : packets_collection) {
+    ///          boost::shared_ptr<Pkt4> pkt = it;
     ///          # Do something with packet;
     ///      }
     /// \endcode
@@ -778,10 +776,8 @@ public:
     ///
     // \return true, if packet drops occurred.
     bool droppedPackets() const {
-        for (ExchangesMapIterator it = exchanges_.begin();
-             it != exchanges_.end();
-             ++it) {
-            if (it->second->getDroppedPacketsNum() > 0) {
+        for (auto const& it : exchanges_) {
+            if (it.second->getDroppedPacketsNum() > 0) {
                 return (true);
             }
         }
@@ -1098,11 +1094,9 @@ public:
             isc_throw(isc::InvalidOperation,
                       "no exchange type added for tracking");
         }
-        for (ExchangesMapIterator it = exchanges_.begin();
-             it != exchanges_.end();
-             ++it) {
-            ExchangeStatsPtr xchg_stats = it->second;
-            std::cout << "***Statistics for: " << it->first
+        for (auto const& it : exchanges_) {
+            ExchangeStatsPtr xchg_stats = it.second;
+            std::cout << "***Statistics for: " << it.first
                       << "***" << std::endl;
             xchg_stats->printMainStats();
             std::cout << std::endl;
@@ -1126,35 +1120,36 @@ public:
         std::ostringstream stream_drops;
         std::ostringstream stream_reject;
         std::string sep("");
-        for (ExchangesMapIterator it = exchanges_.begin();
-             it != exchanges_.end(); ++it) {
-
-            if (it != exchanges_.begin()) {
+        bool first = true;
+        for (auto const& it : exchanges_) {
+            if (!first) {
                 if (clean_report) {
                     sep = clean_sep;
                 } else {
                     sep = "/";
                 }
+            } else {
+                first = false;
             }
-            stream_sent << sep << it->second->getSentPacketsNum();
-            stream_rcvd << sep << it->second->getRcvdPacketsNum();
-            stream_drops << sep << it->second->getDroppedPacketsNum();
-            stream_reject << sep << it->second->getRejLeasesNum();
+            stream_sent << sep << it.second->getSentPacketsNum();
+            stream_rcvd << sep << it.second->getRcvdPacketsNum();
+            stream_drops << sep << it.second->getDroppedPacketsNum();
+            stream_reject << sep << it.second->getRejLeasesNum();
         }
 
         if (clean_report) {
-        std::cout << stream_sent.str()
-                  << clean_sep << stream_rcvd.str()
-                  << clean_sep << stream_drops.str()
-                  << clean_sep << stream_reject.str()
-                  << std::endl;
+            std::cout << stream_sent.str()
+                      << clean_sep << stream_rcvd.str()
+                      << clean_sep << stream_drops.str()
+                      << clean_sep << stream_reject.str()
+                      << std::endl;
 
         } else {
-        std::cout << "sent: " << stream_sent.str()
-                  << "; received: " << stream_rcvd.str()
-                  << "; drops: " << stream_drops.str()
-                  << "; rejected: " << stream_reject.str()
-                  << std::endl;
+            std::cout << "sent: " << stream_sent.str()
+                      << "; received: " << stream_rcvd.str()
+                      << "; drops: " << stream_drops.str()
+                      << "; rejected: " << stream_reject.str()
+                      << std::endl;
         }
     }
 
@@ -1174,12 +1169,10 @@ public:
             isc_throw(isc::InvalidOperation,
                       "no exchange type added for tracking");
         }
-        for (ExchangesMapIterator it = exchanges_.begin();
-             it != exchanges_.end();
-             ++it) {
-            ExchangeStatsPtr xchg_stats = it->second;
+        for (auto const& it : exchanges_) {
+            ExchangeStatsPtr xchg_stats = it.second;
             std::cout << "***Timestamps for packets: "
-                      << it->first
+                      << it.first
                       << "***" << std::endl;
             xchg_stats->printTimestamps();
             std::cout << std::endl;
@@ -1199,19 +1192,19 @@ public:
         if (custom_counters_.empty()) {
             isc_throw(isc::InvalidOperation, "no custom counters specified");
         }
-        for (CustomCountersMapIterator it = custom_counters_.begin();
-             it != custom_counters_.end();
-             ++it) {
-            CustomCounterPtr counter = it->second;
+        for (auto const& it : custom_counters_) {
+            CustomCounterPtr counter = it.second;
             std::cout << counter->getName() << ": " << counter->getValue()
                       << std::endl;
         }
     }
 
-    std::tuple<typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator> getSentPackets(const ExchangeType xchg_type) const {
+    std::tuple<typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator>
+    getSentPackets(const ExchangeType xchg_type) const {
         ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
-        std::tuple<typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator> sent_packets_its = xchg_stats->getSentPackets();
-        return(sent_packets_its);
+        std::tuple<typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator> sent_packets_its =
+                xchg_stats->getSentPackets();
+        return (sent_packets_its);
     }
 
 private:
index 29ef5a87f35f33acf82ed11d77fe0c2aa48f964f..9d33be86aa65eb04b3d231a5c20594d344e0d465 100644 (file)
@@ -549,9 +549,8 @@ TestControl::initPacketTemplates() {
     template_packets_v6_.clear();
     template_buffers_.clear();
     std::vector<std::string> template_files = options_.getTemplateFiles();
-    for (std::vector<std::string>::const_iterator it = template_files.begin();
-         it != template_files.end(); ++it) {
-        readPacketTemplate(*it);
+    for (auto const& it : template_files) {
+        readPacketTemplate(it);
     }
 }
 
@@ -750,13 +749,13 @@ std::string
 TestControl::vector2Hex(const std::vector<uint8_t>& vec,
                         const std::string& separator /* = "" */) {
     std::ostringstream stream;
-    for (std::vector<uint8_t>::const_iterator it = vec.begin();
-         it != vec.end();
-         ++it) {
-        if (it == vec.begin()) {
-            stream << byte2Hex(*it);
+    bool first = true;
+    for (auto const& it : vec) {
+        if (first) {
+            stream << byte2Hex(it);
+            first = false;
         } else {
-            stream << separator << byte2Hex(*it);
+            stream << separator << byte2Hex(it);
         }
     }
     return (stream.str());
index 17700cebf29050f8e3cb0b110b1faeba9ab2f2dd..2ec4e44cec63fa550193932a23f986c2a5d0e781 100644 (file)
@@ -615,10 +615,9 @@ protected:
     void addUniqeAddr(const std::set<std::string>& current, ExchangeType xchg_type) {
         switch(xchg_type) {
             case ExchangeType::SA: {
-                for (auto current_it = current.begin();
-                     current_it != current.end(); ++current_it) {
+                for (auto const& current_it : current) {
                     // addresses should be unique cross packets
-                    auto ret = unique_address_.emplace(*current_it);
+                    auto ret = unique_address_.emplace(current_it);
                     if (!ret.second) {
                         stats_mgr_.updateNonUniqueAddrNum(ExchangeType::SA);
                     }
@@ -626,10 +625,9 @@ protected:
                 break;
             }
             case ExchangeType::RR: {
-                for (auto current_it = current.begin();
-                     current_it != current.end(); ++current_it) {
+                for (auto const& current_it : current) {
                     // addresses should be unique cross packets
-                    auto ret = unique_reply_address_.emplace(*current_it);
+                    auto ret = unique_reply_address_.emplace(current_it);
                     if (!ret.second) {
                         stats_mgr_.updateNonUniqueAddrNum(ExchangeType::RR);
                     }
@@ -642,10 +640,9 @@ protected:
                 break;
             }
             case ExchangeType::DO: {
-                for (auto current_it = current.begin();
-                     current_it != current.end(); ++current_it) {
+                for (auto const& current_it : current) {
                     // addresses should be unique cross packets
-                    auto ret = unique_address_.emplace(*current_it);
+                    auto ret = unique_address_.emplace(current_it);
                     if (!ret.second) {
                         stats_mgr_.updateNonUniqueAddrNum(ExchangeType::DO);
                     }
@@ -653,10 +650,9 @@ protected:
                 break;
             }
             case ExchangeType::RA: {
-                for (auto current_it = current.begin();
-                     current_it != current.end(); ++current_it) {
+                for (auto const& current_it : current) {
                     // addresses should be unique cross packets
-                    auto ret = unique_reply_address_.emplace(*current_it);
+                    auto ret = unique_reply_address_.emplace(current_it);
                     if (!ret.second) {
                         stats_mgr_.updateNonUniqueAddrNum(ExchangeType::RA);
                     }
@@ -677,13 +673,13 @@ protected:
     ///
     /// \param addr holding value of unique address.
     void removeUniqueAddr(const std::set<std::string>& addr) {
-        for (auto addr_it = addr.begin(); addr_it != addr.end(); ++addr_it) {
-            auto it = unique_address_.find(*addr_it);
+        for (auto const& addr_it : addr) {
+            auto it = unique_address_.find(addr_it);
             if (it != unique_address_.end()) {
                 unique_address_.erase(it);
             }
 
-            auto it2 = unique_reply_address_.find(*addr_it);
+            auto it2 = unique_reply_address_.find(addr_it);
             if (it2 != unique_reply_address_.end()) {
                 unique_reply_address_.erase(it2);
             }
index d2e119a094f3dbe5bbabcbef723f6686bc9ba24a..614ca033809fe6463de147ceef34024fb901fce0 100644 (file)
@@ -18,7 +18,6 @@
 #include <dhcp/option6_iaprefix.h>
 
 #include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/foreach.hpp>
 
 #include <algorithm>
 #include <cstddef>
index 5240293339eda0c0c0e5db415f2506524e517682..431e8326fc32f74eb1f374d00e790ad990678e15 100644 (file)
@@ -17,7 +17,6 @@
 #include <dhcp/option6_iaaddr.h>
 #include <dhcp/option6_iaprefix.h>
 #include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/foreach.hpp>
 
 #include <algorithm>
 #include <cstddef>
index 39a2db99e9cdc091d20638f3755bd11845f176a8..e0d5f1ce2e2eb971f05538c7feb9679da3b567cd 100644 (file)
@@ -6,8 +6,8 @@
 
 #include <config.h>
 
-#include "command_options_helper.h"
-#include "../perf_socket.h"
+#include <command_options_helper.h>
+#include <perf_socket.h>
 
 #include <asiolink/io_address.h>
 #include <exceptions/exceptions.h>
@@ -16,7 +16,6 @@
 #include <dhcp/iface_mgr.h>
 
 #include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/foreach.hpp>
 
 #include <algorithm>
 #include <cstddef>
index 1838a7b1db14f7d9dff5f22eb08115308a4b2f32..f31f25a8447fa99f59a6599a053851615be9006f 100644 (file)
@@ -6,8 +6,8 @@
 
 #include <config.h>
 
-#include "command_options_helper.h"
-#include "../test_control.h"
+#include <command_options_helper.h>
+#include <test_control.h>
 
 #include <asiolink/io_address.h>
 #include <exceptions/exceptions.h>
@@ -19,7 +19,6 @@
 #include <dhcp/option6_iaprefix.h>
 
 #include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/foreach.hpp>
 #include <boost/format.hpp>
 
 #include <algorithm>
index 725f9f185a480dfbcdb3298db7183f77459ffdbd..a2f25195a85750ba9e54758d58addac45fa2fb9c 100644 (file)
@@ -141,17 +141,15 @@ ConstElementPtr
 CommandCreator::createLease6BulkApply(const Lease6CollectionPtr& leases,
                                       const Lease6CollectionPtr& deleted_leases) {
     ElementPtr deleted_leases_list = Element::createList();
-    for (auto lease = deleted_leases->begin(); lease != deleted_leases->end();
-         ++lease) {
-        ElementPtr lease_as_json = (*lease)->toElement();
+    for (auto const& lease : *deleted_leases) {
+        ElementPtr lease_as_json = lease->toElement();
         insertLeaseExpireTime(lease_as_json);
         deleted_leases_list->add(lease_as_json);
     }
 
     ElementPtr leases_list = Element::createList();
-    for (auto lease = leases->begin(); lease != leases->end();
-         ++lease) {
-        ElementPtr lease_as_json = (*lease)->toElement();
+    for (auto const& lease : *leases) {
+        ElementPtr lease_as_json = lease->toElement();
         insertLeaseExpireTime(lease_as_json);
         leases_list->add(lease_as_json);
     }
index bc31fde230f825d2b251a3c5738c7164be765876..8cfa6858335bcae9d1dfd46441bc8d04133a320f 100644 (file)
@@ -257,9 +257,9 @@ HAConfig::getPeerConfig(const std::string& name) const {
 HAConfig::PeerConfigPtr
 HAConfig::getFailoverPeerConfig() const {
     PeerConfigMap servers = getOtherServersConfig();
-    for (auto peer = servers.begin(); peer != servers.end(); ++peer) {
-        if (peer->second->getRole() != HAConfig::PeerConfig::BACKUP) {
-            return (peer->second);
+    for (auto const& peer : servers) {
+        if (peer.second->getRole() != HAConfig::PeerConfig::BACKUP) {
+            return (peer.second);
         }
     }
 
@@ -289,28 +289,28 @@ HAConfig::validate() {
 
     // Gather all the roles and see how many occurrences of each role we get.
     std::map<PeerConfig::Role, unsigned> peers_cnt;
-    for (auto p = peers_.begin(); p != peers_.end(); ++p) {
-        if (!p->second->getUrl().isValid()) {
+    for (auto const& p : peers_) {
+        if (!p.second->getUrl().isValid()) {
             isc_throw(HAConfigValidationError, "invalid URL: "
-                      << p->second->getUrl().getErrorMessage()
-                      << " for server " << p->second->getName());
+                      << p.second->getUrl().getErrorMessage()
+                      << " for server " << p.second->getName());
         }
 
         // The hostname must be an address, not a name.
         IOAddress addr("::");
         try {
-            addr = IOAddress(p->second->getUrl().getStrippedHostname());
+            addr = IOAddress(p.second->getUrl().getStrippedHostname());
         } catch (const IOError& ex) {
             isc_throw(HAConfigValidationError, "bad url '"
-                      << p->second->getUrl().toText()
+                      << p.second->getUrl().toText()
                       << "': " << ex.what()
-                      << " for server " << p->second->getName());
+                      << " for server " << p.second->getName());
         }
 
         // Check TLS setup.
-        Optional<std::string> ca = p->second->getTrustAnchor();
-        Optional<std::string> cert = p->second->getCertFile();
-        Optional<std::string> key = p->second->getKeyFile();
+        Optional<std::string> ca = p.second->getTrustAnchor();
+        Optional<std::string> cert = p.second->getCertFile();
+        Optional<std::string> key = p.second->getKeyFile();
         // When not configured get the value from the global level.
         if (ca.unspecified()) {
             ca = trust_anchor_;
@@ -346,11 +346,11 @@ HAConfig::validate() {
                 TlsRole tls_role = TlsRole::CLIENT;
                 bool cert_required = true;
                 // The peer entry for myself will be used for the server side.
-                if (p->second->getName() == getThisServerName()) {
+                if (p.second->getName() == getThisServerName()) {
                     tls_role = TlsRole::SERVER;
                     cert_required = getRequireClientCerts();
                 }
-                TlsContext::configure(p->second->tls_context_,
+                TlsContext::configure(p.second->tls_context_,
                                       tls_role,
                                       ca.get(),
                                       cert.get(),
@@ -358,20 +358,20 @@ HAConfig::validate() {
                                       cert_required);
             } catch (const isc::Exception& ex) {
                 isc_throw(HAConfigValidationError, "bad TLS config for server "
-                          << p->second->getName() << ": " << ex.what());
+                          << p.second->getName() << ": " << ex.what());
             }
         } else {
             // Refuse HTTPS scheme when TLS is not enabled.
-            if (p->second->getUrl().getScheme() == Url::HTTPS) {
+            if (p.second->getUrl().getScheme() == Url::HTTPS) {
                 isc_throw(HAConfigValidationError, "bad url '"
-                          << p->second->getUrl().toText()
+                          << p.second->getUrl().toText()
                           << "': https scheme is not supported"
-                          << " for server " << p->second->getName()
+                          << " for server " << p.second->getName()
                           << " where TLS is disabled");
             }
         }
 
-        ++peers_cnt[p->second->getRole()];
+        ++peers_cnt[p.second->getRole()];
     }
 
     // Only one primary server allowed.
index 79f0c305b2cd7b5fd01327d0f187da1124691062..1d66aae93e04fe8797b30f7ddbe240a1f054abf3 100644 (file)
@@ -261,57 +261,57 @@ HAConfigParser::parseOne(const HAConfigMapperPtr& config_storage,
     auto const& peers_vec = peers->listValue();
 
     // Go over configuration of each peer.
-    for (auto p = peers_vec.begin(); p != peers_vec.end(); ++p) {
+    for (auto const& p : peers_vec) {
 
         // Peer configuration is held in a map.
-        if ((*p)->getType() != Element::map) {
+        if (p->getType() != Element::map) {
             isc_throw(ConfigError, "peer configuration must be a map");
         }
 
-        setDefaults(*p, HA_CONFIG_PEER_DEFAULTS);
+        setDefaults(p, HA_CONFIG_PEER_DEFAULTS);
 
         // Server name.
-        auto cfg = rel_config->selectNextPeerConfig(getString(*p, "name"));
+        auto cfg = rel_config->selectNextPeerConfig(getString(p, "name"));
 
         // URL.
-        cfg->setUrl(Url(getString((*p), "url")));
+        cfg->setUrl(Url(getString(p, "url")));
 
         // Optional trust anchor.
-        if ((*p)->contains("trust-anchor")) {
-            cfg->setTrustAnchor(getString(*p, ("trust-anchor")));
+        if (p->contains("trust-anchor")) {
+            cfg->setTrustAnchor(getString(p, ("trust-anchor")));
         }
 
         // Optional certificate file.
-        if ((*p)->contains("cert-file")) {
-            cfg->setCertFile(getString(*p, ("cert-file")));
+        if (p->contains("cert-file")) {
+            cfg->setCertFile(getString(p, ("cert-file")));
         }
 
         // Optional private key file.
-        if ((*p)->contains("key-file")) {
-            cfg->setKeyFile(getString(*p, ("key-file")));
+        if (p->contains("key-file")) {
+            cfg->setKeyFile(getString(p, ("key-file")));
         }
 
         // Role.
-        cfg->setRole(getString(*p, "role"));
+        cfg->setRole(getString(p, "role"));
 
         // Auto failover configuration.
-        cfg->setAutoFailover(getBoolean(*p, "auto-failover"));
+        cfg->setAutoFailover(getBoolean(p, "auto-failover"));
 
         // Basic HTTP authentication password.
         std::string password;
-        if ((*p)->contains("basic-auth-password")) {
-            if ((*p)->contains("basic-auth-password-file")) {
+        if (p->contains("basic-auth-password")) {
+            if (p->contains("basic-auth-password-file")) {
                 isc_throw(dhcp::DhcpConfigError, "only one of "
                           << "basic-auth-password and "
                           << "basic-auth-password-file parameter can be "
                           << "configured in peer '"
                           << cfg->getName() << "'");
             }
-            password = getString((*p), "basic-auth-password");
+            password = getString(p, "basic-auth-password");
         }
-        if ((*p)->contains("basic-auth-password-file")) {
+        if (p->contains("basic-auth-password-file")) {
             std::string password_file =
-                getString((*p), "basic-auth-password-file");
+                getString(p, "basic-auth-password-file");
             try {
                 password = util::file::getContent(password_file);
             } catch (const std::exception& ex) {
@@ -321,8 +321,8 @@ HAConfigParser::parseOne(const HAConfigMapperPtr& config_storage,
         }
 
         // Basic HTTP authentication user.
-        if ((*p)->contains("basic-auth-user")) {
-            std::string user = getString((*p), "basic-auth-user");
+        if (p->contains("basic-auth-user")) {
+            std::string user = getString(p, "basic-auth-user");
             BasicHttpAuthPtr& auth = cfg->getBasicAuth();
             try {
                 if (!user.empty()) {
@@ -343,17 +343,17 @@ HAConfigParser::parseOne(const HAConfigMapperPtr& config_storage,
         std::set<int> configured_states;
 
         // Go over per state configurations.
-        for (auto s = states_vec.begin(); s != states_vec.end(); ++s) {
+        for (auto const& s : states_vec) {
 
             // State configuration is held in map.
-            if ((*s)->getType() != Element::map) {
+            if (s->getType() != Element::map) {
                 isc_throw(ConfigError, "state configuration must be a map");
             }
 
-            setDefaults(*s, HA_CONFIG_STATE_DEFAULTS);
+            setDefaults(s, HA_CONFIG_STATE_DEFAULTS);
 
             // Get state name and set per state configuration.
-            std::string state_name = getString(*s, "state");
+            std::string state_name = getString(s, "state");
 
             int state = stringToState(state_name);
             // Check that this configuration doesn't duplicate existing configuration.
@@ -364,7 +364,7 @@ HAConfigParser::parseOne(const HAConfigMapperPtr& config_storage,
             configured_states.insert(state);
 
             rel_config->getStateMachineConfig()->
-                getStateConfig(state)->setPausing(getString(*s, "pause"));
+                getStateConfig(state)->setPausing(getString(s, "pause"));
         }
     }
 
index 1d34b0e889d24cb467a0f25d86500211cb7d8e12..3843f61dad680fce4b4197d874ef111ab1c9cde3 100644 (file)
@@ -1198,21 +1198,21 @@ HAService::asyncSendLeaseUpdates(const dhcp::Pkt4Ptr& query,
     size_t sent_num = 0;
 
     // Schedule sending lease updates to each peer.
-    for (auto p = peers_configs.begin(); p != peers_configs.end(); ++p) {
-        HAConfig::PeerConfigPtr conf = p->second;
+    for (auto const& p : peers_configs) {
+        HAConfig::PeerConfigPtr conf = p.second;
 
         // Check if the lease updates should be queued. This is the case when the
         // server is in the communication-recovery state. Queued lease updates may
         // be sent when the communication is re-established.
         if (shouldQueueLeaseUpdates(conf)) {
             // Lease updates for deleted leases.
-            for (auto l = deleted_leases->begin(); l != deleted_leases->end(); ++l) {
-                lease_update_backlog_.push(LeaseUpdateBacklog::DELETE, *l);
+            for (auto const& l : *deleted_leases) {
+                lease_update_backlog_.push(LeaseUpdateBacklog::DELETE, l);
             }
 
             // Lease updates for new allocations and updated leases.
-            for (auto l = leases->begin(); l != leases->end(); ++l) {
-                lease_update_backlog_.push(LeaseUpdateBacklog::ADD, *l);
+            for (auto const& l : *leases) {
+                lease_update_backlog_.push(LeaseUpdateBacklog::ADD, l);
             }
 
             continue;
@@ -1233,14 +1233,14 @@ HAService::asyncSendLeaseUpdates(const dhcp::Pkt4Ptr& query,
         }
 
         // Lease updates for deleted leases.
-        for (auto l = deleted_leases->begin(); l != deleted_leases->end(); ++l) {
-            asyncSendLeaseUpdate(query, conf, CommandCreator::createLease4Delete(**l),
+        for (auto const& l : *deleted_leases) {
+            asyncSendLeaseUpdate(query, conf, CommandCreator::createLease4Delete(*l),
                                  parking_lot);
         }
 
         // Lease updates for new allocations and updated leases.
-        for (auto l = leases->begin(); l != leases->end(); ++l) {
-            asyncSendLeaseUpdate(query, conf, CommandCreator::createLease4Update(**l),
+        for (auto const& l : *leases) {
+            asyncSendLeaseUpdate(query, conf, CommandCreator::createLease4Update(*l),
                                  parking_lot);
         }
 
@@ -1278,20 +1278,20 @@ HAService::asyncSendLeaseUpdates(const dhcp::Pkt6Ptr& query,
     size_t sent_num = 0;
 
     // Schedule sending lease updates to each peer.
-    for (auto p = peers_configs.begin(); p != peers_configs.end(); ++p) {
-        HAConfig::PeerConfigPtr conf = p->second;
+    for (auto const& p : peers_configs) {
+        HAConfig::PeerConfigPtr conf = p.second;
 
         // Check if the lease updates should be queued. This is the case when the
         // server is in the communication-recovery state. Queued lease updates may
         // be sent when the communication is re-established.
         if (shouldQueueLeaseUpdates(conf)) {
-            for (auto l = deleted_leases->begin(); l != deleted_leases->end(); ++l) {
-                lease_update_backlog_.push(LeaseUpdateBacklog::DELETE, *l);
+            for (auto const& l : *deleted_leases) {
+                lease_update_backlog_.push(LeaseUpdateBacklog::DELETE, l);
             }
 
             // Lease updates for new allocations and updated leases.
-            for (auto l = leases->begin(); l != leases->end(); ++l) {
-                lease_update_backlog_.push(LeaseUpdateBacklog::ADD, *l);
+            for (auto const& l : *leases) {
+                lease_update_backlog_.push(LeaseUpdateBacklog::ADD, l);
             }
 
             continue;
@@ -1658,7 +1658,7 @@ HAService::processStatusGet() const {
     }
     std::set<std::string> scopes = query_filter_.getServedScopes();
     ElementPtr list = Element::createList();
-    for (const std::string& scope : scopes) {
+    for (auto const& scope : scopes) {
         list->add(Element::create(scope));
     }
     local->set("scopes", list);
index 7cdee015a73003c7eb30b253dfa08dc3d8310a3e..99c2327beb699375d35941a2865344a83b8d0a4f 100644 (file)
@@ -24,11 +24,11 @@ void
 LeaseSyncFilter::apply() {
     subnet_ids_.clear();
     if (server_type_ == HAServerType::DHCPv4) {
-        for (auto subnet : *CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll()) {
+        for (auto const& subnet : *CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll()) {
             conditionallyApplySubnetFilter(subnet);
         }
     } else {
-        for (auto subnet : *CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll()) {
+        for (auto const& subnet : *CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll()) {
             conditionallyApplySubnetFilter(subnet);
         }
     }
@@ -44,7 +44,7 @@ LeaseSyncFilter::conditionallyApplySubnetFilter(const SubnetPtr& subnet) {
     try {
         auto server_name = HAConfig::getSubnetServerName(subnet);
         if (!server_name.empty()) {
-            for (auto peer : config_->getAllServersConfig()) {
+            for (auto const& peer : config_->getAllServersConfig()) {
                 if (peer.first == server_name) {
                     subnet_ids_.insert(subnet->getID());
                     return;
index 5efda93f968232ac3cb745c5533210aa6ce07a6f..6cf2a9d2dd90bbd26660bf0f7ebb4230c5c29ce9 100644 (file)
@@ -132,8 +132,8 @@ QueryFilter::QueryFilter(const HAConfigPtr& config)
 
     // The returned configurations are not ordered. Let's iterate over them
     // and put them in the desired order.
-    for (auto peer_pair = peers_map.begin(); peer_pair != peers_map.end(); ++peer_pair) {
-        auto peer = peer_pair->second;
+    for (auto const& peer_pair : peers_map) {
+        auto peer = peer_pair.second;
         // The primary server is always first on the list.
         if (peer->getRole() == HAConfig::PeerConfig::PRIMARY) {
             peers_.insert(peers_.begin(), peer);
@@ -275,16 +275,16 @@ QueryFilter::serveFailoverScopesInternal() {
 
     // Iterate over the roles of all servers to see which scope should
     // be enabled.
-    for (auto peer = peers_.begin(); peer != peers_.end(); ++peer) {
+    for (auto const& peer : peers_) {
         // The scope of the primary server must always be served. If we're
         // doing load balancing, the scope of the secondary server also
         // has to be served. Regardless if I am primary or secondary,
         // I will start serving queries from both scopes. If I am a
         // standby server, I will start serving the scope of the primary
         // server.
-        if (((*peer)->getRole() == HAConfig::PeerConfig::PRIMARY) ||
-            ((*peer)->getRole() == HAConfig::PeerConfig::SECONDARY)) {
-            serveScopeInternal((*peer)->getName());
+        if ((peer->getRole() == HAConfig::PeerConfig::PRIMARY) ||
+            (peer->getRole() == HAConfig::PeerConfig::SECONDARY)) {
+            serveScopeInternal(peer->getName());
         }
     }
 }
@@ -304,8 +304,8 @@ QueryFilter::serveNoScopesInternal() {
     scopes_.clear();
 
     // Disable scope for each peer in the configuration.
-    for (auto peer = peers_.begin(); peer != peers_.end(); ++peer) {
-        scopes_[(*peer)->getName()] = false;
+    for (auto const& peer : peers_) {
+        scopes_[peer->getName()] = false;
     }
 }
 
index 52d1780b3ff26af483192950ec351c7cde8232bc..fbf22735e80c965929bf7bb62bfcb716fa83a634 100644 (file)
@@ -954,7 +954,7 @@ CommunicationStateTest::getRejectedLeaseUpdatesCountFromContainerTest() {
     // expiring in the future. Even entries have lifetimes expiring in
     // the past.
     Entries entries;
-    for (auto i = 0; i < 1000; i++) {
+    for (auto i = 0; i < 1000; ++i) {
         entries.insert({i, time(NULL) + (i % 2 ? 100 + i : -1 - i)});
     }
     // Get the count of valid entries. It should remove the expiring
index 800d31a2cd956651d7fe7812a401403f6dc699cf..5a783117be6190ba987e3547487440828c018374 100644 (file)
@@ -122,8 +122,8 @@ void generateTestLeases(std::vector<Lease6Ptr>& leases) {
 template<typename LeasesVec>
 ConstElementPtr getLeasesAsJson(const LeasesVec& leases) {
     ElementPtr leases_json = Element::createList();
-    for (auto l = leases.begin(); l != leases.end(); ++l) {
-        leases_json->add((*l)->toElement());
+    for (auto const& l : leases) {
+        leases_json->add(l->toElement());
     }
     return (leases_json);
 }
@@ -258,13 +258,13 @@ public:
     findRequest(const std::string& str1, const std::string& str2,
                 const std::string& str3 = "") {
         std::lock_guard<std::mutex> lk(mutex_);
-        for (auto r = requests_.begin(); r < requests_.end(); ++r) {
-            std::string request_as_string = (*r)->toString();
+        for (auto const& r : requests_) {
+            std::string request_as_string = r->toString();
             if (request_as_string.find(str1) != std::string::npos) {
                 if (request_as_string.find(str2) != std::string::npos) {
                     if (str3.empty() ||
                         (request_as_string.find(str3) != std::string::npos))
-                    return (*r);
+                    return (r);
                 }
             }
         }
index 243c6382eaad4e37e922ea1b92a75a298012d06b..7e344bba33b060d0858a1a7ff6dd9a3762bd5a48 100644 (file)
@@ -1319,23 +1319,21 @@ LeaseCmdsImpl::leaseGetAllHandler(CalloutHandle& handle) {
             }
 
             const std::vector<ElementPtr>& subnet_ids = subnets->listValue();
-            for (auto subnet_id = subnet_ids.begin();
-                 subnet_id != subnet_ids.end();
-                 ++subnet_id) {
-                if ((*subnet_id)->getType() != Element::integer) {
+            for (auto const& subnet_id : subnet_ids) {
+                if (subnet_id->getType() != Element::integer) {
                     isc_throw(BadValue, "listed subnet identifiers must be numbers");
                 }
 
                 if (v4) {
                     Lease4Collection leases =
-                        LeaseMgrFactory::instance().getLeases4((*subnet_id)->intValue());
+                        LeaseMgrFactory::instance().getLeases4(subnet_id->intValue());
                     for (auto const& lease : leases) {
                         ElementPtr lease_json = lease->toElement();
                         leases_json->add(lease_json);
                     }
                 } else {
                     Lease6Collection leases =
-                        LeaseMgrFactory::instance().getLeases6((*subnet_id)->intValue());
+                        LeaseMgrFactory::instance().getLeases6(subnet_id->intValue());
                     for (auto const& lease : leases) {
                         ElementPtr lease_json = lease->toElement();
                         leases_json->add(lease_json);
index c01874563d67524ebc54e8c39941630fbbb8971f..7caa51d737a6f426a4792c65570b7e25d63d66c5 100644 (file)
@@ -67,10 +67,10 @@ public:
         // we're interested in.
         if (l->getType() == isc::data::Element::list) {
             std::vector<isc::data::ElementPtr> e = l->listValue();
-            for (auto it = e.begin(); it != e.end(); ++it) {
-                isc::data::ConstElementPtr ip_address = (*it)->get("ip-address");
+            for (auto const& it : e) {
+                isc::data::ConstElementPtr ip_address = it->get("ip-address");
                 if (ip_address && ip_address->stringValue() == ip) {
-                    l = (*it);
+                    l = it;
                     break;
                 }
             }
index bc5e953fa5c93d9a9a2f9e28cab13d00d49f1141..1ff38c6e33d3ad6b368ac20e02a20734a3a68404 100644 (file)
@@ -68,10 +68,10 @@ public:
         // we're interested in.
         if (l->getType() == isc::data::Element::list) {
             std::vector<isc::data::ElementPtr> e = l->listValue();
-            for (auto it = e.begin(); it != e.end(); ++it) {
-                isc::data::ConstElementPtr ip_address = (*it)->get("ip-address");
+            for (auto const& it : e) {
+                isc::data::ConstElementPtr ip_address = it->get("ip-address");
                 if (ip_address && ip_address->stringValue() == ip) {
-                    l = (*it);
+                    l = it;
                     break;
                 }
             }
index 57720f4665f2771517d33fe0bd2343ed41be2bf8..4f3be11376892e34532be71e7685636b1bc80b5f 100644 (file)
@@ -177,24 +177,23 @@ public:
     /// @param cms a vector of string with command names
     void testCommands(const std::vector<std::string> cmds) {
         // The commands should not be registered yet.
-        for (auto cmd = cmds.begin(); cmd != cmds.end(); ++cmd) {
-            checkCommandRegistered(*cmd, false);
+        for (auto const& cmd : cmds) {
+            checkCommandRegistered(cmd, false);
         }
 
         loadLib();
 
         // The commands should be available after library was loaded.
-        for (auto cmd = cmds.begin(); cmd != cmds.end(); ++cmd) {
-            checkCommandRegistered(*cmd, true);
+        for (auto const& cmd : cmds) {
+            checkCommandRegistered(cmd, true);
         }
 
         unloadLibs();
 
         // and the commands should be gone now.
-        for (auto cmd = cmds.begin(); cmd != cmds.end(); ++cmd) {
-            checkCommandRegistered(*cmd, false);
+        for (auto const& cmd : cmds) {
+            checkCommandRegistered(cmd, false);
         }
-
     }
 
     // Check that the library can be loaded and unloaded multiple times.
index 53b67998a7e2394f89b365b9183de55f0a414df8..dc4ffca8561f53b39d6fa9caa0dfa5c426d51eed 100644 (file)
@@ -1036,10 +1036,8 @@ public:
         // Create JSON list of required classes.
         ElementPtr required_classes_element = Element::createList();
         auto const& required_classes = subnet->getRequiredClasses();
-        for (auto required_class = required_classes.cbegin();
-             required_class != required_classes.cend();
-             ++required_class) {
-            required_classes_element->add(Element::create(*required_class));
+        for (auto const& required_class : required_classes) {
+            required_classes_element->add(Element::create(required_class));
         }
 
         // Create binding for DDNS replace client name mode.
@@ -1170,8 +1168,8 @@ public:
         auto option_spaces = subnet->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = subnet->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption4(server_selector, subnet->getID(), desc_copy,
                                     true);
@@ -1205,8 +1203,8 @@ public:
         auto option_spaces = pool->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = pool->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption4(server_selector, pool_id, desc_copy, true);
             }
@@ -1800,8 +1798,8 @@ public:
         auto option_spaces = shared_network->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = shared_network->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption4(server_selector, shared_network->getName(),
                                     desc_copy, true);
@@ -2749,8 +2747,8 @@ public:
             auto option_spaces = option_defs.getOptionSpaceNames();
             for (auto const& option_space : option_spaces) {
                 OptionDefContainerPtr defs = option_defs.getItems(option_space);
-                for (auto def = defs->begin(); def != defs->end(); ++def) {
-                    createUpdateOptionDef4(server_selector, *def, client_class->getName());
+                for (auto const& def : *defs) {
+                    createUpdateOptionDef4(server_selector, def, client_class->getName());
                 }
             }
         }
@@ -2759,8 +2757,8 @@ public:
         auto option_spaces = client_class->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = client_class->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption4(server_selector, client_class, desc_copy);
             }
index 1ab8655f99af5910d818e6378f0cac03e86b02a8..90368c8f8d0c2e96da5e987537e846d5330404c1 100644 (file)
@@ -1278,10 +1278,8 @@ public:
         // Create JSON list of required classes.
         ElementPtr required_classes_element = Element::createList();
         auto const& required_classes = subnet->getRequiredClasses();
-        for (auto required_class = required_classes.cbegin();
-             required_class != required_classes.cend();
-             ++required_class) {
-            required_classes_element->add(Element::create(*required_class));
+        for (auto const& required_class : required_classes) {
+            required_classes_element->add(Element::create(required_class));
         }
 
         // Create binding for DDNS replace client name mode.
@@ -1427,8 +1425,8 @@ public:
         auto option_spaces = subnet->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = subnet->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption6(server_selector, subnet->getID(), desc_copy,
                                     true);
@@ -1463,8 +1461,8 @@ public:
         auto option_spaces = pool->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = pool->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption6(server_selector, Lease::TYPE_NA,
                                     pool_id, desc_copy, true);
@@ -1514,8 +1512,8 @@ public:
         auto option_spaces = pd_pool->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = pd_pool->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption6(server_selector, Lease::TYPE_PD,
                                     pd_pool_id, desc_copy, true);
@@ -2139,8 +2137,8 @@ public:
         auto option_spaces = shared_network->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = shared_network->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption6(server_selector, shared_network->getName(),
                                     desc_copy, true);
@@ -3176,8 +3174,8 @@ public:
             auto option_spaces = option_defs.getOptionSpaceNames();
             for (auto const& option_space : option_spaces) {
                 OptionDefContainerPtr defs = option_defs.getItems(option_space);
-                for (auto def = defs->begin(); def != defs->end(); ++def) {
-                    createUpdateOptionDef6(server_selector, *def, client_class->getName());
+                for (auto const& def : *defs) {
+                    createUpdateOptionDef6(server_selector, def, client_class->getName());
                 }
             }
         }
@@ -3186,8 +3184,8 @@ public:
         auto option_spaces = client_class->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = client_class->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption6(server_selector, client_class, desc_copy);
             }
index c4f84da36cc5e4c9e0f895d78d219e9386906984..fa032b9aa436f515f24ab135388c23ed02fd72bc 100644 (file)
@@ -634,10 +634,8 @@ public:
         // Create JSON list of required classes.
         data::ElementPtr required_classes_element = data::Element::createList();
         auto const& required_classes = object->getRequiredClasses();
-        for (auto required_class = required_classes.cbegin();
-             required_class != required_classes.cend();
-             ++required_class) {
-            required_classes_element->add(data::Element::create(*required_class));
+        for (auto const& required_class : required_classes) {
+            required_classes_element->add(data::Element::create(required_class));
         }
 
         return (required_classes_element ?
index 9b99b31a0d7e289e2b3c0283dc03bd1b49d3b2ec..31badd2ca55ed704eb2a43eb801315e89af72fb6 100644 (file)
@@ -1010,8 +1010,8 @@ public:
         auto option_spaces = subnet->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = subnet->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption4(server_selector, subnet->getID(), desc_copy,
                                     true);
@@ -1050,8 +1050,8 @@ public:
         auto option_spaces = pool->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = pool->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption4(server_selector, pool_id, desc_copy, true);
             }
@@ -1576,8 +1576,8 @@ public:
         auto option_spaces = shared_network->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = shared_network->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption4(server_selector, shared_network->getName(),
                                     desc_copy, true);
@@ -2550,8 +2550,8 @@ public:
             auto option_spaces = option_defs.getOptionSpaceNames();
             for (auto const& option_space : option_spaces) {
                 OptionDefContainerPtr defs = option_defs.getItems(option_space);
-                for (auto def = defs->begin(); def != defs->end(); ++def) {
-                    createUpdateOptionDef4(server_selector, *def, client_class->getName());
+                for (auto const& def : *defs) {
+                    createUpdateOptionDef4(server_selector, def, client_class->getName());
                 }
             }
         }
@@ -2560,8 +2560,8 @@ public:
         auto option_spaces = client_class->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = client_class->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption4(server_selector, client_class, desc_copy);
             }
index 4595a0a5b9ec7b9aa7e4396f84be7d4c524b1622..f7e1accc95ee7685acb0a679c7eb8865b72fb63d 100644 (file)
@@ -1185,8 +1185,8 @@ public:
         auto option_spaces = subnet->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = subnet->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption6(server_selector, subnet->getID(), desc_copy,
                                     true);
@@ -1225,8 +1225,8 @@ public:
         auto option_spaces = pool->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = pool->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption6(server_selector, Lease::TYPE_NA,
                                     pool_id, desc_copy, true);
@@ -1279,8 +1279,8 @@ public:
         auto option_spaces = pd_pool->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = pd_pool->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption6(server_selector, Lease::TYPE_PD,
                                     pd_pool_id, desc_copy, true);
@@ -1813,8 +1813,8 @@ public:
         auto option_spaces = shared_network->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = shared_network->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption6(server_selector, shared_network->getName(),
                                     desc_copy, true);
@@ -2872,8 +2872,8 @@ public:
             auto option_spaces = option_defs.getOptionSpaceNames();
             for (auto const& option_space : option_spaces) {
                 OptionDefContainerPtr defs = option_defs.getItems(option_space);
-                for (auto def = defs->begin(); def != defs->end(); ++def) {
-                    createUpdateOptionDef6(server_selector, *def, client_class->getName());
+                for (auto const& def : *defs) {
+                    createUpdateOptionDef6(server_selector, def, client_class->getName());
                 }
             }
         }
@@ -2882,8 +2882,8 @@ public:
         auto option_spaces = client_class->getCfgOption()->getOptionSpaceNames();
         for (auto const& option_space : option_spaces) {
             OptionContainerPtr options = client_class->getCfgOption()->getAll(option_space);
-            for (auto desc = options->begin(); desc != options->end(); ++desc) {
-                OptionDescriptorPtr desc_copy = OptionDescriptor::create(*desc);
+            for (auto const& desc : *options) {
+                OptionDescriptorPtr desc_copy = OptionDescriptor::create(desc);
                 desc_copy->space_name_ = option_space;
                 createUpdateOption6(server_selector, client_class, desc_copy);
             }
index a5cefeea1799311134609a6b2f223be21a6c9096..5eb707d28a5f1a4fadfd4077e0de67fff150abc4 100644 (file)
@@ -601,10 +601,8 @@ public:
         // Create JSON list of required classes.
         data::ElementPtr required_classes_element = data::Element::createList();
         auto const& required_classes = object->getRequiredClasses();
-        for (auto required_class = required_classes.cbegin();
-             required_class != required_classes.cend();
-             ++required_class) {
-            required_classes_element->add(data::Element::create(*required_class));
+        for (auto const& required_class : required_classes) {
+            required_classes_element->add(data::Element::create(required_class));
         }
 
         bindings.add(required_classes_element);
index 4e17695d20909cebfe35ad242f49ed7a78d78663..6ba4a1300445cc66dc4b41ef36f50abc12334f56 100644 (file)
@@ -676,8 +676,8 @@ LeaseStatCmdsImpl::createResultSet(const ElementPtr &result_wrapper,
 
     // Create the list of column names and add it to the result set.
     ElementPtr columns = Element::createList();
-    for (auto label = column_labels.begin(); label != column_labels.end(); ++label) {
-        columns->add(Element::create(*label));
+    for (auto const& label : column_labels) {
+        columns->add(Element::create(label));
     }
     result_set->set("columns", columns);
 
index 8037209726f8453826c2977068f59f38f1bece59..cd62dec3c10b1452b8e981c4c6e92c91fc94bbc9 100644 (file)
@@ -249,22 +249,22 @@ public:
     void testCommands(const std::vector<string> cmds) {
 
         // The commands should not be registered yet.
-        for (auto cmd = cmds.begin(); cmd != cmds.end(); ++cmd) {
-            checkCommandRegistered(*cmd, false);
+        for (auto const& cmd : cmds) {
+            checkCommandRegistered(cmd, false);
         }
 
         loadLib();
 
         // The commands should be available after library was loaded.
-        for (auto cmd = cmds.begin(); cmd != cmds.end(); ++cmd) {
-            checkCommandRegistered(*cmd, true);
+        for (auto const& cmd : cmds) {
+            checkCommandRegistered(cmd, true);
         }
 
         unloadLibs();
 
         // and the commands should be gone now.
-        for (auto cmd = cmds.begin(); cmd != cmds.end(); ++cmd) {
-            checkCommandRegistered(*cmd, false);
+        for (auto const& cmd : cmds) {
+            checkCommandRegistered(cmd, false);
         }
 
     }
@@ -630,7 +630,7 @@ struct TestScenario {
     std::string description_;
     std::string command_txt_;
     std::string exp_response_;
-    std::string exp_result_json;
+    std::string exp_result_json_;
 };
 
 // Verifies detection of invalid v4 input parameters.
@@ -792,11 +792,9 @@ TEST_F(StatCmdsTest, StatLease4GetBadParams) {
         }
     };
 
-    for (auto test = tests.begin(); test != tests.end(); ++test) {
-        {
-        SCOPED_TRACE((*test).description_);
-        testCommand((*test).command_txt_, CONTROL_RESULT_ERROR,(*test).exp_response_);
-        }
+    for (auto const& test : tests) {
+        SCOPED_TRACE(test.description_);
+        testCommand(test.command_txt_, CONTROL_RESULT_ERROR, test.exp_response_);
     }
 }
 
@@ -990,14 +988,11 @@ TEST_F(StatCmdsTest, statLease4GetValid) {
         }
     };
 
-    for (auto test = tests.begin(); test != tests.end(); ++test) {
-        {
-        SCOPED_TRACE((*test).description_);
-        testCommand((*test).command_txt_, CONTROL_RESULT_SUCCESS,
-                    (*test).exp_response_, (*test).exp_result_json);
-        }
+    for (auto const& test : tests) {
+        SCOPED_TRACE(test.description_);
+        testCommand(test.command_txt_, CONTROL_RESULT_SUCCESS,
+                    test.exp_response_, test.exp_result_json_);
     }
-
 }
 
 // Verifies result content for valid v4 statistic commands that
@@ -1052,14 +1047,11 @@ TEST_F(StatCmdsTest, statLease4GetSubnetsNotFound) {
         }
     };
 
-    for (auto test = tests.begin(); test != tests.end(); ++test) {
-        {
-        SCOPED_TRACE((*test).description_);
-        testCommand((*test).command_txt_, CONTROL_RESULT_EMPTY,
-                    (*test).exp_response_, (*test).exp_result_json);
+    for (auto const& test : tests) {
+        SCOPED_TRACE(test.description_);
+        testCommand(test.command_txt_, CONTROL_RESULT_EMPTY,
+                    test.exp_response_, test.exp_result_json_);
         }
-    }
-
 }
 
 // Verifies detection of invalid v6 input parameters.
@@ -1221,11 +1213,9 @@ TEST_F(StatCmdsTest, StatLease6GetBadParams) {
         }
     };
 
-    for (auto test = tests.begin(); test != tests.end(); ++test) {
-        {
-        SCOPED_TRACE((*test).description_);
-        testCommand((*test).command_txt_, CONTROL_RESULT_ERROR,(*test).exp_response_);
-        }
+    for (auto const& test : tests) {
+        SCOPED_TRACE(test.description_);
+        testCommand(test.command_txt_, CONTROL_RESULT_ERROR, test.exp_response_);
     }
 }
 
@@ -1426,12 +1416,10 @@ TEST_F(StatCmdsTest, statLease6GetValid) {
         }
     };
 
-    for (auto test = tests.begin(); test != tests.end(); ++test) {
-        {
-        SCOPED_TRACE((*test).description_);
-        testCommand((*test).command_txt_, CONTROL_RESULT_SUCCESS,
-                    (*test).exp_response_, (*test).exp_result_json);
-        }
+    for (auto const& test : tests) {
+        SCOPED_TRACE(test.description_);
+        testCommand(test.command_txt_, CONTROL_RESULT_SUCCESS,
+                    test.exp_response_, test.exp_result_json_);
     }
 
 }
@@ -1488,12 +1476,10 @@ TEST_F(StatCmdsTest, statLease6GetSubnetsNotFound) {
         }
     };
 
-    for (auto test = tests.begin(); test != tests.end(); ++test) {
-        {
-        SCOPED_TRACE((*test).description_);
-        testCommand((*test).command_txt_, CONTROL_RESULT_EMPTY,
-                    (*test).exp_response_, (*test).exp_result_json);
-        }
+    for (auto const& test : tests) {
+        SCOPED_TRACE(test.description_);
+        testCommand(test.command_txt_, CONTROL_RESULT_EMPTY,
+                    test.exp_response_, test.exp_result_json_);
     }
 }
 
@@ -1540,12 +1526,10 @@ TEST_F(StatCmdsTest, statLease4OrphanedStats) {
         }
     };
 
-    for (auto test = tests.begin(); test != tests.end(); ++test) {
-        {
-        SCOPED_TRACE((*test).description_);
-        testCommand((*test).command_txt_, CONTROL_RESULT_SUCCESS,
-                    (*test).exp_response_, (*test).exp_result_json);
-        }
+    for (auto const& test : tests) {
+        SCOPED_TRACE(test.description_);
+        testCommand(test.command_txt_, CONTROL_RESULT_SUCCESS,
+                    test.exp_response_, test.exp_result_json_);
     }
 }
 
@@ -1593,12 +1577,10 @@ TEST_F(StatCmdsTest, statLease6OrphanedStats) {
         }
     };
 
-    for (auto test = tests.begin(); test != tests.end(); ++test) {
-        {
-        SCOPED_TRACE((*test).description_);
-        testCommand((*test).command_txt_, CONTROL_RESULT_SUCCESS,
-                    (*test).exp_response_, (*test).exp_result_json);
-        }
+    for (auto const& test : tests) {
+        SCOPED_TRACE(test.description_);
+        testCommand(test.command_txt_, CONTROL_RESULT_SUCCESS,
+                    test.exp_response_, test.exp_result_json_);
     }
 }
 
index 531a486d23c283240f5a2fb68603246654e1c40c..09c6c8a57321fdeeb53daa041782a69d5fc91daf 100644 (file)
@@ -85,14 +85,13 @@ UserId::toText(char delim_char) const {
     std::stringstream tmp;
     tmp << std::hex;
     bool delim = false;
-    for (std::vector<uint8_t>::const_iterator it = id_.begin();
-         it != id_.end(); ++it) {
+    for (auto const& it : id_) {
         if (delim_char && delim) {
             tmp << delim_char;
         }
 
         tmp << std::setw(2) << std::setfill('0')
-            << static_cast<unsigned int>(*it);
+            << static_cast<unsigned int>(it);
         delim = true;
     }
 
index 4f493cf04a9d52b3662bebff87fc0eb88a394630..25dc6890c7a043883427693877569e7409320e36 100644 (file)
@@ -10,7 +10,6 @@
 #include <user.h>
 #include <user_file.h>
 
-#include <boost/foreach.hpp>
 #include <errno.h>
 #include <iostream>
 
@@ -87,7 +86,7 @@ UserFile::makeUser(const std::string& user_string) {
     // respective locals.  Anything else is assumed to be an option so
     // add it to the local property map.
     std::pair<std::string, isc::data::ConstElementPtr> element_pair;
-    BOOST_FOREACH (element_pair, elements->mapValue()) {
+    for (auto const& element_pair : elements->mapValue()) {
         // Get the element's label.
         std::string label = element_pair.first;
 
index b1139402df2c9340f6a1d555e48bb2e00ff0461f..58239989d5f739cc7d0556b671d0f30c6ccb081c 100644 (file)
@@ -22,7 +22,7 @@ using namespace isc::asiolink;
 TEST(IOAddressHashTest, hashIPv4) {
     IOAddress::Hash hash;
     std::unordered_set<size_t> results;
-    for (uint32_t i = 0; i < 10; i++) {
+    for (uint32_t i = 0; i < 10; ++i) {
         IOAddress address(i);
         auto result = hash(address);
         results.insert(result);
@@ -35,7 +35,7 @@ TEST(IOAddressHashTest, hashIPv4) {
 TEST(IOAddressHashTest, hashIPv6) {
     IOAddress::Hash hash;
     std::unordered_set<size_t> results;
-    for (auto i = 0; i < 10; i++) {
+    for (auto i = 0; i < 10; ++i) {
         std::ostringstream s;
         s << "2001:db8:" << i << "::ffff";
         IOAddress address(s.str());
index c0bd45ac5f21a50c49a793e20c49fc80f294437a..e17e1e671afb09f1ad2bd0335130a612ab94714a 100644 (file)
@@ -193,9 +193,8 @@ public:
 
     /// @brief Stops all connections.
     void stopAll() {
-        for (auto conn = connections_.begin(); conn != connections_.end();
-             ++conn) {
-            (*conn)->stop();
+        for (auto const& conn : connections_) {
+            conn->stop();
         }
         connections_.clear();
     }
index ebef7d7d54e7dea83566c2bdf53c2c41bc1108c6..79106251376aa602ba2d72f740dd43730dc0906d 100644 (file)
@@ -298,17 +298,17 @@ combineCommandsLists(const ConstElementPtr& response1,
         // Storing command names in a set guarantees that the non-unique
         // command names are aggregated.
         std::set<std::string> combined_set;
-        for (auto v = vec1.cbegin(); v != vec1.cend(); ++v) {
-            combined_set.insert((*v)->stringValue());
+        for (auto const& v : vec1) {
+            combined_set.insert(v->stringValue());
         }
-        for (auto v = vec2.cbegin(); v != vec2.cend(); ++v) {
-            combined_set.insert((*v)->stringValue());
+        for (auto const& v : vec2) {
+            combined_set.insert(v->stringValue());
         }
 
         // Create a combined list of commands.
         ElementPtr combined_list = Element::createList();
-        for (auto s = combined_set.cbegin(); s != combined_set.cend(); ++s) {
-            combined_list->add(Element::create(*s));
+        for (auto const& s : combined_set) {
+            combined_list->add(Element::create(s));
         }
         return (createAnswer(CONTROL_RESULT_SUCCESS, combined_list));
     }
index abcb0fbc4f9299651b163ade5d745961a5cfa7d6..6e1892608710de4a16ecc68c897e6bea5bef59ce 100644 (file)
@@ -923,11 +923,14 @@ ListElement::toJSON(std::ostream& ss) const {
     ss << "[ ";
 
     const std::vector<ElementPtr>& v = listValue();
-    for (auto it = v.begin(); it != v.end(); ++it) {
-        if (it != v.begin()) {
+    bool first = true;
+    for (auto const& it : v) {
+        if (!first) {
             ss << ", ";
+        } else {
+            first = false;
         }
-        (*it)->toJSON(ss);
+        it->toJSON(ss);
     }
     ss << " ]";
 }
@@ -936,13 +939,16 @@ void
 MapElement::toJSON(std::ostream& ss) const {
     ss << "{ ";
 
-    for (auto it = m.begin(); it != m.end(); ++it) {
-        if (it != m.begin()) {
+    bool first = true;
+    for (auto const& it : m) {
+        if (!first) {
             ss << ", ";
+        } else {
+            first = false;
         }
-        ss << "\"" << (*it).first << "\": ";
-        if ((*it).second) {
-            (*it).second->toJSON(ss);
+        ss << "\"" << it.first << "\": ";
+        if (it.second) {
+            it.second->toJSON(ss);
         } else {
             ss << "None";
         }
@@ -1218,14 +1224,14 @@ mergeDiffAdd(ElementPtr& element, ElementPtr& other,
         // Store new elements in a separate container so we don't overwrite
         // options as we add them (if there are duplicates).
         ElementPtr new_elements = Element::createList();
-        for (auto& right : other->listValue()) {
+        for (auto const& right : other->listValue()) {
             // Check if we have any description of the key in the configuration
             // hierarchy.
             auto f = hierarchy[idx].find(key);
             if (f != hierarchy[idx].end()) {
                 bool found = false;
                 ElementPtr mutable_right = boost::const_pointer_cast<Element>(right);
-                for (auto& left : element->listValue()) {
+                for (auto const& left : element->listValue()) {
                     ElementPtr mutable_left = boost::const_pointer_cast<Element>(left);
                     // Check if the elements refer to the same configuration
                     // entity.
@@ -1242,7 +1248,7 @@ mergeDiffAdd(ElementPtr& element, ElementPtr& other,
             }
         }
         // Finally add the new elements.
-        for (auto& right : new_elements->listValue()) {
+        for (auto const& right : new_elements->listValue()) {
             element->add(right);
         }
         return;
@@ -1367,13 +1373,13 @@ extend(const std::string& container, const std::string& extension,
     }
 
     if (element->getType() == Element::list) {
-        for (auto& right : other->listValue()) {
+        for (auto const& right : other->listValue()) {
             // Check if we have any description of the key in the configuration
             // hierarchy.
             auto f = hierarchy[idx].find(key);
             if (f != hierarchy[idx].end()) {
                 ElementPtr mutable_right = boost::const_pointer_cast<Element>(right);
-                for (auto& left : element->listValue()) {
+                for (auto const& left : element->listValue()) {
                     ElementPtr mutable_left = boost::const_pointer_cast<Element>(left);
                     if (container == key) {
                         alter = true;
@@ -1566,17 +1572,20 @@ prettyPrint(ConstElementPtr element, std::ostream& out,
 
         // iterate on items
         auto const& l = element->listValue();
-        for (auto it = l.begin(); it != l.end(); ++it) {
+        bool first = true;
+        for (auto const& it : l) {
             // add the separator if not the first item
-            if (it != l.begin()) {
+            if (!first) {
                 out << separator;
+            } else {
+                first = false;
             }
             // add indentation
             if (complex) {
                 out << std::string(indent + step, ' ');
             }
             // recursive call
-            prettyPrint(*it, out, indent + step, step);
+            prettyPrint(it, out, indent + step, step);
         }
 
         // close the list
@@ -1599,7 +1608,7 @@ prettyPrint(ConstElementPtr element, std::ostream& out,
         // iterate on keyword: value
         auto const& m = element->mapValue();
         bool first = true;
-        for (auto it = m.begin(); it != m.end(); ++it) {
+        for (auto const& it : m) {
             // add the separator if not the first item
             if (first) {
                 first = false;
@@ -1609,9 +1618,9 @@ prettyPrint(ConstElementPtr element, std::ostream& out,
             // add indentation
             out << std::string(indent + step, ' ');
             // add keyword:
-            out << "\"" << it->first << "\": ";
+            out << "\"" << it.first << "\": ";
             // recursive call
-            prettyPrint(it->second, out, indent + step, step);
+            prettyPrint(it.second, out, indent + step, step);
         }
 
         // close the map
index 314d2888c383441abd674d2806d3bac0457311b6..7506d69d94ce8d96e89247b698d8489af0e1eebb 100644 (file)
@@ -8,7 +8,6 @@
 
 #include <cc/simple_parser.h>
 #include <asiolink/io_address.h>
-#include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
 #include <cc/data.h>
 #include <string>
@@ -178,7 +177,7 @@ size_t SimpleParser::setDefaults(ElementPtr scope,
     const Element::Position pos("<default-value>", 0, 0);
 
     // Let's go over all parameters we have defaults for.
-    BOOST_FOREACH(SimpleDefault def_value, default_values) {
+    for (auto const& def_value : default_values) {
 
         // Try if such a parameter is there. If it is, let's
         // skip it, because user knows best *cough*.
@@ -245,7 +244,7 @@ size_t
 SimpleParser::setListDefaults(ConstElementPtr list,
                               const SimpleDefaults& default_values) {
     size_t cnt = 0;
-    BOOST_FOREACH(ElementPtr entry, list->listValue()) {
+    for (auto const& entry : list->listValue()) {
         cnt += setDefaults(entry, default_values);
     }
     return (cnt);
@@ -261,7 +260,7 @@ SimpleParser::deriveParams(ConstElementPtr parent,
     }
 
     size_t cnt = 0;
-    BOOST_FOREACH(string param, params) {
+    for (auto const& param : params) {
         ConstElementPtr x = parent->get(param);
         if (!x) {
             // Parent doesn't define this parameter, so there's
index ff1d2d86c0b5453b971430670615645952008876..74bfa0585d365be05e575724fec2b71612a40297 100644 (file)
@@ -183,9 +183,8 @@ BaseCommandMgr::listCommandsHandler(const std::string& /* name */,
                                     const isc::data::ConstElementPtr& ) {
     using namespace isc::data;
     ElementPtr commands = Element::createList();
-    for (HandlerContainer::const_iterator it = handlers_.begin();
-         it != handlers_.end(); ++it) {
-        commands->add(Element::create(it->first));
+    for (auto const& it : handlers_) {
+        commands->add(Element::create(it.first));
     }
     return (createAnswer(CONTROL_RESULT_SUCCESS, commands));
 }
index 831d56e78cb61cc21ee505bbcc68c24584d67715..cd42f1c3ad7aede04258194e59e45a885f0ca60c 100644 (file)
@@ -262,9 +262,8 @@ public:
 
     /// @brief Stops all connections which are allowed to stop.
     void stopAll() {
-        for (auto conn = connections_.begin(); conn != connections_.end();
-             ++conn) {
-            (*conn)->stop();
+        for (auto const& conn : connections_) {
+            conn->stop();
         }
         connections_.clear();
     }
index 4674080483c22a1e2379aa76ea93d1a7c8d0e101..2a1c71e39f813a76ff77b0984394901ff6f046ac 100644 (file)
@@ -99,13 +99,13 @@ HookedCommandMgr::handleCommand(const std::string& cmd_name,
         // Only update the response if there are any hooks present.
         if (!hooks.empty()) {
             ElementPtr hooks_commands = Element::createList();
-            for (auto h = hooks.cbegin(); h != hooks.end(); ++h) {
+            for (auto const& h : hooks) {
                 // Try to convert hook name to command name. If non-empty
                 // string is returned it means that the hook point may have
                 // command handlers associated with it. Otherwise, it means that
                 // existing hook points are not for command handlers but for
                 // regular callouts.
-                std::string command_name = ServerHooks::hookToCommandName(*h);
+                std::string command_name = ServerHooks::hookToCommandName(h);
                 if (!command_name.empty()) {
                     // Final check: are command handlers registered for this
                     // hook point? If there are no command handlers associated,
index e558ce3944a76edccabb60363bfdd6a5a37f7286..e5893498191e568a07b52dfff1019c35898e0a89 100644 (file)
@@ -80,8 +80,8 @@ public:
         // Iterate over existing hook points and for each of them remove
         // callouts registered.
         std::vector<std::string> hooks = ServerHooks::getServerHooksPtr()->getHookNames();
-        for (auto h = hooks.cbegin(); h != hooks.cend(); ++h) {
-            HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts(*h);
+        for (auto const& h : hooks) {
+            HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts(h);
         }
     }
 
@@ -418,9 +418,8 @@ TEST_F(CommandMgrTest, delegateListCommands) {
     const std::vector<ElementPtr>& commands_list = answer_arg->listValue();
     ASSERT_EQ(3, commands_list.size());
     std::vector<std::string> command_names_list;
-    for (auto cmd = commands_list.cbegin(); cmd != commands_list.cend();
-         ++cmd) {
-        command_names_list.push_back((*cmd)->stringValue());
+    for (auto const& cmd : commands_list) {
+        command_names_list.push_back(cmd->stringValue());
     }
     std::sort(command_names_list.begin(), command_names_list.end());
     EXPECT_EQ("list-commands", command_names_list[0]);
index 17ac59b2317a17c09aa8bb3211c322646f3a9bac..48a84c9776b7442f598af25da0301f529e47bfb7 100644 (file)
@@ -12,8 +12,7 @@
 #include <cc/command_interpreter.h>
 #include <config/base_command_mgr.h>
 #include <util/encode/hex.h>
-
-#include <boost/foreach.hpp>
+#include <boost/range/adaptor/reversed.hpp>
 
 using namespace isc::asiolink;
 using namespace isc::config;
@@ -95,9 +94,8 @@ D2CfgContext::toElement() const {
     d2->set("reverse-ddns", reverse_ddns);
     // Set tsig-keys
     ElementPtr tsig_keys = Element::createList();
-    for (TSIGKeyInfoMap::const_iterator key = keys_->begin();
-         key != keys_->end(); ++key) {
-        tsig_keys->add(key->second->toElement());
+    for (auto const& key : *keys_) {
+        tsig_keys->add(key.second->toElement());
     }
     d2->set("tsig-keys", tsig_keys);
     // Set control-socket (skip if null as empty is not legal)
@@ -198,16 +196,8 @@ D2CfgMgr::reverseV4Address(const isc::asiolink::IOAddress& ioaddr) {
     // Walk backwards through vector outputting each octet and a dot.
     std::ostringstream stream;
 
-    // We have to set the following variable to get
-    // const_reverse_iterator type of rend(), otherwise Solaris GCC
-    // complains on operator!= by trying to use the non-const variant.
-    const ByteAddress::const_reverse_iterator end = bytes.rend();
-
-    for (ByteAddress::const_reverse_iterator rit = bytes.rbegin();
-         rit != end;
-         ++rit)
-    {
-        stream << static_cast<unsigned int>(*rit) << ".";
+    for (auto const& rit : boost::adaptors::reverse(bytes)) {
+        stream << static_cast<unsigned int>(rit) << ".";
     }
 
     // Tack on the suffix and we're done.
@@ -228,16 +218,8 @@ D2CfgMgr::reverseV6Address(const isc::asiolink::IOAddress& ioaddr) {
     // Walk backwards through string outputting each digits and a dot.
     std::ostringstream stream;
 
-    // We have to set the following variable to get
-    // const_reverse_iterator type of rend(), otherwise Solaris GCC
-    // complains on operator!= by trying to use the non-const variant.
-    const std::string::const_reverse_iterator end = digits.rend();
-
-    for (std::string::const_reverse_iterator rit = digits.rbegin();
-         rit != end;
-         ++rit)
-    {
-        stream << static_cast<char>(*rit) << ".";
+    for (auto const& rit : boost::adaptors::reverse(digits)) {
+        stream << static_cast<char>(rit) << ".";
     }
 
     // Tack on the suffix and we're done.
index c75281b5f631f97cdf140d56690dcac2881d75ae..ff416459416dee21020d6cb299e731221c1fa9ce 100644 (file)
@@ -12,7 +12,6 @@
 #include <exceptions/exceptions.h>
 #include <asiolink/io_error.h>
 
-#include <boost/foreach.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <boost/algorithm/string/predicate.hpp>
 
@@ -270,9 +269,8 @@ DdnsDomain::toElement() const {
     result->set("name", Element::create(name_));
     // Set servers
     ElementPtr servers = Element::createList();
-    for (DnsServerInfoStorage::const_iterator server = servers_->begin();
-         server != servers_->end(); ++server) {
-        ElementPtr dns_server = (*server)->toElement();
+    for (auto const& server : *servers_) {
+        ElementPtr dns_server = server->toElement();
         servers->add(dns_server);
     }
     // the dns server list may not be empty
@@ -330,9 +328,8 @@ DdnsDomainListMgr::matchDomain(const std::string& fqdn, DdnsDomainPtr& domain) {
 
     size_t req_len = fqdn.size();
     size_t match_len = 0;
-    DdnsDomainMapPair map_pair;
     DdnsDomainPtr best_match;
-    BOOST_FOREACH (map_pair, *domains_) {
+    for (auto const& map_pair : *domains_) {
         std::string domain_name = map_pair.first;
         size_t dom_len = domain_name.size();
 
@@ -386,9 +383,8 @@ ElementPtr
 DdnsDomainListMgr::toElement() const {
     ElementPtr result = Element::createList();
     // Iterate on ddns domains
-    for (DdnsDomainMap::const_iterator domain = domains_->begin();
-         domain != domains_->end(); ++domain) {
-        ElementPtr ddns_domain = domain->second->toElement();
+    for (auto const& domain : *domains_) {
+        ElementPtr ddns_domain = domain.second->toElement();
         result->add(ddns_domain);
     }
 
@@ -457,9 +453,8 @@ TSIGKeyInfoParser::parse(ConstElementPtr key_config) {
 TSIGKeyInfoMapPtr
 TSIGKeyInfoListParser::parse(ConstElementPtr key_list) {
     TSIGKeyInfoMapPtr keys(new TSIGKeyInfoMap());
-    ConstElementPtr key_config;
     TSIGKeyInfoParser key_parser;
-    BOOST_FOREACH(key_config, key_list->listValue()) {
+    for (auto const& key_config : key_list->listValue()) {
         TSIGKeyInfoPtr key = key_parser.parse(key_config);
 
         // Duplicates are not allowed and should be flagged as an error.
@@ -574,9 +569,8 @@ DnsServerInfoListParser::parse(ConstElementPtr server_list,
                                ConstElementPtr domain_config,
                                const TSIGKeyInfoMapPtr keys) {
     DnsServerInfoStoragePtr servers(new DnsServerInfoStorage());
-    ConstElementPtr server_config;
     DnsServerInfoParser parser;
-    BOOST_FOREACH(server_config, server_list->listValue()) {
+    for (auto const& server_config : server_list->listValue()) {
         DnsServerInfoPtr server =
             parser.parse(server_config, domain_config, keys);
         servers->push_back(server);
@@ -627,8 +621,7 @@ DdnsDomainMapPtr DdnsDomainListParser::parse(ConstElementPtr domain_list,
                                              const TSIGKeyInfoMapPtr keys) {
     DdnsDomainMapPtr domains(new DdnsDomainMap());
     DdnsDomainParser parser;
-    ConstElementPtr domain_config;
-    BOOST_FOREACH(domain_config, domain_list->listValue()) {
+    for (auto const& domain_config : domain_list->listValue()) {
         DdnsDomainPtr domain = parser.parse(domain_config, keys);
 
         // Duplicates are not allowed
index cb141ad6b77f6573f40dc01d87b620df6fc2ad53..56d1a332b5038e1dc494e34f3dd439fab0d13fe1 100644 (file)
@@ -17,8 +17,6 @@
 #include <exceptions/exceptions.h>
 #include <process/d_cfg_mgr.h>
 
-#include <boost/foreach.hpp>
-
 #include <stdint.h>
 #include <string>
 
index 8be6376272c393f1c5ec387556c11c6cee2ec4a5..b158188031023518b3e601bdfe87a542ff598fc0 100644 (file)
@@ -11,7 +11,6 @@
 #include <cc/data.h>
 #include <hooks/hooks_manager.h>
 #include <hooks/hooks_parser.h>
-#include <boost/foreach.hpp>
 
 using namespace isc::data;
 using namespace isc::d2;
@@ -185,7 +184,7 @@ D2SimpleParser::setManagerDefaults(ElementPtr global,
         // manager is disabled.
         if (mgr->find("ddns-domains")) {
             ConstElementPtr domains = mgr->get("ddns-domains");
-            BOOST_FOREACH(ElementPtr domain, domains->listValue()) {
+            for (auto const& domain : domains->listValue()) {
                 // Set the domain's defaults.  We can't use setListDefaults()
                 // as this does not handle sub-lists or maps, like server list.
                 cnt += setDdnsDomainDefaults(domain, DDNS_DOMAIN_DEFAULTS);
index 8da9bca1bcae530644b5121eae9384f1e5d4a3c5..03c450a60fc209a25c885712ebaeaa03c7f479fc 100644 (file)
@@ -15,7 +15,6 @@
 #include <util/strutil.h>
 
 #include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
 #include <vector>
 
 using namespace isc::asiolink;
@@ -80,7 +79,7 @@ DatabaseConnection::parse(const std::string& dbaccess) {
             // /usr/include/c++/4.4/bits/stl_algo.h:2178 "array subscript is above
             // array bounds"
             boost::split(tokens, dba, boost::is_any_of(string("\t ")));
-            BOOST_FOREACH(std::string token, tokens) {
+            for (auto const& token : tokens) {
                 size_t pos = token.find("=");
                 if (pos != string::npos) {
                     string name = token.substr(0, pos);
@@ -106,8 +105,7 @@ DatabaseConnection::redactedAccessString(const ParameterMap& parameters) {
     // Reconstruct the access string: start of with an empty string, then
     // work through all the parameters in the original string and add them.
     std::string access;
-    for (DatabaseConnection::ParameterMap::const_iterator i = parameters.begin();
-         i != parameters.end(); ++i) {
+    for (auto const& i : parameters) {
 
         // Separate second and subsequent tokens are preceded by a space.
         if (!access.empty()) {
@@ -115,15 +113,15 @@ DatabaseConnection::redactedAccessString(const ParameterMap& parameters) {
         }
 
         // Append name of parameter...
-        access += i->first;
+        access += i.first;
         access += "=";
 
         // ... and the value, except in the case of the password, where a
         // redacted value is appended.
-        if (i->first == std::string("password")) {
+        if (i.first == std::string("password")) {
             access += "*****";
         } else {
-            access += i->second;
+            access += i.second;
         }
     }
 
index 29322e07274a6e1681733a0499e088dcf2ad3d50..a288e0216fa1892455e28c607ebf213ead468134 100644 (file)
@@ -142,16 +142,15 @@ public:
 
         // Check that the keywords and keyword values are the same: loop
         // through the keywords in the database access string.
-        for (DatabaseConnection::ParameterMap::const_iterator actual = parameters.begin();
-             actual != parameters.end(); ++actual) {
+        for (auto const& actual : parameters) {
 
             // Does the keyword exist in the set of expected keywords?
             std::map<string, string>::iterator corresponding =
-                expected.find(actual->first);
+                expected.find(actual.first);
             ASSERT_TRUE(corresponding != expected.end());
 
             // Keyword exists, is the value the same?
-            EXPECT_EQ(corresponding->second, actual->second);
+            EXPECT_EQ(corresponding->second, actual.second);
         }
     }
 
index 9f1461604ebcdfe785a066fe874b94d6b9712e61..2ff5a0808405ff556ef2a273f50bb62a4ba61a37 100644 (file)
@@ -54,11 +54,14 @@ ClientClasses::contains(const ClientClass& x) const {
 std::string
 ClientClasses::toText(const std::string& separator) const {
     std::stringstream s;
-    for (const_iterator class_it = cbegin(); class_it != cend(); ++class_it) {
-        if (class_it != cbegin()) {
+    bool first = true;
+    for (auto const& class_it : *this) {
+        if (!first) {
             s << separator;
+        } else {
+            first = false;
         }
-        s << *class_it;
+        s << class_it;
     }
     return (s.str());
 }
@@ -66,7 +69,7 @@ ClientClasses::toText(const std::string& separator) const {
 ElementPtr
 ClientClasses::toElement() const {
     ElementPtr result(Element::createList());
-    for (const ClientClass& c : container_) {
+    for (auto const& c : container_) {
         result->add(Element::create(c));
     }
     return (result);
index 6f72cccb3a4f73b8c8fb2b9e3d93643ec013e495..a9f9172d4f8203c9b0d51370c49962f6ffb62d56 100644 (file)
@@ -85,7 +85,7 @@ public:
         std::stringstream tmp;
         tmp << std::hex;
         bool delim = false;
-        for (auto const data : data_) {
+        for (auto const& data : data_) {
             if (delim) {
                 tmp << ":";
             }
index 6303e9ea1f7c9893a3cabe193dff8dbd220849b2..d5019736f0b0fe65bd9ee23f6dd37161837187e4 100644 (file)
@@ -244,7 +244,7 @@ void
 DUIDFactory::createLinkLayerId(std::vector<uint8_t>& identifier,
                                uint16_t& htype) const {
     // Let's find suitable interface.
-    for (const IfacePtr& iface : IfaceMgr::instance().getIfaces()) {
+    for (auto const& iface : IfaceMgr::instance().getIfaces()) {
         // All the following checks could be merged into one multi-condition
         // statement, but let's keep them separated as perhaps one day
         // we will grow knobs to selectively turn them on or off. Also,
index 9416f2d412a9bea134885e8f14879369174e013e..6f26e08164feb55fdce08b617cfddd72341f4926 100644 (file)
@@ -55,12 +55,11 @@ std::string HWAddr::toText(bool include_htype) const {
     }
     tmp << std::hex;
     bool delim = false;
-    for (std::vector<uint8_t>::const_iterator it = hwaddr_.begin();
-         it != hwaddr_.end(); ++it) {
+    for (auto const& it : hwaddr_) {
         if (delim) {
             tmp << ":";
         }
-        tmp << std::setw(2) << std::setfill('0') << static_cast<unsigned int>(*it);
+        tmp << std::setw(2) << std::setfill('0') << static_cast<unsigned int>(it);
         delim = true;
     }
     return (tmp.str());
index 4ae0f0e85b6a9a1b0acb86c953738f3c78dc7373..e74f96080fecd28f16bfb05c5f11e48c7faf37ea 100644 (file)
@@ -114,14 +114,13 @@ IfaceMgr::detectIfaces(bool update_only) {
     freeifaddrs(iflist);
 
     // Interfaces registering
-    for (IfaceLst::const_iterator iface_iter = ifaces.begin();
-        iface_iter != ifaces.end(); ++iface_iter) {
+    for (auto const& iface_iter : ifaces) {
         IfacePtr iface;
         if (update_only) {
-            iface = getIface(iface_iter->first);
+            iface = getIface(iface_iter.first);
         }
         if (!iface) {
-            addInterface(iface_iter->second);
+            addInterface(iface_iter.second);
         }
     }
 }
index 1fb2aaf712500fa8b0512db74db2e049582064a2..55092388ff5176f345c0c60901aa514b9dc4a16b 100644 (file)
@@ -279,9 +279,8 @@ void Netlink::ipaddrs_get(Iface& iface, NetlinkMessages& addr_info) {
     uint8_t addr[V6ADDRESS_LEN];
     RTattribPtrs rta_tb;
 
-    for (NetlinkMessages::const_iterator msg = addr_info.begin();
-         msg != addr_info.end(); ++msg) {
-        ifaddrmsg* ifa = static_cast<ifaddrmsg*>(NLMSG_DATA(*msg));
+    for (auto const& msg : addr_info) {
+        ifaddrmsg* ifa = static_cast<ifaddrmsg*>(NLMSG_DATA(msg));
 
         // These are not the addresses you are looking for
         if (ifa->ifa_index != iface.getIndex()) {
@@ -290,7 +289,7 @@ void Netlink::ipaddrs_get(Iface& iface, NetlinkMessages& addr_info) {
 
         if ((ifa->ifa_family == AF_INET6) || (ifa->ifa_family == AF_INET)) {
             std::fill(rta_tb.begin(), rta_tb.end(), static_cast<rtattr*>(NULL));
-            parse_rtattr(rta_tb, IFA_RTA(ifa), (*msg)->nlmsg_len - NLMSG_LENGTH(sizeof(*ifa)));
+            parse_rtattr(rta_tb, IFA_RTA(ifa), msg->nlmsg_len - NLMSG_LENGTH(sizeof(*ifa)));
             if (!rta_tb[IFA_LOCAL]) {
                 rta_tb[IFA_LOCAL] = rta_tb[IFA_ADDRESS];
             }
@@ -396,8 +395,8 @@ void Netlink::rtnl_process_reply(NetlinkMessages& info) {
 /// @param messages Set of messages to be freed.
 void Netlink::release_list(NetlinkMessages& messages) {
     // let's free local copies of stored messages
-    for (NetlinkMessages::iterator msg = messages.begin(); msg != messages.end(); ++msg) {
-        delete[] (*msg);
+    for (auto const& msg : messages) {
+        delete[] msg;
     }
 
     // and get rid of the message pointers as well
@@ -462,11 +461,10 @@ void IfaceMgr::detectIfaces(bool update_only) {
     nl.rtnl_process_reply(addr_info);
 
     // Now build list with interface names
-    for (Netlink::NetlinkMessages::iterator msg = link_info.begin();
-         msg != link_info.end(); ++msg) {
+    for (auto const& msg : link_info) {
         // Required to display information about interface
-        struct ifinfomsg* interface_info = static_cast<ifinfomsg*>(NLMSG_DATA(*msg));
-        int len = (*msg)->nlmsg_len;
+        struct ifinfomsg* interface_info = static_cast<ifinfomsg*>(NLMSG_DATA(msg));
+        int len = msg->nlmsg_len;
         len -= NLMSG_LENGTH(sizeof(*interface_info));
         nl.parse_rtattr(attribs_table, IFLA_RTA(interface_info), len);
 
index f8ab65cb63f8dcf968b639b4facc6917533393cb..94dcbd7503df58e82821a427f365672096c41c37 100644 (file)
@@ -114,14 +114,13 @@ IfaceMgr::detectIfaces(bool update_only) {
     freeifaddrs(iflist);
 
     // Interfaces registering
-    for (IfaceLst::const_iterator iface_iter = ifaces.begin();
-        iface_iter != ifaces.end(); ++iface_iter) {
+    for (auto const& iface_iter : ifaces) {
         IfacePtr iface;
         if (update_only) {
-            iface = getIface(iface_iter->first);
+            iface = getIface(iface_iter.first);
         }
         if (!iface) {
-            addInterface(iface_iter->second);
+            addInterface(iface_iter.second);
         }
     }
 }
index 760765bc45aa3e62797abf43c713926041f28fcd..db2347633d18e7bafc1e5402f256e9b9da014f9a 100644 (file)
@@ -22,6 +22,7 @@
 #include <exceptions/isc_assert.h>
 #include <util/buffer.h>
 
+#include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/shared_array.hpp>
 #include <boost/shared_ptr.hpp>
@@ -694,9 +695,9 @@ extendVivco(OptionCollection& options) {
     typedef vector<OpaqueDataTuple> TuplesCollection;
     map<uint32_t, TuplesCollection> vendors_tuples;
     auto const& range = options.equal_range(DHO_VIVCO_SUBOPTIONS);
-    for (auto it = range.first; it != range.second; ++it) {
+    BOOST_FOREACH(auto const& it, range) {
         uint32_t offset = 0;
-        auto const& data = it->second->getData();
+        auto const& data = it.second->getData();
         size_t size;
         while ((size = data.size() - offset) != 0) {
             if (size < sizeof(uint32_t)) {
@@ -753,9 +754,9 @@ void
 extendVivso(OptionCollection& options) {
     map<uint32_t, OptionCollection> vendors_data;
     auto const& range = options.equal_range(DHO_VIVSO_SUBOPTIONS);
-    for (auto it = range.first; it != range.second; ++it) {
+    BOOST_FOREACH(auto const& it, range) {
         uint32_t offset = 0;
-        auto const& data = it->second->getData();
+        auto const& data = it.second->getData();
         size_t size;
         while ((size = data.size() - offset) != 0) {
             if (size < sizeof(uint32_t)) {
index 33e00495a7b8bb33630e5de98330cd191403e679..23717f17668058a3e38c32828111a6a6e524b782 100644 (file)
@@ -93,9 +93,8 @@ void Option4AddrLst::setAddresses(const AddressContainer& addrs) {
     // Do not copy it as a whole. addAddress() does sanity checks.
     // i.e. throw if someone tries to set IPv6 address.
     addrs_.clear();
-    for (AddressContainer::const_iterator addr = addrs.begin();
-         addr != addrs.end(); ++addr) {
-        addAddress(*addr);
+    for (auto const& addr : addrs) {
+        addAddress(addr);
     }
 }
 
@@ -116,9 +115,8 @@ std::string Option4AddrLst::toText(int indent) const {
     std::stringstream output;
     output << headerToText(indent) << ":";
 
-    for (AddressContainer::const_iterator addr = addrs_.begin();
-         addr != addrs_.end(); ++addr) {
-        output << " " << (*addr);
+    for (auto const& addr : addrs_) {
+        output << " " << addr;
     }
 
     return (output.str());
index a219d7c59b6e358ca7de72b6baa9ef69c03a2672..980097b2ff5269f7944406a5312e772776b8c8bd 100644 (file)
@@ -68,15 +68,14 @@ void Option6AddrLst::pack(isc::util::OutputBuffer& buf, bool) const {
     // len field contains length without 4-byte option header
     buf.writeUint16(len() - getHeaderLen());
 
-    for (AddressContainer::const_iterator addr=addrs_.begin();
-         addr!=addrs_.end(); ++addr) {
-        if (!addr->isV6()) {
-            isc_throw(isc::BadValue, addr->toText()
+    for (auto const& addr : addrs_) {
+        if (!addr.isV6()) {
+            isc_throw(isc::BadValue, addr.toText()
                       << " is not an IPv6 address");
         }
         // If an address is IPv6 address it should have assumed
         // length of V6ADDRESS_LEN.
-        buf.writeData(&addr->toBytes()[0], V6ADDRESS_LEN);
+        buf.writeData(&addr.toBytes()[0], V6ADDRESS_LEN);
     }
 }
 
@@ -97,9 +96,8 @@ std::string Option6AddrLst::toText(int indent) const {
     stringstream output;
     output << headerToText(indent) << ":";
 
-    for (AddressContainer::const_iterator addr = addrs_.begin();
-         addr != addrs_.end(); ++addr) {
-        output << " " << *addr;
+    for (auto const& addr : addrs_) {
+        output << " " << addr;
     }
     return (output.str());
 }
index 2b414903da4b932248dc48dd41871f3fdf101881..831834525bca4612d0df2f568a61177d526c16bf 100644 (file)
@@ -108,10 +108,8 @@ uint16_t Option6IA::len() const {
         OPTION6_IA_LEN  /* option content (12) */;
 
     // length of all suboptions
-    for (OptionCollection::const_iterator it = options_.begin();
-         it != options_.end();
-         ++it) {
-        length += (*it).second->len();
+    for (auto const& it : options_) {
+        length += it.second->len();
     }
     return (length);
 }
index 1737cd1f79f6e87f0ab38e9bc3226d78cf8f7383..9112e29f7318e79911f633b2d66b2e3df8683f80 100644 (file)
@@ -105,10 +105,8 @@ uint16_t Option6IAAddr::len() const {
     // length of all suboptions
     // TODO implement:
     // protected: unsigned short Option::lenHelper(int header_size);
-    for (OptionCollection::const_iterator it = options_.begin();
-         it != options_.end();
-         ++it) {
-        length += (*it).second->len();
+    for (auto const& it : options_) {
+        length += it.second->len();
     }
     return (length);
 }
index fcca8b0594f919332bc4ac37f7710679a0078c3f..7a5e2ab5f193269e6c36867fb921132ad4eff191 100644 (file)
@@ -112,9 +112,8 @@ uint16_t Option6IAPrefix::len() const {
     uint16_t length = OPTION6_HDR_LEN + OPTION6_IAPREFIX_LEN;
 
     // length of all suboptions
-    for (OptionCollection::const_iterator it = options_.begin();
-         it != options_.end(); ++it) {
-        length += (*it).second->len();
+    for (auto const& it : options_) {
+        length += it.second->len();
     }
     return (length);
 }
index 6b22b7ca2a0d1d0f3f81b69c7a10a92576590d03..2f2da8229ad8f7be9558e277bcfb1d897c9dd92b 100644 (file)
@@ -34,7 +34,7 @@ void
 OptionClasslessStaticRoute::pack(isc::util::OutputBuffer& buf, bool check) const {
     // Header = option code and length.
     packHeader(buf, check);
-    for (const auto& route : static_routes_) {
+    for (auto const& route : static_routes_) {
         // 1-5 octets of destination descriptor
         auto dest = encodeDestinationDescriptor(route);
         buf.writeData(&dest[0], dest.size());
@@ -76,7 +76,7 @@ OptionClasslessStaticRoute::toText(int indent) const {
     stream << in << "type=" << type_ << "(CLASSLESS_STATIC_ROUTE), "
            << "len=" << (len() - getHeaderLen());
     int i = 0;
-    for (const auto& route : static_routes_) {
+    for (auto const& route : static_routes_) {
         stream << ", Route " << ++i << " (subnet " << std::get<0>(route).toText() << "/"
                << static_cast<int>(std::get<1>(route)) << ", router IP "
                << std::get<2>(route).toText() << ")";
@@ -119,7 +119,7 @@ OptionClasslessStaticRoute::calcSignificantOctets(const uint8_t& mask_width) {
 void
 OptionClasslessStaticRoute::calcDataLen() {
     uint16_t len = 0;
-    for (const auto& route : static_routes_) {
+    for (auto const& route : static_routes_) {
         // 1-5 octets of destination descriptor
         len += calcSignificantOctets(std::get<1>(route)) + 1;
         // IP address of the router
@@ -200,7 +200,7 @@ void
 OptionClasslessStaticRoute::parseConfigData(const std::string& config_txt) {
     // this option allows more than one static route, so let's separate them using comma
     std::vector<std::string> tokens = str::tokens(config_txt, std::string(","));
-    for (const auto& route_str : tokens) {
+    for (auto const& route_str : tokens) {
         std::vector<std::string> parts = str::tokens(str::trim(route_str), std::string("-"));
         if (parts.size() != 2) {
             isc_throw(BadValue, "DHCPv4 OptionClasslessStaticRoute "
index 1da78fddb00dd128611365b627829d0f29aa2fd2..fdc8f1936dcfbb9b114db0939f4f03515f4d79e5 100644 (file)
@@ -180,10 +180,9 @@ OptionCustom::createBuffers() {
         const OptionDefinition::RecordFieldsCollection fields =
             definition_.getRecordFields();
 
-        for (OptionDefinition::RecordFieldsConstIter field = fields.begin();
-             field != fields.end(); ++field) {
+        for (auto const& field : fields) {
             OptionBuffer buf;
-            createBuffer(buf, *field);
+            createBuffer(buf, field);
             // We have the buffer with default value prepared so we
             // add it to the set of buffers.
             buffers.push_back(buf);
@@ -291,9 +290,8 @@ OptionCustom::createBuffers(const OptionBuffer& data_buf) {
             definition_.getRecordFields();
 
         // Go over all data fields within a record.
-        for (OptionDefinition::RecordFieldsConstIter field = fields.begin();
-             field != fields.end(); ++field) {
-            size_t data_size = bufferLength(*field, false,
+        for (auto const& field : fields) {
+            size_t data_size = bufferLength(field, false,
                                             data, data_buf.end());
 
             // Our data field requires that there is a certain chunk of
@@ -458,13 +456,12 @@ OptionCustom::pack(isc::util::OutputBuffer& buf, bool check) const {
     packHeader(buf, check);
 
     // Write data from buffers.
-    for (std::vector<OptionBuffer>::const_iterator it = buffers_.begin();
-         it != buffers_.end(); ++it) {
+    for (auto const& it : buffers_) {
         // In theory the createBuffers function should have taken
         // care that there are no empty buffers added to the
         // collection but it is almost always good to make sure.
-        if (!it->empty()) {
-            buf.writeData(&(*it)[0], it->size());
+        if (!it.empty()) {
+            buf.writeData(&it[0], it.size());
         }
     }
 
@@ -662,16 +659,13 @@ OptionCustom::len() const {
     size_t length = getHeaderLen();
 
     // ... lengths of all buffers that hold option data ...
-    for (std::vector<OptionBuffer>::const_iterator buf = buffers_.begin();
-         buf != buffers_.end(); ++buf) {
-        length += buf->size();
+    for (auto const& buf : buffers_) {
+        length += buf.size();
     }
 
     // ... and lengths of all suboptions
-    for (OptionCollection::const_iterator it = options_.begin();
-         it != options_.end();
-         ++it) {
-        length += (*it).second->len();
+    for (auto const& it : options_) {
+        length += it.second->len();
     }
 
     return (static_cast<uint16_t>(length));
@@ -699,10 +693,10 @@ std::string OptionCustom::toText(int indent) const {
         // For record types we iterate over fields defined in
         // option definition and match the appropriate buffer
         // with them.
-        for (OptionDefinition::RecordFieldsConstIter field = fields.begin();
-             field != fields.end(); ++field) {
-            output << " " << dataFieldToText(*field, std::distance(fields.begin(),
-                                                                   field));
+        size_t j = 0;
+        for (auto const& field : fields) {
+            output << " " << dataFieldToText(field, j);
+            j++;
         }
 
         // If the last record field is an array iterate on extra buffers
index 10a4cc6d3200961bae6f598b3e76c316c7078c20..13d5db6076e05b46c5d4f66ef53065c927c3e464 100644 (file)
@@ -201,10 +201,8 @@ public:
         // The data length is equal to size of T.
         length += sizeof(T);;
         // length of all suboptions
-        for (OptionCollection::const_iterator it = options_.begin();
-             it != options_.end();
-             ++it) {
-            length += (*it).second->len();
+        for (auto const& it : options_) {
+            length += it.second->len();
         }
         return (length);
     }
index 70803d7cec26f66307a732a2f0a07098b47e663b..2b9bd68f453e6f3059c0fa47efb115300946bbff 100644 (file)
@@ -244,10 +244,8 @@ public:
         uint16_t length = (getUniverse() == Option::V4) ? OPTION4_HDR_LEN : OPTION6_HDR_LEN;
         length += values_.size() * sizeof(T);
         // length of all suboptions
-        for (OptionCollection::const_iterator it = options_.begin();
-             it != options_.end();
-             ++it) {
-            length += (*it).second->len();
+        for (auto const& it : options_) {
+            length += it.second->len();
         }
         return (length);
     }
@@ -263,18 +261,17 @@ public:
         output << headerToText(indent) << ":";
 
         std::string data_type = OptionDataTypeUtil::getDataTypeName(OptionDataTypeTraits<T>::type);
-        for (typename std::vector<T>::const_iterator value = values_.begin();
-             value != values_.end(); ++value) {
+        for (auto const& value : values_) {
             output << " ";
 
             // For 1 byte long data types we need to cast to the integer
             // because they are usually implemented as "char" types, in
             // which case the character rather than number would be printed.
             if (OptionDataTypeTraits<T>::len == 1) {
-                output << static_cast<int>(*value);
+                output << static_cast<int>(value);
 
             } else {
-                output << *value;
+                output << value;
             }
 
             // Append data type.
index ea8fa7c91a7440d4f3f6d099252b661f29001fab..ad63b13eb5fdc65762cd8252c2cc4b9fc3a48d0b 100644 (file)
@@ -44,9 +44,8 @@ void
 OptionOpaqueDataTuples::pack(isc::util::OutputBuffer& buf, bool check) const {
     packHeader(buf, check);
 
-    for (TuplesCollection::const_iterator it = tuples_.begin();
-         it != tuples_.end(); ++it) {
-        it->pack(buf);
+    for (auto const& it : tuples_) {
+        it.pack(buf);
     }
     // That's it. We don't pack any sub-options here, because this option
     // must not contain sub-options.
@@ -113,9 +112,8 @@ bool
 OptionOpaqueDataTuples::hasTuple(const std::string& tuple_str) const {
     // Iterate over existing tuples (there shouldn't be many of them),
     // and try to match the searched one.
-    for (TuplesCollection::const_iterator it = tuples_.begin();
-         it != tuples_.end(); ++it) {
-        if (*it == tuple_str) {
+    for (auto const& it : tuples_) {
+        if (it == tuple_str) {
             return (true);
         }
     }
@@ -127,9 +125,8 @@ OptionOpaqueDataTuples::len() const {
     // The option starts with the header.
     uint16_t length = getHeaderLen();
     // Now iterate over existing tuples and add their size.
-    for (TuplesCollection::const_iterator it = tuples_.begin();
-         it != tuples_.end(); ++it) {
-        length += it->getTotalLength();
+    for (auto const& it : tuples_) {
+        length += it.getTotalLength();
     }
 
     return (length);
index df4cf1cb345f005ff72926dc419f2c68210e2e2e..70d0976df48bd5f9288fc1aee88325140a833d6d 100644 (file)
@@ -40,14 +40,15 @@ OptionVendorClass::pack(isc::util::OutputBuffer& buf, bool check) const {
 
     buf.writeUint32(getVendorId());
 
-    for (TuplesCollection::const_iterator it = tuples_.begin();
-         it != tuples_.end(); ++it) {
+    bool first = true;
+    for (auto const& it : tuples_) {
         // For DHCPv4 V-I Vendor Class option, there is enterprise id before
         // every tuple.
-        if ((getUniverse() == V4) && (it != tuples_.begin())) {
+        if ((getUniverse() == V4) && (!first)) {
             buf.writeUint32(getVendorId());
         }
-        it->pack(buf);
+        first = false;
+        it.pack(buf);
 
     }
     // That's it. We don't pack any sub-options here, because this option
@@ -146,9 +147,8 @@ bool
 OptionVendorClass::hasTuple(const std::string& tuple_str) const {
     // Iterate over existing tuples (there shouldn't be many of them),
     // and try to match the searched one.
-    for (TuplesCollection::const_iterator it = tuples_.begin();
-         it != tuples_.end(); ++it) {
-        if (*it == tuple_str) {
+    for (auto const& it : tuples_) {
+        if (it == tuple_str) {
             return (true);
         }
     }
@@ -161,14 +161,15 @@ OptionVendorClass::len() const {
     // The option starts with the header and enterprise id.
     uint16_t length = getHeaderLen() + sizeof(uint32_t);
     // Now iterate over existing tuples and add their size.
-    for (TuplesCollection::const_iterator it = tuples_.begin();
-         it != tuples_.end(); ++it) {
+    bool first = true;
+    for (auto const& it : tuples_) {
         // For DHCPv4 V-I Vendor Class option, there is enterprise id before
         // every tuple.
-        if ((getUniverse() == V4) && (it != tuples_.begin())) {
+        if ((getUniverse() == V4) && (!first)) {
             length += sizeof(uint32_t);
         }
-        length += it->getTotalLength();
+        first = false;
+        length += it.getTotalLength();
 
     }
 
index 2484d974ff8a70eba2f5c1649bd3399007dd6038..abfd7b46327fa94f5d690e790126f85a91b665a6 100644 (file)
@@ -9,6 +9,7 @@
 #include <dhcp/pkt.h>
 #include <dhcp/iface_mgr.h>
 #include <dhcp/hwaddr.h>
+#include <boost/foreach.hpp>
 #include <vector>
 
 namespace isc {
@@ -90,10 +91,9 @@ Pkt::getOptions(const uint16_t opt_type) {
     // matching options, copy them and replace the original ones with new
     // instances.
     if (copy_retrieved_options_) {
-        for (OptionCollection::iterator opt_it = range.first;
-             opt_it != range.second; ++opt_it) {
-            OptionPtr option_copy = opt_it->second->clone();
-            opt_it->second = option_copy;
+        BOOST_FOREACH(auto& opt_it, range) {
+            OptionPtr option_copy = opt_it.second->clone();
+            opt_it.second = option_copy;
         }
     }
     // Finally, return updated options. This can also be empty in some cases.
index aba14c691ea9862291e39c20ad960bb2d2862f7f..a2b93cf3749a8221f051c9407b88275830b187d6 100644 (file)
@@ -18,7 +18,7 @@
 #include <exceptions/exceptions.h>
 #include <dhcp/duid.h>
 #include <dhcp/iface_mgr.h>
-
+#include <boost/foreach.hpp>
 #include <iterator>
 #include <iostream>
 #include <sstream>
@@ -227,10 +227,9 @@ Pkt6::getAllRelayOptions(const uint16_t option_code,
         // matching options, copy them and replace the original ones with new
         // instances.
         if (copy_retrieved_options_) {
-            for (OptionCollection::iterator opt_it = range.first;
-                 opt_it != range.second; ++opt_it) {
-                OptionPtr option_copy = opt_it->second->clone();
-                opt_it->second = option_copy;
+            BOOST_FOREACH(auto& opt_it, range) {
+                OptionPtr option_copy = opt_it.second->clone();
+                opt_it.second = option_copy;
             }
         }
         opts.insert(range.first, range.second);
@@ -312,10 +311,9 @@ Pkt6::getRelayOptions(const uint16_t opt_type,
     // matching options, copy them and replace the original ones with new
     // instances.
     if (copy_retrieved_options_) {
-        for (OptionCollection::iterator opt_it = range.first;
-             opt_it != range.second; ++opt_it) {
-            OptionPtr option_copy = opt_it->second->clone();
-            opt_it->second = option_copy;
+        BOOST_FOREACH(auto& opt_it, range) {
+            OptionPtr option_copy = opt_it.second->clone();
+            opt_it.second = option_copy;
         }
     }
     // Finally, return updated options. This can also be empty in some cases.
@@ -406,15 +404,14 @@ Pkt6::packUDP() {
             calculateRelaySizes();
 
             // Now for each relay, we need to...
-            for (vector<RelayInfo>::iterator relay = relay_info_.begin();
-                 relay != relay_info_.end(); ++relay) {
+            for (auto const& relay : relay_info_) {
 
                 // build relay-forw/relay-repl header (see RFC 8415, section 9)
-                buffer_out_.writeUint8(relay->msg_type_);
-                buffer_out_.writeUint8(relay->hop_count_);
-                buffer_out_.writeData(&(relay->linkaddr_.toBytes()[0]),
+                buffer_out_.writeUint8(relay.msg_type_);
+                buffer_out_.writeUint8(relay.hop_count_);
+                buffer_out_.writeData(&(relay.linkaddr_.toBytes()[0]),
                                      isc::asiolink::V6ADDRESS_LEN);
-                buffer_out_.writeData(&relay->peeraddr_.toBytes()[0],
+                buffer_out_.writeData(&relay.peeraddr_.toBytes()[0],
                                      isc::asiolink::V6ADDRESS_LEN);
 
                 // store every option in this relay scope. Usually that will be
@@ -422,7 +419,7 @@ Pkt6::packUDP() {
                 // present here as well (vendor-opts for Cable modems,
                 // subscriber-id, remote-id, options echoed back from Echo
                 // Request Option, etc.)
-                for (auto const& opt : relay->options_) {
+                for (auto const& opt : relay.options_) {
                     (opt.second)->pack(buffer_out_);
                 }
 
@@ -431,7 +428,7 @@ Pkt6::packUDP() {
                 // or outside the loop (if there are no more relays and the
                 // payload is a direct message)
                 buffer_out_.writeUint16(D6O_RELAY_MSG);
-                buffer_out_.writeUint16(relay->relay_msg_len_);
+                buffer_out_.writeUint16(relay.relay_msg_len_);
             }
 
         }
index abc73dd0250b818d30b0f4ac0d23eda03d542dcb..c0602d27e52d28eed56a23d2198116f5ed82a8a0 100644 (file)
@@ -86,19 +86,18 @@ TEST(ClassifyTest, ClientClassesIterator) {
     bool seenbeta = false;
     bool seengamma = false;
     bool seendelta = false;
-    for (ClientClasses::const_iterator it = classes.cbegin();
-         it != classes.cend(); ++it) {
+    for (auto const& it : classes) {
         ++count;
-        if (*it == "alpha") {
+        if (it == "alpha") {
             seenalpha = true;
-        } else if (*it == "beta") {
+        } else if (it == "beta") {
             seenbeta = true;
-        } else if (*it == "gamma") {
+        } else if (it == "gamma") {
             seengamma = true;
-        } else if (*it == "delta") {
+        } else if (it == "delta") {
             seendelta = true;
         } else {
-            ADD_FAILURE() << "Got unexpected " << *it;
+            ADD_FAILURE() << "Got unexpected " << it;
         }
     }
     EXPECT_EQ(count, classes.size());
index a0a7a28f01d372e2a6ae7f2477c3eb55c1da984c..3271b9b68b7a57c0db82f995bf3757007fdf6609 100644 (file)
@@ -17,7 +17,6 @@
 #include <dhcp/tests/packet_queue_testutils.h>
 #include <testutils/gtest_utils.h>
 
-#include <boost/foreach.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <gtest/gtest.h>
 
@@ -167,11 +166,10 @@ public:
         // Check if there is any other socket bound to the specified address
         // and port on this interface.
         const Iface::SocketCollection& sockets = iface.getSockets();
-        for (Iface::SocketCollection::const_iterator socket = sockets.begin();
-             socket != sockets.end(); ++socket) {
-            if (((socket->addr_ == addr) ||
-                 ((socket->addr_ == IOAddress("::")) && join_multicast)) &&
-                socket->port_ == port) {
+        for (auto const& socket : sockets) {
+            if (((socket.addr_ == addr) ||
+                 ((socket.addr_ == IOAddress("::")) && join_multicast)) &&
+                socket.port_ == port) {
                 isc_throw(SocketConfigError, "test socket bind error");
             }
         }
@@ -308,14 +306,13 @@ public:
             return (false);
         }
         const Iface::SocketCollection& sockets = iface->getSockets();
-        for (Iface::SocketCollection::const_iterator sock = sockets.begin();
-             sock != sockets.end(); ++sock) {
-            if (sock->addr_ == IOAddress(addr)) {
+        for (auto const& sock : sockets) {
+            if (sock.addr_ == IOAddress(addr)) {
                 return (true);
 
-            } else if ((sock->addr_ == IOAddress("::")) &&
+            } else if ((sock.addr_ == IOAddress("::")) &&
                        (IOAddress(addr).isV6LinkLocal())) {
-                BOOST_FOREACH(Iface::Address a, iface->getAddresses()) {
+                for (auto const& a : iface->getAddresses()) {
                     if (a.get() == IOAddress(addr)) {
                         return (true);
                     }
@@ -336,7 +333,7 @@ public:
                        const bool up, const bool running,
                        const bool inactive4,
                        const bool inactive6) {
-        for (const IfacePtr& iface : ifaces_) {
+        for (auto const& iface : ifaces_) {
             if (iface->getName() == name) {
                 iface->flag_loopback_ = loopback;
                 iface->flag_up_ = up;
@@ -410,10 +407,9 @@ public:
         // Loop through sockets and try to find the ones which match the
         // specified type.
         int sockets_count = 0;
-        for (Iface::SocketCollection::const_iterator sock = sockets.begin();
-             sock != sockets.end(); ++sock) {
+        for (auto const& sock : sockets) {
             // Match found, increase the counter.
-            if (sock->family_ == family) {
+            if (sock.family_ == family) {
                 ++sockets_count;
             }
         }
@@ -432,10 +428,9 @@ public:
     const isc::dhcp::SocketInfo*
     getSocketByAddr(const isc::dhcp::Iface::SocketCollection& sockets,
                     const IOAddress& addr) {
-        for (isc::dhcp::Iface::SocketCollection::const_iterator s =
-                 sockets.begin(); s != sockets.end(); ++s) {
-            if (s->addr_ == addr) {
-                return (&(*s));
+        for (auto const& s : sockets) {
+            if (s.addr_ == addr) {
+                return (&s);
             }
         }
         return (NULL);
@@ -1121,7 +1116,7 @@ TEST_F(IfaceMgrTest, getIface) {
 
     cout << "There are " << ifacemgr->getIfacesLst().size()
          << " interfaces." << endl;
-    for (const IfacePtr& iface : ifacemgr->getIfacesLst()) {
+    for (auto const& iface : ifacemgr->getIfacesLst()) {
         cout << "  " << iface->getFullName() << endl;
     }
 
@@ -2894,7 +2889,7 @@ checkIfAddrs(const Iface & iface, struct ifaddrs *& ifptr) {
 
             IOAddress addrv4 = IOAddress::fromBytes(AF_INET, p);
 
-            BOOST_FOREACH(Iface::Address a, iface.getAddresses()) {
+            for (auto const& a :iface.getAddresses()) {
                 if(a.get().isV4() && (a.get()) == addrv4) {
                     return (true);
                 }
@@ -2909,7 +2904,7 @@ checkIfAddrs(const Iface & iface, struct ifaddrs *& ifptr) {
 
             IOAddress addrv6 = IOAddress::fromBytes(AF_INET6, p);
 
-            BOOST_FOREACH(Iface::Address a, iface.getAddresses()) {
+            for (auto const&  a : iface.getAddresses()) {
                 if (a.get().isV6() && (a.get() == addrv6)) {
                     return (true);
                 }
index 3c6262c0635c1ff6ed92758f6a1496fa14d887c3..c9d0d322073c9aecbdce9a1a8ee1eba4630c17f4 100644 (file)
@@ -1603,7 +1603,8 @@ TEST_F(LibDhcpTest, fuseLongOptionWithLongSuboption) {
     ASSERT_EQ(1, col.size());
     ASSERT_EQ(1, col.begin()->second->getOptions().size());
     uint8_t index = 0;
-    for (auto const& option : col.begin()->second->getOptions()) {
+    auto const& options = col.begin()->second->getOptions();
+    for (auto const& option : options) {
         for (auto const& value : option.second->getData()) {
             ASSERT_EQ(index, value);
             index++;
@@ -3217,12 +3218,11 @@ TEST_F(LibDhcpTest, getOptionDefByName6) {
     // Get all definitions.
     const OptionDefContainerPtr defs = LibDHCP::getOptionDefs(DHCP6_OPTION_SPACE);
     // For each definition try to find it using option name.
-    for (OptionDefContainer::const_iterator def = defs->begin();
-         def != defs->end(); ++def) {
+    for (auto const& def : *defs) {
         OptionDefinitionPtr def_by_name =
-            LibDHCP::getOptionDef(DHCP6_OPTION_SPACE, (*def)->getName());
+            LibDHCP::getOptionDef(DHCP6_OPTION_SPACE, def->getName());
         ASSERT_TRUE(def_by_name);
-        ASSERT_TRUE(**def == *def_by_name);
+        ASSERT_TRUE(*def == *def_by_name);
     }
 }
 
@@ -3232,12 +3232,11 @@ TEST_F(LibDhcpTest, getOptionDefByName4) {
     // Get all definitions.
     const OptionDefContainerPtr defs = LibDHCP::getOptionDefs(DHCP4_OPTION_SPACE);
     // For each definition try to find it using option name.
-    for (OptionDefContainer::const_iterator def = defs->begin();
-         def != defs->end(); ++def) {
+    for (auto const& def : *defs) {
         OptionDefinitionPtr def_by_name =
-            LibDHCP::getOptionDef(DHCP4_OPTION_SPACE, (*def)->getName());
+            LibDHCP::getOptionDef(DHCP4_OPTION_SPACE, def->getName());
         ASSERT_TRUE(def_by_name);
-        ASSERT_TRUE(**def == *def_by_name);
+        ASSERT_TRUE(*def == *def_by_name);
     }
 }
 
@@ -3247,13 +3246,12 @@ TEST_F(LibDhcpTest, getVendorOptionDefByName6) {
     const OptionDefContainerPtr& defs =
         LibDHCP::getVendorOptionDefs(Option::V6, VENDOR_ID_CABLE_LABS);
     ASSERT_TRUE(defs);
-    for (OptionDefContainer::const_iterator def = defs->begin();
-         def != defs->end(); ++def) {
+    for (auto const& def : *defs) {
         OptionDefinitionPtr def_by_name =
             LibDHCP::getVendorOptionDef(Option::V6, VENDOR_ID_CABLE_LABS,
-                                        (*def)->getName());
+                                        def->getName());
         ASSERT_TRUE(def_by_name);
-        ASSERT_TRUE(**def == *def_by_name);
+        ASSERT_TRUE(*def == *def_by_name);
     }
 }
 
@@ -3263,13 +3261,12 @@ TEST_F(LibDhcpTest, getVendorOptionDefByName4) {
     const OptionDefContainerPtr& defs =
         LibDHCP::getVendorOptionDefs(Option::V4, VENDOR_ID_CABLE_LABS);
     ASSERT_TRUE(defs);
-    for (OptionDefContainer::const_iterator def = defs->begin();
-         def != defs->end(); ++def) {
+    for (auto const& def : *defs) {
         OptionDefinitionPtr def_by_name =
             LibDHCP::getVendorOptionDef(Option::V4, VENDOR_ID_CABLE_LABS,
-                                        (*def)->getName());
+                                        def->getName());
         ASSERT_TRUE(def_by_name);
-        ASSERT_TRUE(**def == *def_by_name);
+        ASSERT_TRUE(*def == *def_by_name);
     }
 }
 
index 9d7a3850da6a5e1f8a7d03e64d022f626cac915e..0adfdc17a9b2fe0c3bc911aa297b0b2067d85fa7 100644 (file)
@@ -128,17 +128,17 @@ void testCopyAssign(const OpType& op_type,
 
     // Iterate over source options.
     OptionCollection::const_iterator it_copy = option_copy_subs.begin();
-    for (OptionCollection::const_iterator it = option_subs.begin();
-         it != option_subs.end(); ++it, ++it_copy) {
+    for (auto const& it : option_subs) {
         // The option codes should be equal in both containers.
-        EXPECT_EQ(it->first, it_copy->first);
+        EXPECT_EQ(it.first, it_copy->first);
         // Pointers must be unequal because the expectation is that options
         // are copied, rather than pointers.
-        EXPECT_NE(it->second, it_copy->second);
-        Option* opt_ptr = it->second.get();
+        EXPECT_NE(it.second, it_copy->second);
+        Option* opt_ptr = it.second.get();
         Option* opt_copy_ptr = it_copy->second.get();
         // The C++ types must match.
         EXPECT_TRUE(typeid(*opt_ptr) == typeid(*opt_copy_ptr));
+        ++it_copy;
     }
 
     // Final check is to compare their binary representations.
index f1f51add064a69105b10809eb66b39856019c864..0d01b13700f5bbadd9b9cd46ff12bfdf9a4c0fed 100644 (file)
@@ -551,9 +551,8 @@ TEST_F(OptionDefinitionTest, ipv6AddressArrayTokenized) {
 
     // Create a vector of strings representing addresses given above.
     std::vector<std::string> addrs_str;
-    for (std::vector<asiolink::IOAddress>::const_iterator it = addrs.begin();
-         it != addrs.end(); ++it) {
-        addrs_str.push_back(it->toText());
+    for (auto const& it : addrs) {
+        addrs_str.push_back(it.toText());
     }
 
     // Create DHCPv6 option using the list of IPv6 addresses given in the
@@ -650,9 +649,8 @@ TEST_F(OptionDefinitionTest, ipv4AddressArrayTokenized) {
 
     // Create a vector of strings representing addresses given above.
     std::vector<std::string> addrs_str;
-    for (std::vector<asiolink::IOAddress>::const_iterator it = addrs.begin();
-         it != addrs.end(); ++it) {
-        addrs_str.push_back(it->toText());
+    for (auto const& it : addrs) {
+        addrs_str.push_back(it.toText());
     }
 
     // Create DHCPv4 option using the list of IPv4 addresses given in the
index 8232b8f387fc1160bdac805a3b7773d4d8f99ce0..87d97f2a58b1950b0788522906f975f53fbc817f 100644 (file)
@@ -676,9 +676,8 @@ TEST_F(Pkt4Test, getOptions) {
     // in the packet.
     pkt->setCopyRetrievedOptions(false);
     OptionCollection options_modified = pkt->getOptions(1);
-    for (OptionCollection::const_iterator opt_it_modified = options_modified.begin();
-         opt_it_modified != options_modified.end(); ++opt_it_modified) {
-        opt_it = std::find(options.begin(), options.end(), *opt_it_modified);
+    for (auto const& opt_it_modified : options_modified) {
+        opt_it = std::find(options.begin(), options.end(), opt_it_modified);
         ASSERT_TRUE(opt_it != options.end());
     }
 
index caee2d2fdb2bb121744ea29e67d821d9bfd768e6..40c6c6af27eb174391faac285a16e71c2fa4ba6c 100644 (file)
@@ -25,6 +25,7 @@
 #include <testutils/gtest_utils.h>
 #include <util/range_utilities.h>
 #include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/range/adaptor/reversed.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <boost/pointer_cast.hpp>
 #include <util/encode/hex.h>
@@ -452,9 +453,8 @@ TEST_F(Pkt6Test, addGetDelOptions) {
 
     // Both options must be of type 2 and there must not be
     // any other type returned
-    for (OptionCollection::const_iterator x= options.begin();
-         x != options.end(); ++x) {
-        EXPECT_EQ(2, x->second->getType());
+    for (auto const& x : options) {
+        EXPECT_EQ(2, x.second->getType());
     }
 
     // Try to get a single option. Normally for singular options
@@ -552,9 +552,8 @@ TEST_F(Pkt6Test, getOptions) {
     // that copies of the options were used to replace original options
     // in the packet.
     OptionCollection options_modified = pkt.getNonCopiedOptions(1);
-    for (OptionCollection::const_iterator opt_it_modified = options_modified.begin();
-         opt_it_modified != options_modified.end(); ++opt_it_modified) {
-        opt_it = std::find(options.begin(), options.end(), *opt_it_modified);
+    for (auto const& opt_it_modified : options_modified) {
+        opt_it = std::find(options.begin(), options.end(), opt_it_modified);
         ASSERT_TRUE(opt_it != options.end());
     }
 
@@ -1064,9 +1063,10 @@ TEST_F(Pkt6Test, getAnyRelayOption) {
 
     // Check reverse order.
     vector<OptionPtr> ropts;
-    for (auto it = opts.rbegin(); it != opts.rend(); ++it) {
-        ropts.push_back(it->second);
+    for (auto const& it : boost::adaptors::reverse(opts)) {
+         ropts.push_back(it.second);
     }
+
     EXPECT_TRUE(lopts0 == ropts);
 
     // We just want option from the first relay (closest to the client)
index 83afc1c1e239bb8f0cdb09b7466946298f028390..b7142a057bdc393460946bc63955e7b522852293 100644 (file)
@@ -10,8 +10,6 @@
 #include <dhcp/pkt6.h>
 #include <dhcp/tests/pkt_filter6_test_utils.h>
 
-#include <boost/foreach.hpp>
-
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
@@ -181,7 +179,7 @@ PktFilter6Stub::openSocket(const Iface& iface, const isc::asiolink::IOAddress& a
                            const uint16_t port, const bool) {
     // Check if there is any other socket bound to the specified address
     // and port on this interface.
-    BOOST_FOREACH(SocketInfo socket, iface.getSockets()) {
+    for (auto const& socket : iface.getSockets()) {
         if ((socket.addr_ == addr) && (socket.port_ == port)) {
             isc_throw(SocketConfigError, "test socket bind error");
         }
index 5532fec2557f7c36cbc77791c460769d86308327..36df127eae3f7e6385e6d46c73d4579edb04324b 100644 (file)
@@ -13,8 +13,6 @@
 #include <dhcp/testutils/pkt_filter_test_stub.h>
 #include <dhcp/testutils/pkt_filter6_test_stub.h>
 
-#include <boost/foreach.hpp>
-
 using namespace isc::asiolink;
 
 namespace isc {
@@ -165,7 +163,7 @@ IfaceMgrTestConfig::socketOpen(const std::string& iface_name,
         isc_throw(Unexpected, "No such interface '" << iface_name << "'");
     }
 
-    BOOST_FOREACH(SocketInfo sock, iface->getSockets()) {
+    for (auto const& sock : iface->getSockets()) {
         if (sock.family_ == family) {
             return (true);
         }
@@ -181,7 +179,7 @@ IfaceMgrTestConfig::socketOpen(const std::string& iface_name,
         isc_throw(Unexpected, "No such interface '" << iface_name << "'");
     }
 
-    BOOST_FOREACH(SocketInfo sock, iface->getSockets()) {
+    for (auto const& sock : iface->getSockets()) {
         if ((sock.family_ == AF_INET) &&
             (sock.addr_ == IOAddress(address))) {
             return (true);
@@ -197,7 +195,7 @@ IfaceMgrTestConfig::unicastOpen(const std::string& iface_name) const {
         isc_throw(Unexpected, "No such interface '" << iface_name << "'");
     }
 
-    BOOST_FOREACH(SocketInfo sock, iface->getSockets()) {
+    for (auto const& sock : iface->getSockets()) {
         if ((!sock.addr_.isV6LinkLocal()) &&
             (!sock.addr_.isV6Multicast())) {
             return (true);
index 111a3a9347db5f0c50db3d870570ebd52e81cca4..810409fe4b6235c217420c09978b87d58e995ff6 100644 (file)
@@ -388,9 +388,9 @@ AllocEngine::findReservation(ClientContext6& ctx) {
             // Store the hosts in the temporary map, because some hosts may
             // belong to subnets outside of the shared network. We'll need
             // to eliminate them.
-            for (auto host = hosts.begin(); host != hosts.end(); ++host) {
-                if ((*host)->getIPv6SubnetID() != SUBNET_ID_GLOBAL) {
-                    host_map[(*host)->getIPv6SubnetID()] = *host;
+            for (auto const& host : hosts) {
+                if (host->getIPv6SubnetID() != SUBNET_ID_GLOBAL) {
+                    host_map[host->getIPv6SubnetID()] = host;
                 }
             }
         }
@@ -621,7 +621,7 @@ AllocEngine::allocateLeases6(ClientContext6& ctx) {
             // If there are any leases allocated, let's store in them in the
             // IA context so as they are available when we process subsequent
             // IAs.
-            BOOST_FOREACH(Lease6Ptr lease, leases) {
+            for (auto const& lease : leases) {
                 ctx.addAllocatedResource(lease->addr_, lease->prefixlen_);
                 ctx.new_leases_.push_back(lease);
             }
@@ -1148,7 +1148,7 @@ AllocEngine::allocateReservedLeases6(ClientContext6& ctx,
     // We want to avoid allocating new lease for an IA if there is already
     // a valid lease for which client has reservation. So, we first check if
     // we already have a lease for a reserved address or prefix.
-    BOOST_FOREACH(const Lease6Ptr& lease, existing_leases) {
+    for (auto const& lease : existing_leases) {
         if ((lease->valid_lft_ != 0)) {
             if ((ctx.hosts_.count(lease->subnet_id_) > 0) &&
                 ctx.hosts_[lease->subnet_id_]->hasReservation(makeIPv6Resrv(*lease))) {
@@ -1218,7 +1218,7 @@ AllocEngine::allocateReservedLeases6(ClientContext6& ctx,
 
         // Get the IPv6 reservations of specified type.
         const IPv6ResrvRange& reservs = host->getIPv6Reservations(type);
-        BOOST_FOREACH(IPv6ResrvTuple type_lease_tuple, reservs) {
+        BOOST_FOREACH(auto const& type_lease_tuple, reservs) {
             // We do have a reservation for address or prefix.
             const IOAddress& addr = type_lease_tuple.second.getPrefix();
             uint8_t prefix_len = type_lease_tuple.second.getPrefixLen();
@@ -1318,7 +1318,7 @@ AllocEngine::allocateGlobalReservedLeases6(ClientContext6& ctx,
     // We want to avoid allocating a new lease for an IA if there is already
     // a valid lease for which client has reservation. So, we first check if
     // we already have a lease for a reserved address or prefix.
-    BOOST_FOREACH(const Lease6Ptr& lease, existing_leases) {
+    for (auto const& lease : existing_leases) {
         if ((lease->valid_lft_ != 0) &&
             (ghost->hasReservation(makeIPv6Resrv(*lease)))) {
             // We found existing lease for a reserved address or prefix.
@@ -1357,7 +1357,7 @@ AllocEngine::allocateGlobalReservedLeases6(ClientContext6& ctx,
         IPv6Resrv::TYPE_NA : IPv6Resrv::TYPE_PD;
 
     const IPv6ResrvRange& reservs = ghost->getIPv6Reservations(type);
-    BOOST_FOREACH(IPv6ResrvTuple type_lease_tuple, reservs) {
+    BOOST_FOREACH(auto const& type_lease_tuple, reservs) {
         // We do have a reservation for address or prefix.
         const IOAddress& addr = type_lease_tuple.second.getPrefix();
         uint8_t prefix_len = type_lease_tuple.second.getPrefixLen();
@@ -1468,7 +1468,7 @@ AllocEngine::removeNonmatchingReservedLeases6(ClientContext6& ctx,
     // so the operation shouldn't be that expensive.
     Lease6Collection copy = existing_leases;
 
-    BOOST_FOREACH(const Lease6Ptr& candidate, copy) {
+    for (auto const& candidate : copy) {
         // If we have reservation we should check if the reservation is for
         // the candidate lease. If so, we simply accept the lease.
         IPv6Resrv resv = makeIPv6Resrv(*candidate);
@@ -1576,7 +1576,7 @@ AllocEngine::removeNonmatchingReservedNoHostLeases6(ClientContext6& ctx,
     // so the operation shouldn't be that expensive.
     Lease6Collection copy = existing_leases;
 
-    BOOST_FOREACH(const Lease6Ptr& candidate, copy) {
+    for (auto const& candidate : copy) {
         // Lease can be allocated to us from a dynamic pool, but we must
         // check if this lease belongs to any allowed pool. If it does,
         // we can proceed to checking the next lease.
@@ -1657,7 +1657,7 @@ AllocEngine::removeNonreservedLeases6(ClientContext6& ctx,
          lease != existing_leases.end(); ++lease) {
 
         // If there is reservation for this keep it.
-        IPv6Resrv resv = makeIPv6Resrv(*(*lease));
+        IPv6Resrv resv = makeIPv6Resrv(**lease);
         if (ctx.hasGlobalReservation(resv) ||
             ((ctx.hosts_.count((*lease)->subnet_id_) > 0) &&
              (ctx.hosts_[(*lease)->subnet_id_]->hasReservation(resv)))) {
@@ -1883,9 +1883,8 @@ AllocEngine::getLifetimes6(ClientContext6& ctx, uint32_t& preferred, uint32_t& v
 
         // Iterate over the assigned class definitions.
         int have_both = 0;
-        for (auto name = classes.cbegin();
-             name != classes.cend() && have_both < 2; ++name) {
-            ClientClassDefPtr cl = dict->findClass(*name);
+        for (auto const& name : classes) {
+            ClientClassDefPtr cl = dict->findClass(name);
             if (candidate_preferred.unspecified() &&
                 (cl && (!cl->getPreferred().unspecified()))) {
                 candidate_preferred = cl->getPreferred();
@@ -1897,6 +1896,9 @@ AllocEngine::getLifetimes6(ClientContext6& ctx, uint32_t& preferred, uint32_t& v
                 candidate_valid = cl->getValid();
                 ++have_both;
             }
+            if (have_both == 2) {
+                break;
+            }
         }
     }
 
@@ -2139,25 +2141,25 @@ AllocEngine::renewLeases6(ClientContext6& ctx) {
         }
 
         // Extend all existing leases that passed all checks.
-        for (Lease6Collection::iterator l = leases.begin(); l != leases.end(); ++l) {
-            if (ctx.currentIA().isNewResource((*l)->addr_,
-                                              (*l)->prefixlen_)) {
+        for (auto const& l : leases) {
+            if (ctx.currentIA().isNewResource(l->addr_,
+                                              l->prefixlen_)) {
                 // This lease was just created so is already extended.
                 continue;
             }
             LOG_DEBUG(alloc_engine_logger, ALLOC_ENGINE_DBG_TRACE_DETAIL,
                       ALLOC_ENGINE_V6_EXTEND_LEASE)
                 .arg(ctx.query_->getLabel())
-                .arg((*l)->typeToText((*l)->type_))
-                .arg((*l)->addr_);
-            extendLease6(ctx, *l);
+                .arg(l->typeToText(l->type_))
+                .arg(l->addr_);
+            extendLease6(ctx, l);
         }
 
         if (!leases.empty()) {
             // If there are any leases allocated, let's store in them in the
             // IA context so as they are available when we process subsequent
             // IAs.
-            BOOST_FOREACH(Lease6Ptr lease, leases) {
+            for (auto const& lease : leases) {
                 ctx.addAllocatedResource(lease->addr_, lease->prefixlen_);
                 ctx.new_leases_.push_back(lease);
             }
@@ -2418,9 +2420,8 @@ AllocEngine::extendLease6(ClientContext6& ctx, Lease6Ptr lease) {
 Lease6Collection
 AllocEngine::updateLeaseData(ClientContext6& ctx, const Lease6Collection& leases) {
     Lease6Collection updated_leases;
-    for (Lease6Collection::const_iterator lease_it = leases.begin();
-         lease_it != leases.end(); ++lease_it) {
-        Lease6Ptr lease(new Lease6(**lease_it));
+    for (auto const& lease_it : leases) {
+        Lease6Ptr lease(new Lease6(*lease_it));
         if (ctx.currentIA().isNewResource(lease->addr_, lease->prefixlen_)) {
             // This lease was just created so is already up to date.
             updated_leases.push_back(lease);
@@ -2452,14 +2453,14 @@ AllocEngine::updateLeaseData(ClientContext6& ctx, const Lease6Collection& leases
             }
 
             bool fqdn_changed = ((lease->type_ != Lease::TYPE_PD) &&
-                                 !(lease->hasIdenticalFqdn(**lease_it)));
+                                 !(lease->hasIdenticalFqdn(*lease_it)));
 
             lease->cltt_ = time(NULL);
             if (!fqdn_changed) {
                 setLeaseReusable(lease, current_preferred_lft, ctx);
             }
             if (lease->reuseable_valid_lft_ == 0) {
-                ctx.currentIA().changed_leases_.push_back(*lease_it);
+                ctx.currentIA().changed_leases_.push_back(lease_it);
                 LeaseMgrFactory::instance().updateLease6(lease);
             }
 
@@ -2575,7 +2576,7 @@ AllocEngine::reclaimExpiredLeases6Internal(const size_t max_leases,
     }
 
     size_t leases_processed = 0;
-    BOOST_FOREACH(Lease6Ptr lease, leases) {
+    for (auto const& lease : leases) {
 
         try {
             // Reclaim the lease.
@@ -2738,7 +2739,7 @@ AllocEngine::reclaimExpiredLeases4Internal(const size_t max_leases,
     }
 
     size_t leases_processed = 0;
-    BOOST_FOREACH(Lease4Ptr lease, leases) {
+    for (auto const& lease : leases) {
 
         try {
             // Reclaim the lease.
@@ -3502,10 +3503,10 @@ void findClientLease(AllocEngine::ClientContext4& ctx, Lease4Ptr& client_lease)
             // explicitly configured to ignore client identifiers for this subnet
             // check if there is a lease within this subnet.
             if (subnet->getMatchClientId()) {
-                for (auto l = leases_client_id.begin(); l != leases_client_id.end(); ++l) {
-                    if ((*l)->subnet_id_ == subnet->getID()) {
+                for (auto const& l : leases_client_id) {
+                    if (l->subnet_id_ == subnet->getID()) {
                         // Lease found, so stick to this lease.
-                        client_lease = (*l);
+                        client_lease = l;
                         ctx.subnet_ = subnet;
                         return;
                     }
@@ -3530,9 +3531,8 @@ void findClientLease(AllocEngine::ClientContext4& ctx, Lease4Ptr& client_lease)
 
             // Try to find the lease that matches current subnet and belongs to
             // this client, so both HW address and client identifier match.
-            for (Lease4Collection::const_iterator client_lease_it = leases_hw_address.begin();
-                 client_lease_it != leases_hw_address.end(); ++client_lease_it) {
-                Lease4Ptr existing_lease = *client_lease_it;
+            for (auto const& client_lease_it : leases_hw_address) {
+                Lease4Ptr existing_lease = client_lease_it;
                 if ((existing_lease->subnet_id_ == subnet->getID()) &&
                     existing_lease->belongsToClient(ctx.hwaddr_, client_id)) {
                     // Found the lease of this client, so return it.
@@ -3760,9 +3760,9 @@ AllocEngine::findReservation(ClientContext4& ctx) {
             // Store the hosts in the temporary map, because some hosts may
             // belong to subnets outside of the shared network. We'll need
             // to eliminate them.
-            for (auto host = hosts.begin(); host != hosts.end(); ++host) {
-                if ((*host)->getIPv4SubnetID() != SUBNET_ID_GLOBAL) {
-                    host_map[(*host)->getIPv4SubnetID()] = *host;
+            for (auto const& host : hosts) {
+                if (host->getIPv4SubnetID() != SUBNET_ID_GLOBAL) {
+                    host_map[host->getIPv4SubnetID()] = host;
                 }
             }
         }
@@ -4172,9 +4172,8 @@ AllocEngine::getOfferLft(const ClientContext4& ctx) {
             CfgMgr::instance().getCurrentCfg()->getClientClassDictionary();
 
         // Iterate over the assigned class definitions.
-        for (ClientClasses::const_iterator name = classes.cbegin();
-             name != classes.cend(); ++name) {
-            ClientClassDefPtr cl = dict->findClass(*name);
+        for (auto const& name : classes) {
+            ClientClassDefPtr cl = dict->findClass(name);
             if (cl && (!cl->getOfferLft().unspecified())) {
                 offer_lft = cl->getOfferLft();
                 break;
@@ -4217,9 +4216,8 @@ AllocEngine::getValidLft(const ClientContext4& ctx) {
             CfgMgr::instance().getCurrentCfg()->getClientClassDictionary();
 
         // Iterate over the assigned class definitions.
-        for (ClientClasses::const_iterator name = classes.cbegin();
-             name != classes.cend(); ++name) {
-            ClientClassDefPtr cl = dict->findClass(*name);
+        for (auto const& name : classes) {
+            ClientClassDefPtr cl = dict->findClass(name);
             if (cl && (!cl->getValid().unspecified())) {
                 candidate_lft = cl->getValid();
                 break;
index 926946de8944d139cbbe5b49b4adc26eab6b1aa2..104fa871c2ec05a25c04051c1892c59f355d948e 100644 (file)
@@ -45,14 +45,14 @@ protected:
     void addGlobalsToConfig(SrvConfigPtr external_cfg,
                             data::StampedValueCollection& cb_globals) const {
         auto const& index = cb_globals.get<data::StampedValueNameIndexTag>();
-        for (auto cb_global = index.begin(); cb_global != index.end(); ++cb_global) {
+        for (auto const& cb_global : index) {
 
-            if ((*cb_global)->amNull()) {
+            if (cb_global->amNull()) {
                 continue;
             }
 
-            external_cfg->addConfiguredGlobal((*cb_global)->getName(),
-                                              (*cb_global)->getElementValue());
+            external_cfg->addConfiguredGlobal(cb_global->getName(),
+                                              cb_global->getElementValue());
         }
     }
 };
index 37efb8a4bc500ca255bd00054198d6f8fce83f68..1bc678fdcaa1a4b073a2bee379a980e45ed953a5 100644 (file)
@@ -13,6 +13,7 @@
 #include <dhcpsrv/parsers/simple_parser4.h>
 #include <hooks/callout_handle.h>
 #include <hooks/hooks_manager.h>
+#include <boost/foreach.hpp>
 
 using namespace isc::db;
 using namespace isc::data;
@@ -99,37 +100,37 @@ CBControlDHCPv4::databaseConfigApply(const BackendSelector& backend_selector,
             // audit entry is found.
             range = index.equal_range(boost::make_tuple("dhcp4_option_def",
                                                         AuditEntry::ModificationType::DELETE));
-            for (auto entry = range.first; entry != range.second; ++entry) {
-                current_cfg->getCfgOptionDef()->del((*entry)->getObjectId());
+            BOOST_FOREACH(auto const& entry, range) {
+                current_cfg->getCfgOptionDef()->del(entry->getObjectId());
             }
 
             // Repeat the same for other configuration elements.
 
             range = index.equal_range(boost::make_tuple("dhcp4_options",
                                                         AuditEntry::ModificationType::DELETE));
-            for (auto entry = range.first; entry != range.second; ++entry) {
-                current_cfg->getCfgOption()->del((*entry)->getObjectId());
+            BOOST_FOREACH(auto const& entry, range) {
+                current_cfg->getCfgOption()->del(entry->getObjectId());
             }
 
             range = index.equal_range(boost::make_tuple("dhcp4_client_class",
                                                         AuditEntry::ModificationType::DELETE));
-            for (auto entry = range.first; entry != range.second; ++entry) {
-                current_cfg->getClientClassDictionary()->removeClass((*entry)->getObjectId());
+            BOOST_FOREACH(auto const& entry, range) {
+                current_cfg->getClientClassDictionary()->removeClass(entry->getObjectId());
             }
 
             range = index.equal_range(boost::make_tuple("dhcp4_shared_network",
                                                         AuditEntry::ModificationType::DELETE));
-            for (auto entry = range.first; entry != range.second; ++entry) {
-                current_cfg->getCfgSharedNetworks4()->del((*entry)->getObjectId());
+            BOOST_FOREACH(auto const& entry, range) {
+                current_cfg->getCfgSharedNetworks4()->del(entry->getObjectId());
             }
 
             range = index.equal_range(boost::make_tuple("dhcp4_subnet",
                                                         AuditEntry::ModificationType::DELETE));
-            for (auto entry = range.first; entry != range.second; ++entry) {
+            BOOST_FOREACH(auto const& entry, range) {
                 // If the deleted subnet belongs to a shared network and the
                 // shared network is not being removed, we need to detach the
                 // subnet from the shared network.
-                auto subnet = current_cfg->getCfgSubnets4()->getBySubnetId((*entry)->getObjectId());
+                auto subnet = current_cfg->getCfgSubnets4()->getBySubnetId(entry->getObjectId());
                 if (subnet) {
                     // Check if the subnet belongs to a shared network.
                     SharedNetwork4Ptr network;
@@ -139,7 +140,7 @@ CBControlDHCPv4::databaseConfigApply(const BackendSelector& backend_selector,
                         network->del(subnet->getID());
                     }
                     // Actually delete the subnet from the configuration.
-                    current_cfg->getCfgSubnets4()->del((*entry)->getObjectId());
+                    current_cfg->getCfgSubnets4()->del(entry->getObjectId());
                 }
             }
 
@@ -177,11 +178,11 @@ CBControlDHCPv4::databaseConfigApply(const BackendSelector& backend_selector,
         OptionDefContainer option_defs =
             getMgr().getPool()->getModifiedOptionDefs4(backend_selector, server_selector,
                                                        lb_modification_time);
-        for (auto option_def = option_defs.begin(); option_def != option_defs.end(); ++option_def) {
-            if (!audit_entries.empty() && !hasObjectId(updated_entries, (*option_def)->getId())) {
+        for (auto const& option_def : option_defs) {
+            if (!audit_entries.empty() && !hasObjectId(updated_entries, option_def->getId())) {
                 continue;
             }
-            external_cfg->getCfgOptionDef()->add(*option_def);
+            external_cfg->getCfgOptionDef()->add(option_def);
         }
     }
 
@@ -193,11 +194,11 @@ CBControlDHCPv4::databaseConfigApply(const BackendSelector& backend_selector,
         OptionContainer options = getMgr().getPool()->getModifiedOptions4(backend_selector,
                                                                           server_selector,
                                                                           lb_modification_time);
-        for (auto option = options.begin(); option != options.end(); ++option) {
-            if (!audit_entries.empty() && !hasObjectId(updated_entries, (*option).getId())) {
+        for (auto const& option : options) {
+            if (!audit_entries.empty() && !hasObjectId(updated_entries, option.getId())) {
                 continue;
             }
-            external_cfg->getCfgOption()->add((*option), (*option).space_name_);
+            external_cfg->getCfgOption()->add(option, option.space_name_);
         }
     }
 
@@ -257,18 +258,18 @@ CBControlDHCPv4::databaseConfigApply(const BackendSelector& backend_selector,
                                                                   lb_modification_time);
     }
     // Iterate over all shared networks that may require reconfiguration.
-    for (auto network = networks.begin(); network != networks.end(); ++network) {
-        if (!allocator_changed && cb_update && !hasObjectId(updated_entries, (*network)->getId())) {
+    for (auto const& network : networks) {
+        if (!allocator_changed && cb_update && !hasObjectId(updated_entries, network->getId())) {
             continue;
         }
         // In order to take advantage of the dynamic inheritance of global
         // parameters to a shared network we need to set a callback function
         // for each network to allow for fetching global parameters.
-        (*network)->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
+        network->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
              return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
         });
-        (*network)->setDefaultAllocatorType(global_allocator);
-        external_cfg->getCfgSharedNetworks4()->add((*network));
+        network->setDefaultAllocatorType(global_allocator);
+        external_cfg->getCfgSharedNetworks4()->add(network);
     }
 
     // Next, fetch the subnets.
@@ -289,18 +290,18 @@ CBControlDHCPv4::databaseConfigApply(const BackendSelector& backend_selector,
                                                           lb_modification_time);
     }
     // Iterate over all subnets that may require reconfiguration.
-    for (auto subnet = subnets.begin(); subnet != subnets.end(); ++subnet) {
-        if (!allocator_changed && cb_update && !hasObjectId(updated_entries, (*subnet)->getID())) {
+    for (auto const& subnet : subnets) {
+        if (!allocator_changed && cb_update && !hasObjectId(updated_entries, subnet->getID())) {
             continue;
         }
         // In order to take advantage of the dynamic inheritance of global
         // parameters to a subnet we need to set a callback function for each
         // subnet to allow for fetching global parameters.
-        (*subnet)->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
+        subnet->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
             return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
         });
-        (*subnet)->setDefaultAllocatorType(global_allocator);
-        external_cfg->getCfgSubnets4()->add((*subnet));
+        subnet->setDefaultAllocatorType(global_allocator);
+        external_cfg->getCfgSubnets4()->add(subnet);
     }
 
     if (reconfig) {
index ca74a5e53129c48742755e6b9fc635208662ac15..fba428a38bae242152483e625d98eea6fff5f141 100644 (file)
@@ -12,6 +12,7 @@
 #include <dhcpsrv/parsers/simple_parser6.h>
 #include <hooks/callout_handle.h>
 #include <hooks/hooks_manager.h>
+#include <boost/foreach.hpp>
 
 using namespace isc::db;
 using namespace isc::data;
@@ -98,37 +99,37 @@ CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector
             // audit entry is found.
             range = index.equal_range(boost::make_tuple("dhcp6_option_def",
                                                         AuditEntry::ModificationType::DELETE));
-            for (auto entry = range.first; entry != range.second; ++entry) {
-                current_cfg->getCfgOptionDef()->del((*entry)->getObjectId());
+            BOOST_FOREACH(auto const& entry, range) {
+                current_cfg->getCfgOptionDef()->del(entry->getObjectId());
             }
 
             // Repeat the same for other configuration elements.
 
             range = index.equal_range(boost::make_tuple("dhcp6_options",
                                                         AuditEntry::ModificationType::DELETE));
-            for (auto entry = range.first; entry != range.second; ++entry) {
-                current_cfg->getCfgOption()->del((*entry)->getObjectId());
+            BOOST_FOREACH(auto const& entry, range) {
+                current_cfg->getCfgOption()->del(entry->getObjectId());
             }
 
             range = index.equal_range(boost::make_tuple("dhcp6_client_class",
                                                         AuditEntry::ModificationType::DELETE));
-            for (auto entry = range.first; entry != range.second; ++entry) {
-                current_cfg->getClientClassDictionary()->removeClass((*entry)->getObjectId());
+            BOOST_FOREACH(auto const& entry, range) {
+                current_cfg->getClientClassDictionary()->removeClass(entry->getObjectId());
             }
 
             range = index.equal_range(boost::make_tuple("dhcp6_shared_network",
                                                         AuditEntry::ModificationType::DELETE));
-            for (auto entry = range.first; entry != range.second; ++entry) {
-                current_cfg->getCfgSharedNetworks6()->del((*entry)->getObjectId());
+            BOOST_FOREACH(auto const& entry, range) {
+                current_cfg->getCfgSharedNetworks6()->del(entry->getObjectId());
             }
 
             range = index.equal_range(boost::make_tuple("dhcp6_subnet",
                                                         AuditEntry::ModificationType::DELETE));
-            for (auto entry = range.first; entry != range.second; ++entry) {
+            BOOST_FOREACH(auto const& entry, range) {
                 // If the deleted subnet belongs to a shared network and the
                 // shared network is not being removed, we need to detach the
                 // subnet from the shared network.
-                auto subnet = current_cfg->getCfgSubnets6()->getBySubnetId((*entry)->getObjectId());
+                auto subnet = current_cfg->getCfgSubnets6()->getBySubnetId(entry->getObjectId());
                 if (subnet) {
                     // Check if the subnet belongs to a shared network.
                     SharedNetwork6Ptr network;
@@ -138,7 +139,7 @@ CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector
                         network->del(subnet->getID());
                     }
                     // Actually delete the subnet from the configuration.
-                    current_cfg->getCfgSubnets6()->del((*entry)->getObjectId());
+                    current_cfg->getCfgSubnets6()->del(entry->getObjectId());
                 }
             }
 
@@ -176,11 +177,11 @@ CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector
         OptionDefContainer option_defs =
             getMgr().getPool()->getModifiedOptionDefs6(backend_selector, server_selector,
                                                        lb_modification_time);
-        for (auto option_def = option_defs.begin(); option_def != option_defs.end(); ++option_def) {
-            if (!audit_entries.empty() && !hasObjectId(updated_entries, (*option_def)->getId())) {
+        for (auto const& option_def : option_defs) {
+            if (!audit_entries.empty() && !hasObjectId(updated_entries, option_def->getId())) {
                 continue;
             }
-            external_cfg->getCfgOptionDef()->add(*option_def);
+            external_cfg->getCfgOptionDef()->add(option_def);
         }
     }
 
@@ -192,11 +193,11 @@ CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector
         OptionContainer options = getMgr().getPool()->getModifiedOptions6(backend_selector,
                                                                           server_selector,
                                                                           lb_modification_time);
-        for (auto option = options.begin(); option != options.end(); ++option) {
-            if (!audit_entries.empty() && !hasObjectId(updated_entries, (*option).getId())) {
+        for (auto const& option : options) {
+            if (!audit_entries.empty() && !hasObjectId(updated_entries, option.getId())) {
                 continue;
             }
-            external_cfg->getCfgOption()->add((*option), (*option).space_name_);
+            external_cfg->getCfgOption()->add(option, option.space_name_);
         }
     }
 
@@ -268,19 +269,19 @@ CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector
         networks = getMgr().getPool()->getModifiedSharedNetworks6(backend_selector, server_selector,
                                                                   lb_modification_time);
     }
-    for (auto network = networks.begin(); network != networks.end(); ++network) {
-        if (!allocator_changed && cb_update && !hasObjectId(updated_entries, (*network)->getId())) {
+    for (auto const& network : networks) {
+        if (!allocator_changed && cb_update && !hasObjectId(updated_entries, network->getId())) {
             continue;
         }
         // In order to take advantage of the dynamic inheritance of global
         // parameters to a shared network we need to set a callback function
         // for each network to allow for fetching global parameters.
-        (*network)->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
+        network->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
             return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
         });
-        (*network)->setDefaultAllocatorType(global_allocator);
-        (*network)->setDefaultPdAllocatorType(global_pd_allocator);
-        external_cfg->getCfgSharedNetworks6()->add((*network));
+        network->setDefaultAllocatorType(global_allocator);
+        network->setDefaultPdAllocatorType(global_pd_allocator);
+        external_cfg->getCfgSharedNetworks6()->add(network);
     }
 
     // Next we fetch subnets.
@@ -301,19 +302,19 @@ CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector
                                                           lb_modification_time);
     }
     // Iterate over all subnets that may require reconfiguration.
-    for (auto subnet = subnets.begin(); subnet != subnets.end(); ++subnet) {
-        if (!audit_entries.empty() && !hasObjectId(updated_entries, (*subnet)->getID())) {
+    for (auto const& subnet : subnets) {
+        if (!audit_entries.empty() && !hasObjectId(updated_entries, subnet->getID())) {
             continue;
         }
         // In order to take advantage of the dynamic inheritance of global
         // parameters to a subnet we need to set a callback function for each
         // subnet to allow for fetching global parameters.
-        (*subnet)->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
+        subnet->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
             return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
         });
-        (*subnet)->setDefaultAllocatorType(global_allocator);
-        (*subnet)->setDefaultPdAllocatorType(global_pd_allocator);
-        external_cfg->getCfgSubnets6()->add((*subnet));
+        subnet->setDefaultAllocatorType(global_allocator);
+        subnet->setDefaultPdAllocatorType(global_pd_allocator);
+        external_cfg->getCfgSubnets6()->add(subnet);
     }
 
     if (reconfig) {
index e3a37bfa30c4a2722c6d47958fa60d583ece200b..37038a46beba402810097e983726cd46f4bf3b93 100644 (file)
@@ -13,7 +13,6 @@
 #include <dhcpsrv/host_mgr.h>
 #include <dhcpsrv/lease_mgr_factory.h>
 #include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
 #include <sstream>
 #include <vector>
index ed43125b3375ef826488181a68143653098f6246..7aab23038dbc681833ae26ef33fc9c9c94b33ce3 100644 (file)
@@ -84,18 +84,17 @@ struct CfgGlobalsChecks {
         // Build the name vector.
         std::vector<std::string> names;
         names.resize(CfgGlobals::SIZE);
-        for (auto it = CfgGlobals::nameToIndex.cbegin();
-             it != CfgGlobals::nameToIndex.cend(); ++it) {
-            int idx = it->second;
+        for (auto const& it : CfgGlobals::nameToIndex) {
+            int idx = it.second;
             if ((idx < 0) || (idx >= CfgGlobals::SIZE)) {
                 isc_throw(Unexpected, "invalid index " << idx
-                          << " for name " << it->first);
+                          << " for name " << it.first);
             }
             if (!names[idx].empty()) {
                 isc_throw(Unexpected, "duplicated names for " << idx
                           << " got " << names[idx]);
             }
-            names[idx] = it->first;
+            names[idx] = it.first;
         }
 
         // No name should be empty.
@@ -160,11 +159,11 @@ CfgGlobals::clear() {
 const CfgGlobals::MapType
 CfgGlobals::valuesMap() const {
     MapType map;
-    for (auto it = nameToIndex.cbegin(); it != nameToIndex.cend(); ++it) {
-        int idx = it->second;
+    for (auto const& it : nameToIndex) {
+        int idx = it.second;
         ConstElementPtr value = values_[idx];
         if (value) {
-            map.insert(make_pair(it->first, value));
+            map.insert(make_pair(it.first, value));
         }
     }
     return (map);
@@ -173,11 +172,11 @@ CfgGlobals::valuesMap() const {
 ElementPtr
 CfgGlobals::toElement() const {
     ElementPtr result = Element::createMap();
-    for (auto it = nameToIndex.cbegin(); it != nameToIndex.cend(); ++it) {
-        int idx = it->second;
+    for (auto const& it : nameToIndex) {
+        int idx = it.second;
         ConstElementPtr value = values_[idx];
         if (value) {
-            result->set(it->first, value);
+            result->set(it.first, value);
         }
     }
     return (result);
index f588b9dc610e88bffd9ab70f4684d0f97c02ebfa..08093047b34881e0a3123db1a5876970ba63fa1d 100644 (file)
@@ -61,9 +61,8 @@ CfgHostOperations::clearIdentifierTypes() {
 ElementPtr
 CfgHostOperations::toElement() const {
     ElementPtr result = Element::createList();
-    for (IdentifierTypes::const_iterator id = identifier_types_.begin();
-         id != identifier_types_.end(); ++id) {
-        const std::string& name = Host::getIdentifierName(*id);
+    for (auto const& id : identifier_types_) {
+        const std::string& name = Host::getIdentifierName(id);
         result->add(Element::create(name));
     }
     return (result);
index bee54332bc4e4617adb2b1a3827e8b1ca8f7de90..69b924a0f9a2252cbaa80c53764ba9454ce83bc4 100644 (file)
@@ -13,6 +13,7 @@
 #include <dhcpsrv/cfgmgr.h>
 #include <exceptions/exceptions.h>
 #include <util/encode/hex.h>
+#include <boost/foreach.hpp>
 #include <ostream>
 #include <string>
 #include <vector>
@@ -618,13 +619,12 @@ CfgHosts::getAllInternal4(const IOAddress& address, Storage& storage) const {
     const HostContainerIndex1& idx = hosts_.get<1>();
     HostContainerIndex1Range r = idx.equal_range(address);
     // Append each Host object to the storage.
-    for (HostContainerIndex1::iterator host = r.first; host != r.second;
-         ++host) {
+    BOOST_FOREACH(auto const& host, r) {
         LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
                   HOSTS_CFG_GET_ALL_ADDRESS4_HOST)
             .arg(address.toText())
-            .arg((*host)->toText());
-        storage.push_back(*host);
+            .arg(host->toText());
+        storage.push_back(host);
     }
 
     LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS, HOSTS_CFG_GET_ALL_ADDRESS4_COUNT)
@@ -647,13 +647,12 @@ CfgHosts::getAllInternal6(const IOAddress& address, Storage& storage) const {
     const HostContainer6Index4& idx = hosts6_.get<4>();
     HostContainer6Index4Range r = idx.equal_range(address);
     // Append each Host object to the storage.
-    for (HostContainer6Index4::iterator reservation = r.first; reservation != r.second;
-         ++reservation) {
+    BOOST_FOREACH(auto const& reservation, r) {
         LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
                   HOSTS_CFG_GET_ALL_ADDRESS6_HOST)
             .arg(address.toText())
-            .arg(reservation->host_->toText());
-        storage.push_back(reservation->host_);
+            .arg(reservation.host_->toText());
+        storage.push_back(reservation.host_);
     }
 
     LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS, HOSTS_CFG_GET_ALL_ADDRESS6_COUNT)
@@ -685,15 +684,14 @@ CfgHosts::get4(const SubnetID& subnet_id, const IOAddress& address) const {
         .arg(subnet_id).arg(address.toText());
 
     ConstHostCollection hosts = getAll4(address);
-    for (ConstHostCollection::const_iterator host = hosts.begin();
-         host != hosts.end(); ++host) {
-        if ((*host)->getIPv4SubnetID() == subnet_id) {
+    for (auto const& host : hosts) {
+        if (host->getIPv4SubnetID() == subnet_id) {
             LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS,
                       HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS4_HOST)
                 .arg(subnet_id)
                 .arg(address.toText())
-                .arg((*host)->toText());
-            return (*host);
+                .arg(host->toText());
+            return (host);
         }
     }
 
@@ -822,15 +820,14 @@ CfgHosts::getHostInternal6(const asiolink::IOAddress& prefix,
     const HostContainer6Index0& idx = hosts6_.get<0>();
     HostContainer6Index0Range r = make_pair(idx.lower_bound(prefix),
                                             idx.upper_bound(prefix));
-    for (HostContainer6Index0::iterator resrv = r.first; resrv != r.second;
-         ++resrv) {
-        if (resrv->resrv_.getPrefixLen() == prefix_len) {
+    BOOST_FOREACH(auto const& resrv, r) {
+        if (resrv.resrv_.getPrefixLen() == prefix_len) {
             LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
                       HOSTS_CFG_GET_ONE_PREFIX_HOST)
                 .arg(prefix.toText())
                 .arg(static_cast<int>(prefix_len))
-                .arg(resrv->host_->toText());
-            return (resrv->host_);
+                .arg(resrv.host_->toText());
+            return (resrv.host_);
         }
     }
 
@@ -864,13 +861,13 @@ CfgHosts::getAllInternal6(const SubnetID& subnet_id,
     // in all sane cases, there will be only one such host. (Each host can have
     // multiple addresses reserved, but for each (address, subnet_id) there should
     // be at most one host reserving it).
-    for(HostContainer6Index1::iterator resrv = r.first; resrv != r.second; ++resrv) {
+    BOOST_FOREACH(auto const& resrv, r) {
         LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA,
                   HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS6_HOST)
             .arg(subnet_id)
             .arg(address.toText())
-            .arg(resrv->host_->toText());
-        storage.push_back(resrv->host_);
+            .arg(resrv.host_->toText());
+        storage.push_back(resrv.host_);
     }
 
     LOG_DEBUG(hosts_logger, HOSTS_DBG_RESULTS,
@@ -901,11 +898,10 @@ CfgHosts::getHostInternal(const SubnetID& subnet_id, const bool subnet6,
     HostPtr host;
     // Iterate over the returned hosts and select those for which the
     // subnet id matches.
-    for (HostCollection::const_iterator host_it = hosts.begin();
-         host_it != hosts.end(); ++host_it) {
+    for (auto const& host_it : hosts) {
         // Check if this is IPv4 subnet or IPv6 subnet.
-        SubnetID host_subnet_id = subnet6 ? (*host_it)->getIPv6SubnetID() :
-            (*host_it)->getIPv4SubnetID();
+        SubnetID host_subnet_id = subnet6 ? host_it->getIPv6SubnetID() :
+            host_it->getIPv4SubnetID();
 
         if (subnet_id == host_subnet_id) {
             // If this is the first occurrence of the host for this subnet,
@@ -916,7 +912,7 @@ CfgHosts::getHostInternal(const SubnetID& subnet_id, const bool subnet6,
             // result, and we don't know which reservation we should choose.
             // Therefore, throw an exception.
             if (!host) {
-                host = *host_it;
+                host = host_it;
 
             } else {
                 isc_throw(DuplicateHost,  "more than one reservation found"
@@ -1066,22 +1062,21 @@ CfgHosts::add6(const HostPtr& host) {
     }
 
     // Now for each reservation, insert corresponding (address, host) tuple.
-    for (IPv6ResrvIterator it = reservations.first; it != reservations.second;
-         ++it) {
+    BOOST_FOREACH(auto const& it, reservations) {
 
         if (ip_reservations_unique_) {
             // If there's an entry for this (subnet-id, address), reject it.
-            if (get6(host->getIPv6SubnetID(), it->second.getPrefix())) {
+            if (get6(host->getIPv6SubnetID(), it.second.getPrefix())) {
                 isc_throw(DuplicateHost, "failed to add address reservation for "
                           << "host using the HW address '"
                           << (hwaddr ? hwaddr->toText(false) : "(null)")
                           << " and DUID '" << (duid ? duid->toText() : "(null)")
                           << "' to the IPv6 subnet id '" << host->getIPv6SubnetID()
-                          << "' for address/prefix " << it->second.getPrefix()
+                          << "' for address/prefix " << it.second.getPrefix()
                           << ": There's already reservation for this address/prefix");
             }
         }
-        hosts6_.insert(HostResrv6Tuple(it->second, host));
+        hosts6_.insert(HostResrv6Tuple(it.second, host));
     }
 }
 
@@ -1103,8 +1098,8 @@ CfgHosts::del(const SubnetID& subnet_id, const asiolink::IOAddress& addr) {
         auto const& range = idx6.equal_range(boost::make_tuple(subnet_id, addr));
         erased_addresses = boost::distance(range);
         // Delete hosts.
-        for (auto key = range.first; key != range.second; ++key) {
-            erased_hosts += idx.erase(key->host_->getHostId());
+        BOOST_FOREACH(auto const& key, range) {
+            erased_hosts += idx.erase(key.host_->getHostId());
         }
         idx6.erase(range.first, range.second);
     }
@@ -1137,8 +1132,8 @@ CfgHosts::del4(const SubnetID& subnet_id,
                const size_t identifier_len) {
     HostContainerIndex0& idx = hosts_.get<0>();
     auto const t = boost::make_tuple(std::vector<uint8_t>(identifier_begin,
-                                                    identifier_begin + identifier_len),
-                                                    identifier_type);
+                                                          identifier_begin + identifier_len),
+                                                          identifier_type);
     auto const& range = idx.equal_range(t);
     size_t erased = 0;
     for (auto key = range.first; key != range.second;) {
@@ -1241,14 +1236,13 @@ CfgHosts::toElement4() const {
     CfgHostsList result;
     // Iterate using arbitrary the index 0
     const HostContainerIndex0& idx = hosts_.get<0>();
-    for (HostContainerIndex0::const_iterator host = idx.begin();
-         host != idx.end(); ++host) {
+    for (auto const& host : idx) {
 
         // Convert host to element representation
-        ElementPtr map = (*host)->toElement4();
+        ElementPtr map = host->toElement4();
 
         // Push it on the list
-        SubnetID subnet_id = (*host)->getIPv4SubnetID();
+        SubnetID subnet_id = host->getIPv4SubnetID();
         result.add(subnet_id, map);
     }
     return (result.externalize());
@@ -1259,14 +1253,13 @@ CfgHosts::toElement6() const {
     CfgHostsList result;
     // Iterate using arbitrary the index 0
     const HostContainerIndex0& idx = hosts_.get<0>();
-    for (HostContainerIndex0::const_iterator host = idx.begin();
-         host != idx.end(); ++host) {
+    for (auto const& host : idx) {
 
         // Convert host to Element representation
-        ElementPtr map = (*host)->toElement6();
+        ElementPtr map = host->toElement6();
 
         // Push it on the list
-        SubnetID subnet_id = (*host)->getIPv6SubnetID();
+        SubnetID subnet_id = host->getIPv6SubnetID();
         result.add(subnet_id, map);
     }
     return (result.externalize());
index 11c9e87aa2f5d7e2f2c2f541257bc880a70aceba..31db3c1eecf86080633de10f9268563add307939 100644 (file)
@@ -62,11 +62,10 @@ void CfgHostsList::internalize(ConstElementPtr list) {
 
 ElementPtr CfgHostsList::externalize() const {
     ElementPtr result = Element::createList();
-    for (CfgHostsMap::const_iterator item = map_.begin();
-         item != map_.end(); ++item) {
+    for (auto const& item : map_) {
         ElementPtr pair = Element::createMap();
-        pair->set("id", Element::create(static_cast<int64_t>(item->first)));
-        pair->set("reservations", item->second);
+        pair->set("id", Element::create(static_cast<int64_t>(item.first)));
+        pair->set("reservations", item.second);
         result->add(pair);
     }
     return (result);
index 16f523cadaec9e7d84680fa2fa2a2c82fc87d551..fa23e54db817ff0998dc2314df6f3bbe7b065cc6 100644 (file)
@@ -49,7 +49,7 @@ CfgIface::equals(const CfgIface& other) const {
 
 bool
 CfgIface::multipleAddressesPerInterfaceActive() {
-    for (const IfacePtr& iface : IfaceMgr::instance().getIfaces()) {
+    for (auto const& iface : IfaceMgr::instance().getIfaces()) {
         if (iface->countActive4() > 1) {
             return (true);
         }
@@ -69,17 +69,15 @@ CfgIface::openSockets(const uint16_t family, const uint16_t port,
     bool loopback_used_ = false;
     if ((family == AF_INET6) || (socket_type_ == SOCKET_UDP)) {
         // Check interface set
-        for (IfaceSet::const_iterator iface_name = iface_set_.begin();
-             iface_name != iface_set_.end(); ++iface_name) {
-            IfacePtr iface = IfaceMgr::instance().getIface(*iface_name);
+        for (auto const& iface_name : iface_set_) {
+            IfacePtr iface = IfaceMgr::instance().getIface(iface_name);
             if (iface && iface->flag_loopback_) {
                 loopback_used_ = true;
             }
         }
         // Check address map
-        for (ExplicitAddressMap::const_iterator unicast = address_map_.begin();
-             unicast != address_map_.end(); ++unicast) {
-            IfacePtr iface = IfaceMgr::instance().getIface(unicast->first);
+        for (auto const& unicast : address_map_) {
+            IfacePtr iface = IfaceMgr::instance().getIface(unicast.first);
             if (iface && iface->flag_loopback_) {
                 loopback_used_ = true;
             }
@@ -112,9 +110,8 @@ CfgIface::openSockets(const uint16_t family, const uint16_t port,
     // If there is no wildcard interface specified, we will have to iterate
     // over the names specified by the caller and enable them.
     if (!wildcard_used_) {
-        for (IfaceSet::const_iterator iface_name = iface_set_.begin();
-             iface_name != iface_set_.end(); ++iface_name) {
-            IfacePtr iface = IfaceMgr::instance().getIface(*iface_name);
+        for (auto const& iface_name : iface_set_) {
+            IfacePtr iface = IfaceMgr::instance().getIface(iface_name);
             // This shouldn't really happen because we are checking the
             // names of interfaces when they are being added (use()
             // function). But, if someone has triggered detection of
@@ -122,7 +119,7 @@ CfgIface::openSockets(const uint16_t family, const uint16_t port,
             if (iface == NULL) {
                 isc_throw(Unexpected,
                           "fail to open socket on interface '"
-                          << *iface_name << "' as this interface doesn't"
+                          << iface_name << "' as this interface doesn't"
                           " exist");
 
             } else if (family == AF_INET) {
@@ -137,21 +134,20 @@ CfgIface::openSockets(const uint16_t family, const uint16_t port,
 
     // Select unicast sockets for DHCPv6 or activate specific IPv4 addresses
     // for DHCPv4.
-    for (ExplicitAddressMap::const_iterator unicast = address_map_.begin();
-         unicast != address_map_.end(); ++unicast) {
-        IfacePtr iface = IfaceMgr::instance().getIface(unicast->first);
+    for (auto const& unicast : address_map_) {
+        IfacePtr iface = IfaceMgr::instance().getIface(unicast.first);
         if (iface == NULL) {
             isc_throw(Unexpected,
                       "fail to open unicast socket on interface '"
-                      << unicast->first << "' as this interface doesn't"
+                      << unicast.first << "' as this interface doesn't"
                       " exist");
         }
         if (family == AF_INET6) {
-            iface->addUnicast(unicast->second);
+            iface->addUnicast(unicast.second);
             iface->inactive6_ = false;
 
         } else {
-            iface->setActive(unicast->second, true);
+            iface->setActive(unicast.second, true);
             iface->inactive4_ = false;
         }
     }
@@ -284,7 +280,7 @@ CfgIface::reset() {
 void
 CfgIface::setState(const uint16_t family, const bool inactive,
                    const bool loopback_inactive) const {
-    for (const IfacePtr& iface : IfaceMgr::instance().getIfaces()) {
+    for (auto const& iface : IfaceMgr::instance().getIfaces()) {
         bool iface_inactive = iface->flag_loopback_ ? loopback_inactive : inactive;
         if (family == AF_INET) {
             iface->inactive4_ = iface_inactive;
@@ -301,7 +297,7 @@ void
 CfgIface::setIfaceAddrsState(const uint16_t family, const bool active,
                              Iface& iface) const {
     // Activate/deactivate all addresses.
-    for (const Iface::Address& addr : iface.getAddresses()) {
+    for (auto const& addr : iface.getAddresses()) {
         if (addr.get().getFamily() == family) {
             iface.setActive(addr.get(), active);
         }
@@ -565,13 +561,11 @@ CfgIface::toElement() const {
     if (wildcard_used_) {
         ifaces->add(Element::create(std::string(ALL_IFACES_KEYWORD)));
     }
-    for (IfaceSet::const_iterator iface = iface_set_.cbegin();
-         iface != iface_set_.cend(); ++iface) {
-        ifaces->add(Element::create(*iface));
+    for (auto const& iface : iface_set_) {
+        ifaces->add(Element::create(iface));
     }
-    for (ExplicitAddressMap::const_iterator address = address_map_.cbegin();
-         address != address_map_.cend(); ++address) {
-        std::string spec = address->first + "/" + address->second.toText();
+    for (auto const& address : address_map_) {
+        std::string spec = address.first + "/" + address.second.toText();
         ifaces->add(Element::create(spec));
     }
     result->set("interfaces", ifaces);
index 7a0db260b38dc73b34c012d47b2a70796c0b2ab3..8fbc9c71d399bf495fab899f1fcfe1419187af4d 100644 (file)
@@ -55,9 +55,8 @@ uint32_t CfgMACSource::MACSourceFromText(const std::string& name) {
 }
 
 void CfgMACSource::add(uint32_t source) {
-    for (CfgMACSources::const_iterator it = mac_sources_.begin();
-         it != mac_sources_.end(); ++it) {
-        if (*it == source) {
+    for (auto const& it : mac_sources_) {
+        if (it == source) {
             isc_throw(InvalidParameter, "mac-source parameter " << source
                       << "' specified twice.");
         }
@@ -67,17 +66,16 @@ void CfgMACSource::add(uint32_t source) {
 
 ElementPtr CfgMACSource::toElement() const {
     ElementPtr result = Element::createList();
-    for (CfgMACSources::const_iterator source = mac_sources_.cbegin();
-         source != mac_sources_.cend(); ++source) {
+    for (auto const& source : mac_sources_) {
         std::string name;
         for (unsigned i = 0; i < sizeof(sources)/sizeof(sources[0]); ++i) {
-            if (sources[i].type == *source) {
+            if (sources[i].type == source) {
                 name = sources[i].name;
                 break;
             }
         }
         if (name.empty()) {
-            isc_throw(ToElementError, "invalid MAC source: " << *source);
+            isc_throw(ToElementError, "invalid MAC source: " << source);
         }
         result->add(Element::create(name));
     }
@@ -85,5 +83,5 @@ ElementPtr CfgMACSource::toElement() const {
     return (result);
 }
 
-};
-};
+}
+}
index c4b8f470216a30cffbdb14c63cad2dfaab56f100..4b731090f42e94550de13d2bd96729157f844bec 100644 (file)
@@ -374,16 +374,14 @@ CfgOption::del(const std::string& option_space, const uint16_t option_code) {
         auto option_space_names = getOptionSpaceNames();
         for (auto const& option_space_from_list : option_space_names) {
             // Get all options within the particular option space.
-            auto options_in_space = getAll(option_space_from_list);
-            for (auto option_it = options_in_space->begin();
-                 option_it != options_in_space->end();
-                 ++option_it) {
+            auto const& options_in_space = getAll(option_space_from_list);
+            for (auto const& option_it : *options_in_space) {
 
                 // Check if the option encapsulates our option space and
                 // it does, try to delete our option.
-                if (option_it->option_ &&
-                    (option_it->option_->getEncapsulatedSpace() == option_space)) {
-                    option_it->option_->delOption(option_code);
+                if (option_it.option_ &&
+                    (option_it.option_->getEncapsulatedSpace() == option_space)) {
+                    option_it.option_->delOption(option_code);
                 }
             }
         }
@@ -413,20 +411,18 @@ CfgOption::del(const uint64_t id) {
     // any of them. Let's walk over the existing option spaces.
     for (auto const& space_name : getOptionSpaceNames()) {
         // Get all options for the option space.
-        auto options = getAll(space_name);
-        for (auto option_it = options->begin(); option_it != options->end();
-             ++option_it) {
-            if (!option_it->option_) {
+        auto const& options = getAll(space_name);
+        for (auto const& option_it : *options) {
+            if (!option_it.option_) {
                 continue;
             }
 
             // For each option within the option space we need to dereference
             // any existing sub options.
-            auto sub_options = option_it->option_->getOptions();
-            for (auto sub = sub_options.begin(); sub != sub_options.end();
-                 ++sub) {
+            auto sub_options = option_it.option_->getOptions();
+            for (auto const& sub : sub_options) {
                 // Dereference sub option.
-                option_it->option_->delOption(sub->second->getType());
+                option_it.option_->delOption(sub.second->getType());
             }
         }
     }
index a0c6d0b68d3f3a8bbe1c1d840e974660f3165759..fd33d8df8b87c11595c94f4d810101237e355f05 100644 (file)
@@ -14,6 +14,7 @@
 #include <cc/user_context.h>
 #include <dhcpsrv/cfg_option_def.h>
 #include <dhcpsrv/key_from_key.h>
+#include <boost/foreach.hpp>
 #include <boost/multi_index_container.hpp>
 #include <boost/multi_index/hashed_index.hpp>
 #include <boost/multi_index/ordered_index.hpp>
@@ -516,7 +517,7 @@ public:
     /// there is no definition matching the option code in the given space, or
     /// if the definition factory invocation fails.
     static bool createDescriptorOption(CfgOptionDefPtr cfg_def, const std::string& space,
-                             OptionDescriptor& opt_desc);
+                                       OptionDescriptor& opt_desc);
 
     /// @brief Merges this configuration to another configuration.
     ///
@@ -646,9 +647,8 @@ public:
         const OptionContainerTypeIndex& idx = options->get<1>();
         OptionContainerTypeRange range = idx.equal_range(option_code);
         // This code copies descriptors and can be optimized not doing this.
-        for (OptionContainerTypeIndex::const_iterator od_itr = range.first;
-             od_itr != range.second; ++od_itr) {
-            list.push_back(*od_itr);
+        BOOST_FOREACH(auto const& od_itr, range) {
+            list.push_back(od_itr);
         }
 
         return (list);
index e154d1944184ee576a9d42da94ad3b2914cdaf6e..f1671f3f6f231aecbc93186c471f510ed9dbb172 100644 (file)
@@ -23,13 +23,11 @@ CfgOptionDef::copyTo(CfgOptionDef& new_config) const {
     new_config.option_definitions_.clearItems();
     const std::list<std::string>& names =
         option_definitions_.getOptionSpaceNames();
-    for (std::list<std::string>::const_iterator name = names.begin();
-         name != names.end(); ++name) {
-        OptionDefContainerPtr defs = getAll(*name);
-        for (OptionDefContainer::const_iterator def = defs->begin();
-             def != defs->end(); ++def) {
+    for (auto const& name : names) {
+        OptionDefContainerPtr defs = getAll(name);
+        for (auto const& def : *defs) {
             OptionDefinitionPtr new_def =
-                OptionDefinitionPtr(new OptionDefinition(**def));
+                OptionDefinitionPtr(new OptionDefinition(*def));
             new_config.add(new_def);
         }
     }
@@ -49,23 +47,20 @@ CfgOptionDef::equals(const CfgOptionDef& other) const {
     }
     // Iterate over all option space names and get the definitions for each
     // of them.
-    for (std::list<std::string>::const_iterator name = names.begin();
-         name != names.end(); ++name) {
+    for (auto const& name : names) {
         // Get all definitions.
-        OptionDefContainerPtr defs = getAll(*name);
-        OptionDefContainerPtr other_defs = other.getAll(*name);
+        OptionDefContainerPtr defs = getAll(name);
+        OptionDefContainerPtr other_defs = other.getAll(name);
         // Compare sizes. If they hold different number of definitions,
         // they are unequal.
         if (defs->size() != defs->size()) {
             return (false);
         }
         // For each option definition, try to find one in the other object.
-        for (OptionDefContainer::const_iterator def = defs->begin();
-             def != defs->end(); ++def) {
-            OptionDefinitionPtr
-                other_def = other.get(*name, (*def)->getCode());
+        for (auto const& def : *defs) {
+            OptionDefinitionPtr other_def = other.get(name, def->getCode());
             // Actually compare them.
-            if (!other_def || (*other_def != **def)) {
+            if (!other_def || (*other_def != *def)) {
                 return (false);
             }
         }
@@ -175,41 +170,40 @@ CfgOptionDef::toElementWithMetadata(const bool include_metadata) const {
     // Iterate through the container by names and definitions
     const std::list<std::string>& names =
         option_definitions_.getOptionSpaceNames();
-    for (std::list<std::string>::const_iterator name = names.begin();
-         name != names.end(); ++name) {
-        OptionDefContainerPtr defs = getAll(*name);
-        for (OptionDefContainer::const_iterator def = defs->begin();
-             def != defs->end(); ++def) {
+    for (auto const& name : names) {
+        OptionDefContainerPtr defs = getAll(name);
+        for (auto const& def : *defs) {
             // Get and fill the map for this definition
             ElementPtr map = Element::createMap();
             // Set user context
-            (*def)->contextToElement(map);
+            def->contextToElement(map);
             // Set space from parent iterator
-            map->set("space", Element::create(*name));
+            map->set("space", Element::create(name));
             // Set required items: name, code and type
-            map->set("name", Element::create((*def)->getName()));
-            map->set("code", Element::create((*def)->getCode()));
+            map->set("name", Element::create(def->getName()));
+            map->set("code", Element::create(def->getCode()));
             std::string data_type =
-                OptionDataTypeUtil::getDataTypeName((*def)->getType());
+                OptionDataTypeUtil::getDataTypeName(def->getType());
             map->set("type", Element::create(data_type));
             // Set the array type
-            bool array_type = (*def)->getArrayType();
+            bool array_type = def->getArrayType();
             map->set("array", Element::create(array_type));
             // Set the encapsulate space
-            std::string encapsulates = (*def)->getEncapsulatedSpace();
+            std::string encapsulates = def->getEncapsulatedSpace();
             map->set("encapsulate", Element::create(encapsulates));
             // Set the record field types
             OptionDefinition::RecordFieldsCollection fields =
-                (*def)->getRecordFields();
+                def->getRecordFields();
             if (!fields.empty()) {
                 std::ostringstream oss;
-                for (OptionDefinition::RecordFieldsCollection::const_iterator
-                         field = fields.begin();
-                     field != fields.end(); ++field) {
-                    if (field != fields.begin()) {
+                bool first = true;
+                for (auto const& field : fields) {
+                    if (!first) {
                         oss << ", ";
+                    } else {
+                        first = false;
                     }
-                    oss << OptionDataTypeUtil::getDataTypeName(*field);
+                    oss << OptionDataTypeUtil::getDataTypeName(field);
                 }
                 map->set("record-types", Element::create(oss.str()));
             } else {
@@ -218,7 +212,7 @@ CfgOptionDef::toElementWithMetadata(const bool include_metadata) const {
 
             // Include metadata if requested.
             if (include_metadata) {
-                map->set("metadata", (*def)->getMetadata());
+                map->set("metadata", def->getMetadata());
             }
 
             // Push on the list
index 30f02e67c20d207e624d4f2938e9b15b30698880..b9f4e4595cb7f36a7f1f7b5cd59ebb3a8d36c1c8 100644 (file)
@@ -42,9 +42,8 @@ ElementPtr
 CfgRSOO::toElement() const {
     ElementPtr result = Element::createList();
     // We can use LibDHCP::getOptionDef(DHCP6_OPTION_SPACE, *opt) too...
-    for (std::set<uint16_t>::const_iterator opt = rsoo_options_.cbegin();
-         opt != rsoo_options_.cend(); ++opt) {
-        const std::string& code = boost::lexical_cast<std::string>(*opt);
+    for (auto const& opt : rsoo_options_) {
+        const std::string& code = boost::lexical_cast<std::string>(opt);
         result->add(Element::create(code));
     }
     return (result);
index a47822017141026ce9ce4e31c0d2597f457b9c1a..4bf38ac50f049c23f45c9c4cf3338db3ceaa7a9d 100644 (file)
@@ -12,6 +12,7 @@
 #include <cc/data.h>
 #include <exceptions/exceptions.h>
 #include <dhcpsrv/shared_network.h>
+#include <boost/foreach.hpp>
 #include <boost/shared_ptr.hpp>
 #include <string>
 
@@ -91,8 +92,8 @@ public:
 
         // For each shared network found, dereference the subnets belonging
         // to it.
-        for (auto it = sn_range.first; it != sn_range.second; ++it) {
-            (*it)->delAll();
+        BOOST_FOREACH(auto const& it, sn_range) {
+            it->delAll();
         }
 
         // Remove the shared networks.
@@ -123,9 +124,8 @@ public:
 
         // Insert shared networks sorted by their names into the list.
         auto const& index = networks_.template get<SharedNetworkNameIndexTag>();
-        for (auto shared_network = index.begin(); shared_network != index.end();
-             ++shared_network) {
-            list->add((*shared_network)->toElement());
+        for (auto const& shared_network : index) {
+            list->add(shared_network->toElement());
         }
         return (list);
     }
@@ -165,21 +165,20 @@ public:
         // Iterate over the subnets to be merged. They will replace the existing
         // subnets with the same id. All new subnets will be inserted into this
         // configuration.
-        auto other_networks = other.getAll();
-        for (auto other_network = other_networks->begin();
-            other_network != other_networks->end(); ++other_network) {
+        auto const& other_networks = other.getAll();
+        for (auto const& other_network : *other_networks) {
 
             // In theory we should drop subnet assignments from "other". The
             // idea being  those that come from the CB should not have subnets_
             // populated.  We will quietly throw them away, just in case.
-            (*other_network)->delAll();
+            other_network->delAll();
 
             // Check if the other network exists in this config.
-            auto existing_network = index.find((*other_network)->getName());
+            auto existing_network = index.find(other_network->getName());
             if (existing_network != index.end()) {
 
                 // Somehow the same instance is in both, skip it.
-                if (*existing_network == *other_network) {
+                if (*existing_network == other_network) {
                     continue;
                 }
 
@@ -189,9 +188,9 @@ public:
                 auto const subnets = (*existing_network)->getAllSubnets();
 
                 auto copy_subnets(*subnets);
-                for (auto subnet = copy_subnets.cbegin(); subnet != copy_subnets.cend(); ++subnet) {
-                    (*existing_network)->del((*subnet)->getID());
-                    (*other_network)->add(*subnet);
+                for (auto const& subnet : copy_subnets) {
+                    (*existing_network)->del(subnet->getID());
+                    other_network->add(subnet);
                 }
 
                 // Now we discard the existing copy of the network.
@@ -199,10 +198,10 @@ public:
             }
 
             // Create the network's options based on the given definitions.
-            (*other_network)->getCfgOption()->createOptions(cfg_def);
+            other_network->getCfgOption()->createOptions(cfg_def);
 
             // Add the new/updated nework.
-            static_cast<void>(networks_.push_back(*other_network));
+            static_cast<void>(networks_.push_back(other_network));
         }
     }
 
index 179c5bd22677c24d2032996ea5ac08cda3002d65..b1dcec60359767eb685242e379c70c894583e6c7 100644 (file)
@@ -13,7 +13,7 @@
 #include <dhcpsrv/lease_mgr_factory.h>
 #include <dhcpsrv/subnet_id.h>
 #include <stats/stats_mgr.h>
-#include <boost/foreach.hpp>
+#include <boost/range/adaptor/reversed.hpp>
 #include <string.h>
 #include <sstream>
 
@@ -210,7 +210,7 @@ CfgSubnets6::initSelector(const Pkt6Ptr& query) {
 
     // Initialize fields specific to relayed messages.
     if (!query->relay_info_.empty()) {
-        BOOST_REVERSE_FOREACH(Pkt6::RelayInfo relay, query->relay_info_) {
+        for (auto const& relay : boost::adaptors::reverse(query->relay_info_)) {
             if (!relay.linkaddr_.isV6Zero() &&
                 !relay.linkaddr_.isV6LinkLocal()) {
                 selector.first_relay_linkaddr_ = relay.linkaddr_;
index 168288343cf710bb2deb3d5d5e9f77126f863ddf..033ad369897a95680448d2c7723afdc12cb8bb98 100644 (file)
@@ -13,7 +13,6 @@
 #include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/dhcpsrv_log.h>
 #include <dhcpsrv/parsers/client_class_def_parser.h>
-#include <boost/foreach.hpp>
 
 #include <queue>
 
@@ -55,7 +54,7 @@ ClientClassDef::ClientClassDef(const ClientClassDef& rhs)
 
     if (rhs.match_expr_) {
         match_expr_.reset(new Expression());
-        *match_expr_ = *(rhs.match_expr_);
+        *match_expr_ = *rhs.match_expr_;
     }
 
     if (rhs.cfg_option_def_) {
@@ -215,7 +214,7 @@ ClientClassDef::equals(const ClientClassDef& other) const {
     return ((name_ == other.name_) &&
         ((!match_expr_ && !other.match_expr_) ||
         (match_expr_ && other.match_expr_ &&
-         (*match_expr_ == *(other.match_expr_)))) &&
+         (*match_expr_ == *other.match_expr_))) &&
         ((!cfg_option_ && !other.cfg_option_) ||
         (cfg_option_ && other.cfg_option_ &&
          (*cfg_option_ == *other.cfg_option_))) &&
@@ -330,7 +329,7 @@ ClientClassDictionary::ClientClassDictionary()
 
 ClientClassDictionary::ClientClassDictionary(const ClientClassDictionary& rhs)
     : map_(new ClientClassDefMap()), list_(new ClientClassDefList()) {
-    BOOST_FOREACH(ClientClassDefPtr cclass, *(rhs.list_)) {
+    for (auto const& cclass : *rhs.list_) {
         ClientClassDefPtr copy(new ClientClassDef(*cclass));
         addClass(copy);
     }
@@ -444,15 +443,14 @@ ClientClassDictionary::dependOnClass(const std::string& name,
                                      std::string& dependent_class) const {
     // Skip previous classes as they should not depend on name.
     bool found = false;
-    for (ClientClassDefList::iterator this_class = list_->begin();
-         this_class != list_->end(); ++this_class) {
+    for (auto const& this_class : *list_) {
         if (found) {
-            if ((*this_class)->dependOnClass(name)) {
-                dependent_class = (*this_class)->getName();
+            if (this_class->dependOnClass(name)) {
+                dependent_class = this_class->getName();
                 return (true);
             }
         } else {
-            if ((*this_class)->getName() == name) {
+            if (this_class->getName() == name) {
                 found = true;
             }
         }
@@ -552,9 +550,8 @@ ElementPtr
 ClientClassDictionary::toElement() const {
     ElementPtr result = Element::createList();
     // Iterate on the map
-    for (ClientClassDefList::const_iterator this_class = list_->begin();
-         this_class != list_->cend(); ++this_class) {
-        result->add((*this_class)->toElement());
+    for (auto const& this_class : *list_) {
+        result->add(this_class->toElement());
     }
     return (result);
 }
@@ -564,7 +561,7 @@ ClientClassDictionary::operator=(const ClientClassDictionary& rhs) {
     if (this != &rhs) {
         list_->clear();
         map_->clear();
-        for (auto const& cclass : *(rhs.list_)) {
+        for (auto const& cclass : *rhs.list_) {
             ClientClassDefPtr copy(new ClientClassDef(*cclass));
             addClass(copy);
         }
@@ -597,20 +594,18 @@ builtinPrefixes = {
 
 bool
 isClientClassBuiltIn(const ClientClass& client_class) {
-    for (std::list<std::string>::const_iterator bn = builtinNames.cbegin();
-         bn != builtinNames.cend(); ++bn) {
-        if (client_class == *bn) {
+    for (auto const& bn : builtinNames) {
+        if (client_class == bn) {
             return true;
         }
     }
 
-    for (std::list<std::string>::const_iterator bt = builtinPrefixes.cbegin();
-         bt != builtinPrefixes.cend(); ++bt) {
-        if (client_class.size() <= bt->size()) {
+    for (auto const& bt : builtinPrefixes) {
+        if (client_class.size() <= bt.size()) {
             continue;
         }
-        auto mis = std::mismatch(bt->cbegin(), bt->cend(), client_class.cbegin());
-        if (mis.first == bt->cend()) {
+        auto mis = std::mismatch(bt.cbegin(), bt.cend(), client_class.cbegin());
+        if (mis.first == bt.cend()) {
             return true;
         }
     }
index 7b282c5c521812cdc6cdd736f60a00f1bdd6ba25..f2a67be94d5898f26a3845641fd6c7f74e948a21 100644 (file)
@@ -499,12 +499,15 @@ D2ClientMgr::adjustDomainName(const T& fqdn, T& fqdn_resp, const DdnsParams& ddn
             std::vector<std::string> labels;
             boost::algorithm::split(labels, raw_name, boost::is_any_of("."));
             std::stringstream ss;
-            for (auto label = labels.begin(); label != labels.end(); ++label ) {
-                if (label != labels.begin()) {
+            bool first = true;
+            for (auto const& label : labels) {
+                if (!first) {
                     ss << ".";
+                } else {
+                    first = false;
                 }
 
-                ss << sanitizer->scrub(*label);
+                ss << sanitizer->scrub(label);
             }
 
             client_name = ss.str();
index 4cfe046856610c85027ff59671c61da280ea13dd..c0b882fdf60ce05dd06f192ad2dca3ff8ad2766d 100644 (file)
@@ -142,9 +142,8 @@ Pkt6Ptr Dhcp4o6IpcBase::receive() {
 
     // Get all vendor option and look for the one with the ISC enterprise id.
     OptionCollection vendor_options = pkt->getOptions(D6O_VENDOR_OPTS);
-    for (OptionCollection::const_iterator opt = vendor_options.begin();
-         opt != vendor_options.end(); ++opt) {
-        option_vendor = boost::dynamic_pointer_cast<OptionVendor>(opt->second);
+    for (auto const& opt : vendor_options) {
+        option_vendor = boost::dynamic_pointer_cast<OptionVendor>(opt.second);
         if (option_vendor) {
             if (option_vendor->getVendorId() == ENTERPRISE_ID_ISC) {
                 break;
@@ -244,9 +243,8 @@ void Dhcp4o6IpcBase::send(const Pkt6Ptr& pkt) {
 
     // Get all vendor option and look for the one with the ISC enterprise id.
     OptionCollection vendor_options = pkt->getOptions(D6O_VENDOR_OPTS);
-    for (OptionCollection::const_iterator opt = vendor_options.begin();
-         opt != vendor_options.end(); ++opt) {
-        option_vendor = boost::dynamic_pointer_cast<OptionVendor>(opt->second);
+    for (auto const& opt : vendor_options) {
+        option_vendor = boost::dynamic_pointer_cast<OptionVendor>(opt.second);
         if (option_vendor) {
             if (option_vendor->getVendorId() == ENTERPRISE_ID_ISC) {
                 break;
index 30ac4766a55396e62193e93ac836a2672ee0bc7a..5c6de5b7c093c9a79baedfec700ab0e9cb5dd047 100644 (file)
@@ -16,6 +16,7 @@
 #include <util/encode/hex.h>
 #include <util/strutil.h>
 
+#include <boost/foreach.hpp>
 #include <sstream>
 
 using namespace isc::data;
@@ -448,9 +449,8 @@ bool
 Host::hasReservation(const IPv6Resrv& reservation) const {
     IPv6ResrvRange reservations = getIPv6Reservations(reservation.getType());
     if (std::distance(reservations.first, reservations.second) > 0) {
-        for (IPv6ResrvIterator it = reservations.first;
-             it != reservations.second; ++it) {
-            if (it->second == reservation) {
+        BOOST_FOREACH(auto const& it, reservations) {
+            if (it.second == reservation) {
                 return (true);
             }
         }
@@ -561,9 +561,8 @@ Host::toElement4() const {
     // Set client-classes
     const ClientClasses& cclasses = getClientClasses4();
     ElementPtr classes = Element::createList();
-    for (ClientClasses::const_iterator cclass = cclasses.cbegin();
-         cclass != cclasses.cend(); ++cclass) {
-        classes->add(Element::create(*cclass));
+    for (auto const& cclass : cclasses) {
+        classes->add(Element::create(cclass));
     }
     map->set("client-classes", classes);
     // Set option-data
@@ -599,19 +598,17 @@ Host::toElement6() const {
         isc_throw(ToElementError, "invalid DUID type: " << id_type);
     }
     // Set reservations (ip-addresses)
-    IPv6ResrvRange na_resv = getIPv6Reservations(IPv6Resrv::TYPE_NA);
+    const IPv6ResrvRange& na_resv = getIPv6Reservations(IPv6Resrv::TYPE_NA);
     ElementPtr resvs = Element::createList();
-    for (IPv6ResrvIterator resv = na_resv.first;
-         resv != na_resv.second; ++resv) {
-        resvs->add(Element::create(resv->second.toText()));
+    BOOST_FOREACH(auto const& resv, na_resv) {
+        resvs->add(Element::create(resv.second.toText()));
     }
     map->set("ip-addresses", resvs);
     // Set reservations (prefixes)
-    IPv6ResrvRange pd_resv = getIPv6Reservations(IPv6Resrv::TYPE_PD);
+    const IPv6ResrvRange& pd_resv = getIPv6Reservations(IPv6Resrv::TYPE_PD);
     resvs = Element::createList();
-    for (IPv6ResrvIterator resv = pd_resv.first;
-         resv != pd_resv.second; ++resv) {
-        resvs->add(Element::create(resv->second.toText()));
+    BOOST_FOREACH(auto const& resv, pd_resv) {
+        resvs->add(Element::create(resv.second.toText()));
     }
     map->set("prefixes", resvs);
     // Set the hostname
@@ -620,9 +617,8 @@ Host::toElement6() const {
     // Set client-classes
     const ClientClasses& cclasses = getClientClasses6();
     ElementPtr classes = Element::createList();
-    for (ClientClasses::const_iterator cclass = cclasses.cbegin();
-         cclass != cclasses.cend(); ++cclass) {
-        classes->add(Element::create(*cclass));
+    for (auto const& cclass : cclasses) {
+        classes->add(Element::create(cclass));
     }
     map->set("client-classes", classes);
 
@@ -683,33 +679,35 @@ Host::toText() const {
 
     s << " key=" << (key_.toText().empty() ? "(empty)" : key_.toText());
 
+    size_t count = 0;
+
     if (ipv6_reservations_.empty()) {
         s << " ipv6_reservations=(none)";
 
     } else {
         // Add all IPv6 reservations.
-        for (IPv6ResrvIterator resrv = ipv6_reservations_.begin();
-             resrv != ipv6_reservations_.end(); ++resrv) {
+        count = 0;
+        for (auto const& resrv : ipv6_reservations_) {
             s << " ipv6_reservation"
-              << std::distance(ipv6_reservations_.begin(), resrv)
-              << "=" << resrv->second.toText();
+              << count++
+              << "=" << resrv.second.toText();
         }
     }
 
     // Add DHCPv4 client classes.
-    for (ClientClasses::const_iterator cclass = dhcp4_client_classes_.cbegin();
-         cclass != dhcp4_client_classes_.cend(); ++cclass) {
+    count = 0;
+    for (auto const& cclass : dhcp4_client_classes_) {
         s << " dhcp4_class"
-          << std::distance(dhcp4_client_classes_.cbegin(), cclass)
-          << "=" << *cclass;
+          << count++
+          << "=" << cclass;
     }
 
     // Add DHCPv6 client classes.
-    for (ClientClasses::const_iterator cclass = dhcp6_client_classes_.cbegin();
-         cclass != dhcp6_client_classes_.cend(); ++cclass) {
+    count = 0;
+    for (auto const& cclass : dhcp6_client_classes_) {
         s << " dhcp6_class"
-          << std::distance(dhcp6_client_classes_.cbegin(), cclass)
-          << "=" << *cclass;
+          << count++
+          << "=" << cclass;
     }
 
     // Add negative cached.
index 374df12c3bb4f7d9364776a8fdf8d18558709ac9..8ef36ef0e2b066fcdbb8ebcfd3fcd9abccc86ffe 100644 (file)
@@ -20,7 +20,6 @@
 #endif
 
 #include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
 
 #include <algorithm>
 #include <iostream>
index 47997a968da58a860a05143dd8b97b159d12643f..397cea7dd13e8a172bb0f97988cf884deadb8385 100644 (file)
@@ -751,7 +751,7 @@ HostMgr::getAll6(const IOAddress& address, const HostMgrOperationTarget target)
     }
 
     if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) {
-        for (auto const&source : alternate_sources_) {
+        for (auto const& source : alternate_sources_) {
             ConstHostCollection hosts_plus = source->getAll6(address);
             hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
         }
index b4f724a5e70a18207f0174798d4fbff365295ce2..d5663fda32d0a73637d9151aa2e49b29ca273e3b 100644 (file)
@@ -223,11 +223,9 @@ public:
         lease_file.open();
 
         // Iterate over the storage area writing out the leases
-        for (typename StorageType::const_iterator lease = storage.begin();
-             lease != storage.end();
-             ++lease) {
+        for (auto const& lease : storage) {
             try {
-                lease_file.append(**lease);
+                lease_file.append(*lease);
             } catch (const isc::Exception&) {
                 // Close the file
                 lease_file.close();
index f56a749de4b8fada5e8560b876d956722fe9fbbc..36bb07d944ce87694d06c7537e7855f9b3ede51b 100644 (file)
@@ -15,7 +15,6 @@
 #include <stats/stats_mgr.h>
 #include <util/encode/hex.h>
 
-#include <boost/foreach.hpp>
 #include <boost/algorithm/string.hpp>
 
 #include <algorithm>
@@ -106,9 +105,8 @@ LeaseMgr::recountLeaseStats4() {
     const Subnet4Collection* subnets =
         CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll();
 
-    for (Subnet4Collection::const_iterator subnet = subnets->begin();
-         subnet != subnets->end(); ++subnet) {
-        SubnetID subnet_id = (*subnet)->getID();
+    for (auto const& subnet : *subnets) {
+        SubnetID subnet_id = subnet->getID();
         stats_mgr.setValue(StatsMgr::generateName("subnet", subnet_id,
                                                   "assigned-addresses"),
                            zero);
@@ -129,7 +127,7 @@ LeaseMgr::recountLeaseStats4() {
             stats_mgr.setValue(name_rec, zero);
         }
 
-        for (auto const& pool : (*subnet)->getPools(Lease::TYPE_V4)) {
+        for (auto const& pool : subnet->getPools(Lease::TYPE_V4)) {
             const std::string name_aa(StatsMgr::generateName("subnet", subnet_id,
                                                              StatsMgr::generateName("pool", pool->getID(),
                                                                                     "assigned-addresses")));
@@ -320,9 +318,8 @@ LeaseMgr::recountLeaseStats6() {
     const Subnet6Collection* subnets =
         CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll();
 
-    for (Subnet6Collection::const_iterator subnet = subnets->begin();
-         subnet != subnets->end(); ++subnet) {
-        SubnetID subnet_id = (*subnet)->getID();
+    for (auto const& subnet : *subnets) {
+        SubnetID subnet_id = subnet->getID();
         stats_mgr.setValue(StatsMgr::generateName("subnet", subnet_id,
                                                   "assigned-nas"),
                            zero);
@@ -353,7 +350,7 @@ LeaseMgr::recountLeaseStats6() {
                 zero);
         }
 
-        for (auto const& pool : (*subnet)->getPools(Lease::TYPE_NA)) {
+        for (auto const& pool : subnet->getPools(Lease::TYPE_NA)) {
             const std::string& name_anas(StatsMgr::generateName("subnet", subnet_id,
                                                                 StatsMgr::generateName("pool", pool->getID(),
                                                                                        "assigned-nas")));
@@ -383,7 +380,7 @@ LeaseMgr::recountLeaseStats6() {
             }
         }
 
-        for (auto const& pool : (*subnet)->getPools(Lease::TYPE_PD)) {
+        for (auto const& pool : subnet->getPools(Lease::TYPE_PD)) {
             const std::string& name_apds(StatsMgr::generateName("subnet", subnet_id,
                                                                 StatsMgr::generateName("pd-pool", pool->getID(),
                                                                                        "assigned-pds")));
index e633916d895a2527a67310a2f9a4846b0820506b..9b71cc1d5b7cbfddde0b0f0723ba4bbb816f5ee9 100644 (file)
@@ -17,7 +17,6 @@
 #endif
 
 #include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
 
 #include <algorithm>
 #include <iostream>
index df812f144ad1ca4160b663c87555f9aa16082441..b94fa0dc7d804b1fa9099f8bc14f7f2b1cf9da82 100644 (file)
@@ -20,6 +20,7 @@
 #include <util/multi_threading_mgr.h>
 #include <util/pid_file.h>
 
+#include <boost/foreach.hpp>
 #include <cstdio>
 #include <cstring>
 #include <errno.h>
@@ -1168,8 +1169,8 @@ Memfile_LeaseMgr::getLease4Internal(const HWAddr& hwaddr,
               Lease4StorageHWAddressSubnetIdIndex::const_iterator> l
         = idx.equal_range(boost::make_tuple(hwaddr.hwaddr_));
 
-    for (auto lease = l.first; lease != l.second; ++lease) {
-        collection.push_back(Lease4Ptr(new Lease4(**lease)));
+    BOOST_FOREACH(auto const& lease, l) {
+        collection.push_back(Lease4Ptr(new Lease4(*lease)));
     }
 }
 
@@ -1233,8 +1234,8 @@ Memfile_LeaseMgr::getLease4Internal(const ClientId& client_id,
               Lease4StorageClientIdSubnetIdIndex::const_iterator> l
         = idx.equal_range(boost::make_tuple(client_id.getClientId()));
 
-    for (auto lease = l.first; lease != l.second; ++lease) {
-        collection.push_back(Lease4Ptr(new Lease4(**lease)));
+    BOOST_FOREACH(auto const& lease, l) {
+        collection.push_back(Lease4Ptr(new Lease4(*lease)));
     }
 }
 
@@ -1294,8 +1295,8 @@ Memfile_LeaseMgr::getLeases4Internal(SubnetID subnet_id,
               Lease4StorageSubnetIdIndex::const_iterator> l =
         idx.equal_range(subnet_id);
 
-    for (auto lease = l.first; lease != l.second; ++lease) {
-        collection.push_back(Lease4Ptr(new Lease4(**lease)));
+    BOOST_FOREACH(auto const& lease, l) {
+        collection.push_back(Lease4Ptr(new Lease4(*lease)));
     }
 }
 
@@ -1323,8 +1324,8 @@ Memfile_LeaseMgr::getLeases4Internal(const std::string& hostname,
               Lease4StorageHostnameIndex::const_iterator> l =
         idx.equal_range(hostname);
 
-    for (auto lease = l.first; lease != l.second; ++lease) {
-        collection.push_back(Lease4Ptr(new Lease4(**lease)));
+    BOOST_FOREACH(auto const& lease, l) {
+        collection.push_back(Lease4Ptr(new Lease4(*lease)));
     }
 }
 
@@ -1346,8 +1347,8 @@ Memfile_LeaseMgr::getLeases4(const std::string& hostname) const {
 
 void
 Memfile_LeaseMgr::getLeases4Internal(Lease4Collection& collection) const {
-   for (auto lease = storage4_.begin(); lease != storage4_.end(); ++lease) {
-       collection.push_back(Lease4Ptr(new Lease4(**lease)));
+   for (auto const& lease : storage4_) {
+       collection.push_back(Lease4Ptr(new Lease4(*lease)));
    }
 }
 
@@ -1540,8 +1541,8 @@ Memfile_LeaseMgr::getLeases6Internal(SubnetID subnet_id,
               Lease6StorageSubnetIdIndex::const_iterator> l =
         idx.equal_range(subnet_id);
 
-    for (auto lease = l.first; lease != l.second; ++lease) {
-        collection.push_back(Lease6Ptr(new Lease6(**lease)));
+    BOOST_FOREACH(auto const& lease, l) {
+        collection.push_back(Lease6Ptr(new Lease6(*lease)));
     }
 }
 
@@ -1569,8 +1570,8 @@ Memfile_LeaseMgr::getLeases6Internal(const std::string& hostname,
               Lease6StorageHostnameIndex::const_iterator> l =
         idx.equal_range(hostname);
 
-    for (auto lease = l.first; lease != l.second; ++lease) {
-        collection.push_back(Lease6Ptr(new Lease6(**lease)));
+    BOOST_FOREACH(auto const& lease, l) {
+        collection.push_back(Lease6Ptr(new Lease6(*lease)));
     }
 }
 
@@ -1592,8 +1593,8 @@ Memfile_LeaseMgr::getLeases6(const std::string& hostname) const {
 
 void
 Memfile_LeaseMgr::getLeases6Internal(Lease6Collection& collection) const {
-   for (auto lease = storage6_.begin(); lease != storage6_.end(); ++lease) {
-       collection.push_back(Lease6Ptr(new Lease6(**lease)));
+   for (auto const& lease : storage6_) {
+       collection.push_back(Lease6Ptr(new Lease6(*lease)));
    }
 }
 
@@ -1620,8 +1621,8 @@ Memfile_LeaseMgr::getLeases6Internal(const DUID& duid,
               Lease6StorageDuidIndex::const_iterator> l =
         idx.equal_range(duid.getDuid());
 
-    for (auto lease = l.first; lease != l.second; ++lease) {
-        collection.push_back(Lease6Ptr(new Lease6(**lease)));
+    BOOST_FOREACH(auto const& lease, l) {
+        collection.push_back(Lease6Ptr(new Lease6(*lease)));
     }
 }
 
@@ -2589,13 +2590,13 @@ Memfile_LeaseMgr::wipeLeases4(const SubnetID& subnet_id) {
 
     // Let's collect all leases.
     Lease4Collection leases;
-    for (auto lease = l.first; lease != l.second; ++lease) {
-        leases.push_back(*lease);
+    BOOST_FOREACH(auto const& lease, l) {
+        leases.push_back(lease);
     }
 
     size_t num = leases.size();
-    for (auto l = leases.begin(); l != leases.end(); ++l) {
-        deleteLease(*l);
+    for (auto const& l : leases) {
+        deleteLease(l);
     }
     LOG_INFO(dhcpsrv_logger, DHCPSRV_MEMFILE_WIPE_LEASES4_FINISHED)
         .arg(subnet_id).arg(num);
@@ -2618,13 +2619,13 @@ Memfile_LeaseMgr::wipeLeases6(const SubnetID& subnet_id) {
 
     // Let's collect all leases.
     Lease6Collection leases;
-    for (auto lease = l.first; lease != l.second; ++lease) {
-        leases.push_back(*lease);
+    BOOST_FOREACH(auto const& lease, l) {
+        leases.push_back(lease);
     }
 
     size_t num = leases.size();
-    for (auto l = leases.begin(); l != leases.end(); ++l) {
-        deleteLease(*l);
+    for (auto const& l : leases) {
+        deleteLease(l);
     }
     LOG_INFO(dhcpsrv_logger, DHCPSRV_MEMFILE_WIPE_LEASES6_FINISHED)
         .arg(subnet_id).arg(num);
@@ -2635,10 +2636,10 @@ Memfile_LeaseMgr::wipeLeases6(const SubnetID& subnet_id) {
 void
 Memfile_LeaseMgr::recountClassLeases4() {
     class_lease_counter_.clear();
-    for (auto lease = storage4_.begin(); lease != storage4_.end(); ++lease) {
+    for (auto const& lease : storage4_) {
         // Bump the appropriate accumulator
-        if ((*lease)->state_ == Lease::STATE_DEFAULT) {
-            class_lease_counter_.addLease(*lease);
+        if (lease->state_ == Lease::STATE_DEFAULT) {
+            class_lease_counter_.addLease(lease);
         }
     }
 }
@@ -2646,10 +2647,10 @@ Memfile_LeaseMgr::recountClassLeases4() {
 void
 Memfile_LeaseMgr::recountClassLeases6() {
     class_lease_counter_.clear();
-    for (auto lease = storage6_.begin(); lease != storage6_.end(); ++lease) {
+    for (auto const& lease : storage6_) {
         // Bump the appropriate accumulator
-        if ((*lease)->state_ == Lease::STATE_DEFAULT) {
-            class_lease_counter_.addLease(*lease);
+        if (lease->state_ == Lease::STATE_DEFAULT) {
+            class_lease_counter_.addLease(lease);
         }
     }
 }
@@ -2899,13 +2900,12 @@ idToText(const OptionBuffer& id) {
     std::stringstream tmp;
     tmp << std::hex;
     bool delim = false;
-    for (std::vector<uint8_t>::const_iterator it = id.begin();
-         it != id.end(); ++it) {
+    for (auto const& it : id) {
         if (delim) {
             tmp << ":";
         }
         tmp << std::setw(2) << std::setfill('0')
-            << static_cast<unsigned int>(*it);
+            << static_cast<unsigned int>(it);
         delim = true;
     }
     return (tmp.str());
@@ -3058,21 +3058,21 @@ Memfile_LeaseMgr::getLeases4ByRemoteIdInternal(const OptionBuffer& remote_id,
     const Lease4StorageRemoteIdIndex& idx = storage4_.get<RemoteIdIndexTag>();
     Lease4StorageRemoteIdRange er = idx.equal_range(remote_id);
     // Store all convenient leases being within the page size.
-    for (auto it = er.first; it != er.second; ++it) {
-        const IOAddress& addr = (*it)->addr_;
+    BOOST_FOREACH(auto const& it, er) {
+        const IOAddress& addr = it->addr_;
         if (addr <= lower_bound_address) {
             // Not greater than lower_bound_address.
             continue;
         }
-        if ((qry_start_time > 0) && ((*it)->cltt_ < qry_start_time)) {
+        if ((qry_start_time > 0) && (it->cltt_ < qry_start_time)) {
             // Too old.
             continue;
         }
-        if ((qry_end_time > 0) && ((*it)->cltt_ > qry_end_time)) {
+        if ((qry_end_time > 0) && (it->cltt_ > qry_end_time)) {
             // Too young.
             continue;
         }
-        sorted[addr] = *it;
+        sorted[addr] = it;
     }
 
     // Return all leases being within the page size.
@@ -3207,8 +3207,8 @@ Memfile_LeaseMgr::getLeases6ByRemoteIdInternal(const OptionBuffer& remote_id,
     const RemoteIdIndex& idx = remote_id6_.get<RemoteIdIndexTag>();
     RemoteIdIndexRange er = idx.equal_range(remote_id);
     // Store all addresses greater than lower_bound_address.
-    for (auto it = er.first; it != er.second; ++it) {
-        const IOAddress& addr = (*it)->lease_addr_;
+    BOOST_FOREACH(auto const& it, er) {
+        const IOAddress& addr = it->lease_addr_;
         if (addr <= lower_bound_address) {
             continue;
         }
index 8a84817b597c2bf6f09ed0bd92d0416a4f8465b3..5b76e1645e4cf651398bbe9100268388553361a1 100644 (file)
@@ -26,6 +26,7 @@
 #include <boost/algorithm/string/split.hpp>
 #include <boost/algorithm/string/classification.hpp>
 #include <boost/array.hpp>
+#include <boost/foreach.hpp>
 #include <boost/pointer_cast.hpp>
 #include <boost/static_assert.hpp>
 
@@ -3140,11 +3141,11 @@ MySqlHostDataSourceImpl::addOptions(MySqlHostContextPtr& ctx,
 
     // For each option space retrieve all options and insert them into the
     // database.
-    for (auto space = option_spaces.begin(); space != option_spaces.end(); ++space) {
-        OptionContainerPtr options = options_cfg->getAllCombined(*space);
+    for (auto const& space : option_spaces) {
+        OptionContainerPtr options = options_cfg->getAllCombined(space);
         if (options && !options->empty()) {
-            for (auto opt = options->begin(); opt != options->end(); ++opt) {
-                addOption(ctx, stindex, *opt, *space, Optional<SubnetID>(), host_id);
+            for (auto const& opt : *options) {
+                addOption(ctx, stindex, opt, space, Optional<SubnetID>(), host_id);
             }
         }
     }
@@ -3336,9 +3337,8 @@ MySqlHostDataSource::add(const HostPtr& host) {
     // Insert IPv6 reservations.
     IPv6ResrvRange v6resv = host->getIPv6Reservations();
     if (std::distance(v6resv.first, v6resv.second) > 0) {
-        for (IPv6ResrvIterator resv = v6resv.first; resv != v6resv.second;
-             ++resv) {
-            impl_->addResv(ctx, resv->second, host_id);
+        BOOST_FOREACH(auto const& resv, v6resv) {
+            impl_->addResv(ctx, resv.second, host_id);
         }
     }
 
index 1b71d52c573bd372773e2924922c3ffd75eea257..270ea8468ba7266cb8893585682d6608c0941877 100644 (file)
@@ -4077,13 +4077,12 @@ idToText(const OptionBuffer& id) {
     std::stringstream tmp;
     tmp << std::hex;
     bool delim = false;
-    for (std::vector<uint8_t>::const_iterator it = id.begin();
-         it != id.end(); ++it) {
+    for (auto const& it : id) {
         if (delim) {
             tmp << ":";
         }
         tmp << std::setw(2) << std::setfill('0')
-            << static_cast<unsigned int>(*it);
+            << static_cast<unsigned int>(it);
         delim = true;
     }
     return (tmp.str());
index 14770d5658eb7e3cf7a448880297dd9c04f5c273..211caa035228eddee61b2ab10b4cf151b4ccb026 100644 (file)
@@ -128,8 +128,8 @@ Network::toElement() const {
     ElementPtr relay_map = Element::createMap();
     ElementPtr address_list = Element::createList();
     const IOAddressList addresses = getRelayAddresses();
-    for (auto address = addresses.begin(); address != addresses.end(); ++address) {
-        address_list->add(Element::create((*address).toText()));
+    for (auto const& address : addresses) {
+        address_list->add(Element::create(address.toText()));
     }
 
     relay_map->set("ip-addresses", address_list);
@@ -144,9 +144,8 @@ Network::toElement() const {
     const ClientClasses& classes = getRequiredClasses();
     if (!classes.empty()) {
         ElementPtr class_list = Element::createList();
-        for (ClientClasses::const_iterator it = classes.cbegin();
-             it != classes.cend(); ++it) {
-            class_list->add(Element::create(*it));
+        for (auto const& it : classes) {
+            class_list->add(Element::create(it));
         }
         map->set("require-client-classes", class_list);
     }
index 0d04293f059ba8050f7798535925cb55ce1e63fb..dc6a7aa938a5b4b710a4ea100aa9885a5798032c 100644 (file)
@@ -16,7 +16,6 @@
 #include <asiolink/io_address.h>
 #include <asiolink/io_error.h>
 
-#include <boost/foreach.hpp>
 #include <algorithm>
 #include <sstream>
 
@@ -131,7 +130,7 @@ ClientClassDefParser::parse(ClientClassDictionaryPtr& class_dictionary,
                 SimpleParser6::OPTION6_DEF_DEFAULTS);
 
         OptionDefParser parser(family);
-        BOOST_FOREACH(ConstElementPtr option_def, option_defs->listValue()) {
+        for (auto const& option_def : option_defs->listValue()) {
             OptionDefinitionPtr def = parser.parse(option_def);
 
             // Verify if the definition is for an option which is in a deferred
@@ -346,8 +345,7 @@ ClientClassDictionaryPtr
 ClientClassDefListParser::parse(ConstElementPtr client_class_def_list,
                                 uint16_t family, bool check_dependencies) {
     ClientClassDictionaryPtr dictionary(new ClientClassDictionary());
-    BOOST_FOREACH(ConstElementPtr client_class_def,
-                  client_class_def_list->listValue()) {
+    for (auto const& client_class_def : client_class_def_list->listValue()) {
         ClientClassDefParser parser;
         parser.parse(dictionary, client_class_def, family, true, check_dependencies);
     }
index c064227362684bd2819e83ec07f9e77bd5ca419a..e7fc071692b8fea339fea84e6e6c81a012c62e8f 100644 (file)
@@ -52,7 +52,7 @@ MACSourcesListConfigParser::parse(CfgMACSource& mac_sources, ConstElementPtr val
     // If user specified anything, we need to get rid of that default.
     mac_sources.clear();
 
-    BOOST_FOREACH(ConstElementPtr source_elem, value->listValue()) {
+    for (auto const& source_elem : value->listValue()) {
         std::string source_str = source_elem->stringValue();
         try {
             source = CfgMACSource::MACSourceFromText(source_str);
@@ -204,11 +204,11 @@ OptionDefParser::parse(ConstElementPtr option_def) {
     isc::util::str::tokens(record_types, ",");
     // Iterate over each token and add a record type into
     // option definition.
-    BOOST_FOREACH(std::string record_type, record_tokens) {
+    for (auto const& record_type : record_tokens) {
         try {
-            boost::trim(record_type);
-            if (!record_type.empty()) {
-                    def->addRecordField(record_type);
+            auto const trim_rec = boost::trim_copy(record_type);
+            if (!trim_rec.empty()) {
+                def->addRecordField(trim_rec);
             }
         } catch (const Exception& ex) {
             isc_throw(DhcpConfigError, "invalid record type values"
@@ -246,7 +246,7 @@ OptionDefListParser::parse(CfgOptionDefPtr storage, ConstElementPtr option_def_l
     }
 
     OptionDefParser parser(address_family_);
-    BOOST_FOREACH(ConstElementPtr option_def, option_def_list->listValue()) {
+    for (auto const& option_def : option_def_list->listValue()) {
         OptionDefinitionPtr def = parser.parse(option_def);
         try {
             storage->add(def);
@@ -304,7 +304,7 @@ RelayInfoParser::parse(const isc::dhcp::Network::RelayInfoPtr& relay_info,
                   "(" << getPosition("ip-addresses", relay_elem) << ")");
     }
 
-    BOOST_FOREACH(ConstElementPtr address_element, addresses->listValue()) {
+    for (auto const& address_element : addresses->listValue()) {
         addAddress("ip-addresses", address_element->stringValue(),
                    relay_elem, relay_info);
     }
@@ -505,22 +505,20 @@ PoolParser::parse(PoolStoragePtr pools,
     ConstElementPtr class_list = pool_structure->get("require-client-classes");
     if (class_list) {
         const std::vector<data::ElementPtr>& classes = class_list->listValue();
-        for (auto cclass = classes.cbegin();
-             cclass != classes.cend(); ++cclass) {
-            if (((*cclass)->getType() != Element::string) ||
-                (*cclass)->stringValue().empty()) {
+        for (auto const& cclass : classes) {
+            if ((cclass->getType() != Element::string) ||
+                 cclass->stringValue().empty()) {
                 isc_throw(DhcpConfigError, "invalid class name ("
-                          << (*cclass)->getPosition() << ")");
+                          << cclass->getPosition() << ")");
             }
-            pool->requireClientClass((*cclass)->stringValue());
+            pool->requireClientClass(cclass->stringValue());
         }
     }
 }
 
 boost::shared_ptr<OptionDataListParser>
 PoolParser::createOptionDataListParser(const uint16_t address_family) const {
-    auto parser = boost::make_shared<OptionDataListParser>(address_family);
-    return (parser);
+    return (boost::make_shared<OptionDataListParser>(address_family));
 }
 
 //****************************** Pool4Parser *************************
@@ -540,16 +538,15 @@ Pool4Parser::poolMaker (IOAddress &min, IOAddress &max, int32_t) {
 void
 Pools4ListParser::parse(PoolStoragePtr pools, ConstElementPtr pools_list,
                         bool encapsulate_options) {
-    BOOST_FOREACH(ConstElementPtr pool, pools_list->listValue()) {
-        auto parser = createPoolConfigParser();
+    for (auto const& pool : pools_list->listValue()) {
+        auto const& parser = createPoolConfigParser();
         parser->parse(pools, pool, AF_INET, encapsulate_options);
     }
 }
 
 boost::shared_ptr<PoolParser>
 Pools4ListParser::createPoolConfigParser() const {
-    auto parser = boost::make_shared<Pool4Parser>();
-    return (parser);
+    return (boost::make_shared<Pool4Parser>());
 }
 
 //****************************** SubnetConfigParser *************************
@@ -682,8 +679,7 @@ SubnetConfigParser::createSubnet(ConstElementPtr params) {
 
 boost::shared_ptr<OptionDataListParser>
 SubnetConfigParser::createOptionDataListParser() const {
-    auto parser = boost::make_shared<OptionDataListParser>(address_family_);
-    return (parser);
+    return (boost::make_shared<OptionDataListParser>(address_family_));
 }
 
 //****************************** Subnet4ConfigParser *************************
@@ -700,7 +696,7 @@ Subnet4ConfigParser::parse(ConstElementPtr subnet, bool encapsulate_options) {
     /// Parse Pools first.
     ConstElementPtr pools = subnet->get("pools");
     if (pools) {
-        auto parser = createPoolsListParser();
+        auto const& parser = createPoolsListParser();
         parser->parse(pools_, pools, encapsulate_options);
     }
 
@@ -731,9 +727,9 @@ Subnet4ConfigParser::parse(ConstElementPtr subnet, bool encapsulate_options) {
         HostCollection hosts;
         HostReservationsListParser<HostReservationParser4> parser;
         parser.parse(subnet_->getID(), reservations, hosts);
-        for (auto h = hosts.begin(); h != hosts.end(); ++h) {
-            validateResv(sn4ptr, *h);
-            CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(*h);
+        for (auto const& h : hosts) {
+            validateResv(sn4ptr, h);
+            CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(h);
         }
     }
 
@@ -890,14 +886,13 @@ Subnet4ConfigParser::initSubnet(data::ConstElementPtr params,
     ConstElementPtr class_list = params->get("require-client-classes");
     if (class_list) {
         const std::vector<data::ElementPtr>& classes = class_list->listValue();
-        for (auto cclass = classes.cbegin();
-             cclass != classes.cend(); ++cclass) {
-            if (((*cclass)->getType() != Element::string) ||
-                (*cclass)->stringValue().empty()) {
+        for (auto const& cclass : classes) {
+            if ((cclass->getType() != Element::string) ||
+                cclass->stringValue().empty()) {
                 isc_throw(DhcpConfigError, "invalid class name ("
-                          << (*cclass)->getPosition() << ")");
+                          << cclass->getPosition() << ")");
             }
-            subnet4->requireClientClass((*cclass)->stringValue());
+            subnet4->requireClientClass(cclass->stringValue());
         }
     }
 
@@ -985,8 +980,7 @@ Subnet4ConfigParser::validateResv(const Subnet4Ptr& subnet, ConstHostPtr host) {
 
 boost::shared_ptr<PoolsListParser>
 Subnet4ConfigParser::createPoolsListParser() const {
-    auto parser = boost::make_shared<Pools4ListParser>();
-    return (parser);
+    return (boost::make_shared<Pools4ListParser>());
 }
 
 //**************************** Subnets4ListConfigParser **********************
@@ -1000,9 +994,9 @@ Subnets4ListConfigParser::parse(SrvConfigPtr cfg,
                                 ConstElementPtr subnets_list,
                                 bool encapsulate_options) {
     size_t cnt = 0;
-    BOOST_FOREACH(ConstElementPtr subnet_json, subnets_list->listValue()) {
+    for (auto const& subnet_json : subnets_list->listValue()) {
 
-        auto parser = createSubnetConfigParser();
+        auto const& parser = createSubnetConfigParser();
         Subnet4Ptr subnet = parser->parse(subnet_json, encapsulate_options);
         if (subnet) {
 
@@ -1026,9 +1020,9 @@ Subnets4ListConfigParser::parse(Subnet4Collection& subnets,
                                 data::ConstElementPtr subnets_list,
                                 bool encapsulate_options) {
     size_t cnt = 0;
-    BOOST_FOREACH(ConstElementPtr subnet_json, subnets_list->listValue()) {
+    for (auto const& subnet_json : subnets_list->listValue()) {
 
-        auto parser = createSubnetConfigParser();
+        auto const& parser = createSubnetConfigParser();
         Subnet4Ptr subnet = parser->parse(subnet_json, encapsulate_options);
         if (subnet) {
             try {
@@ -1049,8 +1043,7 @@ Subnets4ListConfigParser::parse(Subnet4Collection& subnets,
 
 boost::shared_ptr<Subnet4ConfigParser>
 Subnets4ListConfigParser::createSubnetConfigParser() const {
-    auto parser = boost::make_shared<Subnet4ConfigParser>(check_iface_);
-    return (parser);
+    return (boost::make_shared<Subnet4ConfigParser>(check_iface_));
 }
 
 //**************************** Pool6Parser *********************************
@@ -1075,16 +1068,15 @@ Pool6Parser::poolMaker(IOAddress &min, IOAddress &max, int32_t ptype)
 void
 Pools6ListParser::parse(PoolStoragePtr pools, ConstElementPtr pools_list,
                         bool encapsulate_options) {
-    BOOST_FOREACH(ConstElementPtr pool, pools_list->listValue()) {
-        auto parser = createPoolConfigParser();
+    for (auto const& pool : pools_list->listValue()) {
+        auto const& parser = createPoolConfigParser();
         parser->parse(pools, pool, AF_INET6, encapsulate_options);
     }
 }
 
 boost::shared_ptr<PoolParser>
 Pools6ListParser::createPoolConfigParser() const {
-    auto parser = boost::make_shared<Pool6Parser>();
-    return (parser);
+    return (boost::make_shared<Pool6Parser>());
 }
 
 //**************************** PdPoolParser ******************************
@@ -1167,14 +1159,13 @@ PdPoolParser::parse(PoolStoragePtr pools, ConstElementPtr pd_pool_,
 
     if (class_list) {
         const std::vector<data::ElementPtr>& classes = class_list->listValue();
-        for (auto cclass = classes.cbegin();
-             cclass != classes.cend(); ++cclass) {
-            if (((*cclass)->getType() != Element::string) ||
-                (*cclass)->stringValue().empty()) {
+        for (auto const& cclass : classes) {
+            if ((cclass->getType() != Element::string) ||
+                cclass->stringValue().empty()) {
                 isc_throw(DhcpConfigError, "invalid class name ("
-                          << (*cclass)->getPosition() << ")");
+                          << cclass->getPosition() << ")");
             }
-            pool_->requireClientClass((*cclass)->stringValue());
+            pool_->requireClientClass(cclass->stringValue());
         }
     }
 
@@ -1184,8 +1175,7 @@ PdPoolParser::parse(PoolStoragePtr pools, ConstElementPtr pd_pool_,
 
 boost::shared_ptr<OptionDataListParser>
 PdPoolParser::createOptionDataListParser() const {
-    auto parser = boost::make_shared<OptionDataListParser>(AF_INET6);
-    return (parser);
+    return (boost::make_shared<OptionDataListParser>(AF_INET6));
 }
 
 //**************************** PdPoolsListParser ************************
@@ -1193,16 +1183,15 @@ PdPoolParser::createOptionDataListParser() const {
 void
 PdPoolsListParser::parse(PoolStoragePtr pools, ConstElementPtr pd_pool_list) {
     // Loop through the list of pd pools.
-    BOOST_FOREACH(ConstElementPtr pd_pool, pd_pool_list->listValue()) {
-        auto parser = createPdPoolConfigParser();
+    for (auto const& pd_pool : pd_pool_list->listValue()) {
+        auto const& parser = createPdPoolConfigParser();
         parser->parse(pools, pd_pool);
     }
 }
 
 boost::shared_ptr<PdPoolParser>
 PdPoolsListParser::createPdPoolConfigParser() const {
-    auto parser = boost::make_shared<PdPoolParser>();
-    return (parser);
+    return (boost::make_shared<PdPoolParser>());
 }
 
 //**************************** Subnet6ConfigParser ***********************
@@ -1219,12 +1208,12 @@ Subnet6ConfigParser::parse(ConstElementPtr subnet, bool encapsulate_options) {
     /// Parse all pools first.
     ConstElementPtr pools = subnet->get("pools");
     if (pools) {
-        auto parser = createPoolsListParser();
+        auto const& parser = createPoolsListParser();
         parser->parse(pools_, pools, encapsulate_options);
     }
     ConstElementPtr pd_pools = subnet->get("pd-pools");
     if (pd_pools) {
-        auto parser = createPdPoolsListParser();
+        auto const& parser = createPdPoolsListParser();
         parser->parse(pools_, pd_pools);
     }
 
@@ -1255,9 +1244,9 @@ Subnet6ConfigParser::parse(ConstElementPtr subnet, bool encapsulate_options) {
         HostCollection hosts;
         HostReservationsListParser<HostReservationParser6> parser;
         parser.parse(subnet_->getID(), reservations, hosts);
-        for (auto h = hosts.begin(); h != hosts.end(); ++h) {
-            validateResvs(sn6ptr, *h);
-            CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(*h);
+        for (auto const& h : hosts) {
+            validateResvs(sn6ptr, h);
+            CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(h);
         }
     }
 
@@ -1417,14 +1406,13 @@ Subnet6ConfigParser::initSubnet(data::ConstElementPtr params,
         ConstElementPtr class_list = params->get("require-client-classes");
         if (class_list) {
             const std::vector<data::ElementPtr>& classes = class_list->listValue();
-            for (auto cclass = classes.cbegin();
-                 cclass != classes.cend(); ++cclass) {
-                if (((*cclass)->getType() != Element::string) ||
-                    (*cclass)->stringValue().empty()) {
+            for (auto const& cclass : classes) {
+                if ((cclass->getType() != Element::string) ||
+                    cclass->stringValue().empty()) {
                     isc_throw(DhcpConfigError, "invalid class name ("
-                              << (*cclass)->getPosition() << ")");
+                              << cclass->getPosition() << ")");
                 }
-                subnet6->requireClientClass((*cclass)->stringValue());
+                subnet6->requireClientClass(cclass->stringValue());
             }
         }
     }
@@ -1444,9 +1432,9 @@ Subnet6ConfigParser::initSubnet(data::ConstElementPtr params,
 
 void
 Subnet6ConfigParser::validateResvs(const Subnet6Ptr& subnet, ConstHostPtr host) {
-    IPv6ResrvRange range = host->getIPv6Reservations(IPv6Resrv::TYPE_NA);
-    for (auto it = range.first; it != range.second; ++it) {
-        const IOAddress& address = it->second.getPrefix();
+    const IPv6ResrvRange& range = host->getIPv6Reservations(IPv6Resrv::TYPE_NA);
+    BOOST_FOREACH(auto const& it, range) {
+        const IOAddress& address = it.second.getPrefix();
         if (!subnet->inRange(address)) {
             isc_throw(DhcpConfigError, "specified reservation '" << address
                       << "' is not within the IPv6 subnet '"
@@ -1457,14 +1445,12 @@ Subnet6ConfigParser::validateResvs(const Subnet6Ptr& subnet, ConstHostPtr host)
 
 boost::shared_ptr<PoolsListParser>
 Subnet6ConfigParser::createPoolsListParser() const {
-    auto parser = boost::make_shared<Pools6ListParser>();
-    return (parser);
+    return (boost::make_shared<Pools6ListParser>());
 }
 
 boost::shared_ptr<PdPoolsListParser>
 Subnet6ConfigParser::createPdPoolsListParser() const {
-    auto parser = boost::make_shared<PdPoolsListParser>();
-    return (parser);
+    return (boost::make_shared<PdPoolsListParser>());
 }
 
 //**************************** Subnet6ListConfigParser ********************
@@ -1478,9 +1464,9 @@ Subnets6ListConfigParser::parse(SrvConfigPtr cfg,
                                 ConstElementPtr subnets_list,
                                 bool encapsulate_options) {
     size_t cnt = 0;
-    BOOST_FOREACH(ConstElementPtr subnet_json, subnets_list->listValue()) {
+    for (auto const& subnet_json : subnets_list->listValue()) {
 
-        auto parser = createSubnetConfigParser();
+        auto const& parser = createSubnetConfigParser();
         Subnet6Ptr subnet = parser->parse(subnet_json, encapsulate_options);
 
         // Adding a subnet to the Configuration Manager may fail if the
@@ -1502,9 +1488,9 @@ Subnets6ListConfigParser::parse(Subnet6Collection& subnets,
                                 ConstElementPtr subnets_list,
                                 bool encapsulate_options) {
     size_t cnt = 0;
-    BOOST_FOREACH(ConstElementPtr subnet_json, subnets_list->listValue()) {
+    for (auto const& subnet_json : subnets_list->listValue()) {
 
-        auto parser = createSubnetConfigParser();
+        auto const& parser = createSubnetConfigParser();
         Subnet6Ptr subnet = parser->parse(subnet_json, encapsulate_options);
         if (subnet) {
             try {
@@ -1525,8 +1511,7 @@ Subnets6ListConfigParser::parse(Subnet6Collection& subnets,
 
 boost::shared_ptr<Subnet6ConfigParser>
 Subnets6ListConfigParser::createSubnetConfigParser() const {
-    auto parser = boost::make_shared<Subnet6ConfigParser>(check_iface_);
-    return (parser);
+    return (boost::make_shared<Subnet6ConfigParser>(check_iface_));
 }
 
 //**************************** D2ClientConfigParser **********************
index e3bca0fff22631d1db57a358734821950005041c..e9b4e1bd5b31f72e1a228f6164a688dd1dbf7218 100644 (file)
@@ -10,7 +10,6 @@
 #include <dhcpsrv/dhcpsrv_log.h>
 #include <dhcpsrv/parsers/dhcp_queue_control_parser.h>
 #include <util/multi_threading_mgr.h>
-#include <boost/foreach.hpp>
 #include <string>
 #include <sys/types.h>
 
index 937a542c0d35e2b9fbb89c9b55d2a223794e951a..7082e049019e6c2bbb2d3d7941346ced3f53abdc 100644 (file)
@@ -13,7 +13,6 @@
 #include <dhcpsrv/parsers/duid_config_parser.h>
 #include <dhcpsrv/parsers/dhcp_parsers.h>
 #include <exceptions/exceptions.h>
-#include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
 
 #include <string>
index 3bbe33386063680d38092c30b86df5903a9a9357..52d9740e86c3419bf88fddb5cb37bb98c58d8563 100644 (file)
@@ -11,7 +11,6 @@
 #include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/parsers/expiration_config_parser.h>
 #include <dhcpsrv/parsers/dhcp_parsers.h>
-#include <boost/foreach.hpp>
 
 using namespace isc::data;
 
index ed89b3b5f287424d1fded38c7b58d6799cdfd762..f71fe9c9d23f810a874ddc5c4966e94fac8b2a34 100644 (file)
@@ -10,7 +10,6 @@
 #include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/parsers/host_reservation_parser.h>
 #include <dhcpsrv/parsers/option_data_parser.h>
-#include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
 #include <algorithm>
 #include <sys/socket.h>
@@ -119,7 +118,7 @@ HostReservationParser::parseInternal(const SubnetID&,
     try {
         // Gather those parameters that are common for both IPv4 and IPv6
         // reservations.
-        BOOST_FOREACH(auto const& element, reservation_data->mapValue()) {
+        for (auto const& element : reservation_data->mapValue()) {
             // Check if we support this parameter.
             if (!isSupportedParameter(element.first)) {
                 isc_throw(DhcpConfigError, "unsupported configuration"
@@ -148,7 +147,7 @@ HostReservationParser::parseInternal(const SubnetID&,
             // error message and include the information what identifiers
             // are supported.
             std::ostringstream s;
-            BOOST_FOREACH(std::string param_name, getSupportedParameters(true)) {
+            for (auto const& param_name : getSupportedParameters(true)) {
                 if (s.tellp() != std::streampos(0)) {
                     s << ", ";
                 }
@@ -196,7 +195,7 @@ HostReservationParser4::parseInternal(const SubnetID& subnet_id,
 
     host->setIPv4SubnetID(subnet_id);
 
-    BOOST_FOREACH(auto const& element, reservation_data->mapValue()) {
+    for (auto const& element : reservation_data->mapValue()) {
         // For 'option-data' element we will use another parser which
         // already returns errors with position appended, so don't
         // surround it with try-catch.
@@ -209,8 +208,8 @@ HostReservationParser4::parseInternal(const SubnetID& subnet_id,
             OptionDataListParser parser(AF_INET);
             parser.parse(cfg_option, element.second, encapsulate_options);
 
-       // Everything else should be surrounded with try-catch to append
-       // position.
+        // Everything else should be surrounded with try-catch to append
+        // position.
         } else {
             try {
                 if (element.first == "ip-address") {
@@ -226,8 +225,7 @@ HostReservationParser4::parseInternal(const SubnetID& subnet_id,
                     host->setBootFileName(element.second->stringValue());
 
                 } else if (element.first == "client-classes") {
-                    BOOST_FOREACH(ConstElementPtr class_element,
-                                  element.second->listValue()) {
+                    for (auto const& class_element : element.second->listValue()) {
                         host->addClientClass4(class_element->stringValue());
                     }
                 }
@@ -257,7 +255,7 @@ HostReservationParser6::parseInternal(const SubnetID& subnet_id,
 
     host->setIPv6SubnetID(subnet_id);
 
-    BOOST_FOREACH(auto const& element, reservation_data->mapValue()) {
+    for (auto const& element : reservation_data->mapValue()) {
         // Parse option values. Note that the configuration option parser
         // returns errors with position information appended, so there is no
         // need to surround it with try-clause (and rethrow with position
@@ -272,8 +270,7 @@ HostReservationParser6::parseInternal(const SubnetID& subnet_id,
             parser.parse(cfg_option, element.second, encapsulate_options);
 
         } else if (element.first == "ip-addresses" || element.first == "prefixes") {
-            BOOST_FOREACH(ConstElementPtr prefix_element,
-                          element.second->listValue()) {
+            for (auto const& prefix_element : element.second->listValue()) {
                 try {
                     // For the IPv6 address the prefix length is 128 and the
                     // value specified in the list is a reserved address.
@@ -351,8 +348,7 @@ HostReservationParser6::parseInternal(const SubnetID& subnet_id,
 
         } else if (element.first == "client-classes") {
             try {
-                BOOST_FOREACH(ConstElementPtr class_element,
-                              element.second->listValue()) {
+                for (auto const& class_element : element.second->listValue()) {
                     host->addClientClass6(class_element->stringValue());
                 }
             } catch (const std::exception& ex) {
@@ -385,7 +381,7 @@ HostReservationIdsParser::parseInternal(isc::data::ConstElementPtr ids_list) {
     // Remove existing identifier types.
     staging_cfg_->clearIdentifierTypes();
 
-    BOOST_FOREACH(ConstElementPtr element, ids_list->listValue()) {
+    for (auto const& element : ids_list->listValue()) {
         std::string id_name = element->stringValue();
         try {
             if (id_name != "auto") {
index 9f6ce2f68f6cd4ce3a8b01da39d0219c7f9a06c8..fd857055e19c4635f3aee75c27eef1cfb83a776c 100644 (file)
@@ -11,7 +11,6 @@
 #include <cc/simple_parser.h>
 #include <dhcpsrv/host.h>
 #include <dhcpsrv/subnet_id.h>
-#include <boost/foreach.hpp>
 
 namespace isc {
 namespace dhcp {
@@ -39,7 +38,7 @@ public:
     void parse(const SubnetID& subnet_id, isc::data::ConstElementPtr hr_list,
                HostCollection& hosts_list) {
         HostCollection hosts;
-        BOOST_FOREACH(data::ConstElementPtr reservation, hr_list->listValue()) {
+        for (auto const& reservation : hr_list->listValue()) {
             HostReservationParserType parser;
             hosts.push_back(parser.parse(subnet_id, reservation));
         }
index c375b403c2cf22d2839278679267107986d03c91..fee4484a65bf45ab83fd9fc22bc9bb4eb59db19c 100644 (file)
@@ -9,7 +9,6 @@
 #include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/dhcpsrv_log.h>
 #include <dhcpsrv/parsers/ifaces_config_parser.h>
-#include <boost/foreach.hpp>
 #include <string>
 #include <sys/types.h>
 
@@ -21,7 +20,7 @@ namespace dhcp {
 void
 IfacesConfigParser::parseInterfacesList(const CfgIfacePtr& cfg_iface,
                                         ConstElementPtr ifaces_list) {
-    BOOST_FOREACH(ConstElementPtr iface, ifaces_list->listValue()) {
+    for (auto const& iface : ifaces_list->listValue()) {
         std::string iface_name = iface->stringValue();
         try {
             cfg_iface->use(protocol_, iface_name);
@@ -50,7 +49,7 @@ IfacesConfigParser::parse(const CfgIfacePtr& cfg,
     }
 
     bool socket_type_specified = false;
-    BOOST_FOREACH(ConfigPair element, ifaces_config->mapValue()) {
+    for (auto const& element : ifaces_config->mapValue()) {
         try {
             if (element.first == "re-detect") {
                 continue;
index 6a321cde6daba9d0dfe6dce9c7edb9b9cddb4bcd..87d98d92b1905180ee227d6804acbba52c0a5786 100644 (file)
@@ -17,7 +17,6 @@
 #include <dhcpsrv/parsers/simple_parser6.h>
 #include <util/encode/hex.h>
 #include <util/strutil.h>
-#include <boost/foreach.hpp>
 #include <boost/make_shared.hpp>
 #include <limits>
 #include <vector>
@@ -458,7 +457,7 @@ void OptionDataListParser::parse(const CfgOptionPtr& cfg,
                                  isc::data::ConstElementPtr option_data_list,
                                  bool encapsulate) {
     auto option_parser = createOptionDataParser();
-    BOOST_FOREACH(ConstElementPtr data, option_data_list->listValue()) {
+    for (auto const& data : option_data_list->listValue()) {
         std::pair<OptionDescriptor, std::string> option =
             option_parser->parse(data);
         // Use the option description to keep the formatted value
index ef9cc1dc008a72951ea996d0a809cfab4254eeed..ed196f4bfa2d4c0aa5038d48f6382e059ada817a 100644 (file)
@@ -88,9 +88,8 @@ SharedNetwork4Parser::parse(const data::ConstElementPtr& shared_network_data,
             parser->parse(subnets, json);
 
             // Add all returned subnets into shared network.
-            for (auto subnet = subnets.cbegin(); subnet != subnets.cend();
-                 ++subnet) {
-                shared_network->add(*subnet);
+            for (auto const& subnet : subnets) {
+                shared_network->add(subnet);
             }
         }
 
@@ -170,14 +169,13 @@ SharedNetwork4Parser::parse(const data::ConstElementPtr& shared_network_data,
         if (shared_network_data->contains("require-client-classes")) {
             const std::vector<data::ElementPtr>& class_list =
                 shared_network_data->get("require-client-classes")->listValue();
-            for (auto cclass = class_list.cbegin();
-                 cclass != class_list.cend(); ++cclass) {
-                if (((*cclass)->getType() != Element::string) ||
-                    (*cclass)->stringValue().empty()) {
+            for (auto const& cclass : class_list) {
+                if ((cclass->getType() != Element::string) ||
+                    cclass->stringValue().empty()) {
                     isc_throw(DhcpConfigError, "invalid class name ("
-                              << (*cclass)->getPosition() << ")");
+                              << cclass->getPosition() << ")");
                 }
-                shared_network->requireClientClass((*cclass)->stringValue());
+                shared_network->requireClientClass(cclass->stringValue());
             }
         }
 
@@ -344,14 +342,13 @@ SharedNetwork6Parser::parse(const data::ConstElementPtr& shared_network_data,
         if (shared_network_data->contains("require-client-classes")) {
             const std::vector<data::ElementPtr>& class_list =
                 shared_network_data->get("require-client-classes")->listValue();
-            for (auto cclass = class_list.cbegin();
-                 cclass != class_list.cend(); ++cclass) {
-                if (((*cclass)->getType() != Element::string) ||
-                    (*cclass)->stringValue().empty()) {
+            for (auto const& cclass : class_list) {
+                if ((cclass->getType() != Element::string) ||
+                    cclass->stringValue().empty()) {
                     isc_throw(DhcpConfigError, "invalid class name ("
-                              << (*cclass)->getPosition() << ")");
+                              << cclass->getPosition() << ")");
                 }
-                shared_network->requireClientClass((*cclass)->stringValue());
+                shared_network->requireClientClass(cclass->stringValue());
             }
         }
 
@@ -364,9 +361,8 @@ SharedNetwork6Parser::parse(const data::ConstElementPtr& shared_network_data,
             parser->parse(subnets, json);
 
             // Add all returned subnets into shared network.
-            for (auto subnet = subnets.cbegin(); subnet != subnets.cend();
-                 ++subnet) {
-                shared_network->add(*subnet);
+            for (auto const& subnet : subnets) {
+                shared_network->add(subnet);
             }
         }
 
index 5f49c8b09723ad7546bd2975f4afd3b21707a9e7..3705ad224c20bcea38c0e72ee3c426884faac516 100644 (file)
@@ -57,10 +57,9 @@ public:
             const std::vector<data::ElementPtr>& networks_list =
                 shared_networks_list_data->listValue();
             // Iterate over all networks and do the parsing.
-            for (auto network_element = networks_list.cbegin();
-                 network_element != networks_list.cend(); ++network_element) {
+            for (auto const& network_element : networks_list) {
                 SharedNetworkParserType parser(check_iface_);
-                auto network = parser.parse(*network_element);
+                auto network = parser.parse(network_element);
                 cfg->add(network);
             }
         } catch (const DhcpConfigError&) {
index ce16628fbd03132c11e972eef6a334aab3c894be..a7b12ead293a756418b293e56fd67dff97f364f5 100644 (file)
@@ -8,7 +8,6 @@
 
 #include <dhcpsrv/parsers/simple_parser4.h>
 #include <cc/data.h>
-#include <boost/foreach.hpp>
 #include <iostream>
 
 using namespace isc::data;
@@ -428,7 +427,7 @@ size_t SimpleParser4::setAllDefaults(ElementPtr global) {
     // Now set option definition defaults for each specified option definition
     ConstElementPtr option_defs = global->get("option-def");
     if (option_defs) {
-        BOOST_FOREACH(ElementPtr option_def, option_defs->listValue()) {
+        for (auto const& option_def : option_defs->listValue()) {
             cnt += SimpleParser::setDefaults(option_def, OPTION4_DEF_DEFAULTS);
         }
     }
@@ -455,7 +454,7 @@ size_t SimpleParser4::setAllDefaults(ElementPtr global) {
     // Set defaults for shared networks
     ConstElementPtr shared = global->get("shared-networks");
     if (shared) {
-        BOOST_FOREACH(ElementPtr net, shared->listValue()) {
+        for (auto const& net : shared->listValue()) {
 
             cnt += setDefaults(net, SHARED_NETWORK4_DEFAULTS);
 
@@ -512,7 +511,7 @@ size_t SimpleParser4::deriveParameters(ElementPtr global) {
     // Now derive global parameters into subnets.
     ConstElementPtr subnets = global->get("subnet4");
     if (subnets) {
-        BOOST_FOREACH(ElementPtr single_subnet, subnets->listValue()) {
+        for (auto const& single_subnet : subnets->listValue()) {
             cnt += SimpleParser::deriveParams(global, single_subnet,
                                               INHERIT_TO_SUBNET4);
         }
@@ -523,7 +522,7 @@ size_t SimpleParser4::deriveParameters(ElementPtr global) {
     // subnets within derive from it.
     ConstElementPtr shared = global->get("shared-networks");
     if (shared) {
-        BOOST_FOREACH(ElementPtr net, shared->listValue()) {
+        for (auto const& net : shared->listValue()) {
             // First try to inherit the parameters from shared network,
             // if defined there.
             // Then try to inherit them from global.
@@ -533,7 +532,7 @@ size_t SimpleParser4::deriveParameters(ElementPtr global) {
             // Now we need to go thrugh all the subnets in this net.
             subnets = net->get("subnet4");
             if (subnets) {
-                BOOST_FOREACH(ElementPtr single_subnet, subnets->listValue()) {
+                for (auto const& single_subnet : subnets->listValue()) {
                     cnt += SimpleParser::deriveParams(net, single_subnet,
                                                       INHERIT_TO_SUBNET4);
                 }
index accde74d335aa6ef78956d8a01b94bc347b42582..2c9c98f50f6cf7cf39ce86320be0565b9f950a6c 100644 (file)
@@ -9,8 +9,6 @@
 #include <cc/data.h>
 #include <dhcpsrv/parsers/simple_parser6.h>
 
-#include <boost/foreach.hpp>
-
 using namespace isc::data;
 
 namespace isc {
@@ -442,7 +440,7 @@ size_t SimpleParser6::setAllDefaults(ElementPtr global) {
     // Now set the defaults for each specified option definition
     ConstElementPtr option_defs = global->get("option-def");
     if (option_defs) {
-        BOOST_FOREACH(ElementPtr option_def, option_defs->listValue()) {
+        for (auto const& option_def : option_defs->listValue()) {
             cnt += SimpleParser::setDefaults(option_def, OPTION6_DEF_DEFAULTS);
         }
     }
@@ -450,7 +448,7 @@ size_t SimpleParser6::setAllDefaults(ElementPtr global) {
     // Set the defaults for option data
     ConstElementPtr options = global->get("option-data");
     if (options) {
-        BOOST_FOREACH(ElementPtr single_option, options->listValue()) {
+        for (auto const& single_option : options->listValue()) {
             cnt += SimpleParser::setDefaults(single_option, OPTION6_DEFAULTS);
         }
     }
@@ -471,7 +469,7 @@ size_t SimpleParser6::setAllDefaults(ElementPtr global) {
     // Set defaults for shared networks
     ConstElementPtr shared = global->get("shared-networks");
     if (shared) {
-        BOOST_FOREACH(ElementPtr net, shared->listValue()) {
+        for (auto const& net : shared->listValue()) {
 
             cnt += setDefaults(net, SHARED_NETWORK6_DEFAULTS);
 
@@ -528,7 +526,7 @@ size_t SimpleParser6::deriveParameters(ElementPtr global) {
     // Now derive global parameters into subnets.
     ConstElementPtr subnets = global->get("subnet6");
     if (subnets) {
-        BOOST_FOREACH(ElementPtr single_subnet, subnets->listValue()) {
+        for (auto const& single_subnet : subnets->listValue()) {
             cnt += SimpleParser::deriveParams(global, single_subnet,
                                               INHERIT_TO_SUBNET6);
         }
@@ -539,7 +537,7 @@ size_t SimpleParser6::deriveParameters(ElementPtr global) {
     // subnets within derive from it.
     ConstElementPtr shared = global->get("shared-networks");
     if (shared) {
-        BOOST_FOREACH(ElementPtr net, shared->listValue()) {
+        for (auto const& net : shared->listValue()) {
             // First try to inherit the parameters from shared network,
             // if defined there.
             // Then try to inherit them from global.
@@ -549,7 +547,7 @@ size_t SimpleParser6::deriveParameters(ElementPtr global) {
             // Now we need to go thrugh all the subnets in this net.
             subnets = net->get("subnet6");
             if (subnets) {
-                BOOST_FOREACH(ElementPtr single_subnet, subnets->listValue()) {
+                for (auto const& single_subnet : subnets->listValue()) {
                     cnt += SimpleParser::deriveParams(net, single_subnet,
                                                       INHERIT_TO_SUBNET6);
                 }
index 6a88942bdc5011c6548c2064b493d39e075be9f5..ffe2461f1f0239e1f4ec4284cd054a5fde43efed 100644 (file)
@@ -26,6 +26,7 @@
 #include <boost/algorithm/string/split.hpp>
 #include <boost/algorithm/string/classification.hpp>
 #include <boost/array.hpp>
+#include <boost/foreach.hpp>
 #include <boost/pointer_cast.hpp>
 #include <boost/static_assert.hpp>
 
@@ -2556,11 +2557,11 @@ PgSqlHostDataSourceImpl::addOptions(PgSqlHostContextPtr& ctx,
 
     // For each option space retrieve all options and insert them into the
     // database.
-    for (auto space = option_spaces.begin(); space != option_spaces.end(); ++space) {
-        OptionContainerPtr options = options_cfg->getAllCombined(*space);
+    for (auto const& space : option_spaces) {
+        OptionContainerPtr options = options_cfg->getAllCombined(space);
         if (options && !options->empty()) {
-            for (auto opt = options->begin(); opt != options->end(); ++opt) {
-                addOption(ctx, stindex, *opt, *space, Optional<SubnetID>(), host_id);
+            for (auto const& opt : *options) {
+                addOption(ctx, stindex, opt, space, Optional<SubnetID>(), host_id);
             }
         }
     }
@@ -2709,9 +2710,8 @@ PgSqlHostDataSource::add(const HostPtr& host) {
     // Insert IPv6 reservations.
     IPv6ResrvRange v6resv = host->getIPv6Reservations();
     if (std::distance(v6resv.first, v6resv.second) > 0) {
-        for (IPv6ResrvIterator resv = v6resv.first; resv != v6resv.second;
-             ++resv) {
-            impl_->addResv(ctx, resv->second, host_id);
+        BOOST_FOREACH(auto const& resv, v6resv) {
+            impl_->addResv(ctx, resv.second, host_id);
         }
     }
 
index 01718d9b5b305758f35d590a34acf53e699ea8b8..c32d9738e65dc5b66085d82ddbafceecaf7b1958 100644 (file)
@@ -3205,13 +3205,12 @@ idToText(const OptionBuffer& id) {
     std::stringstream tmp;
     tmp << std::hex;
     bool delim = false;
-    for (std::vector<uint8_t>::const_iterator it = id.begin();
-         it != id.end(); ++it) {
+    for (auto const& it : id) {
         if (delim) {
             tmp << ":";
         }
         tmp << std::setw(2) << std::setfill('0')
-            << static_cast<unsigned int>(*it);
+            << static_cast<unsigned int>(it);
         delim = true;
     }
     return (tmp.str());
index 2a47333a34c79085675078206876903f23778ce3..876038ae17ad7e628140545c965d7fee44030350 100644 (file)
@@ -125,9 +125,8 @@ Pool::toElement() const {
     const ClientClasses& classes = getRequiredClasses();
     if (!classes.empty()) {
         ElementPtr class_list = Element::createList();
-        for (ClientClasses::const_iterator it = classes.cbegin();
-             it != classes.cend(); ++it) {
-            class_list->add(Element::create(*it));
+        for (auto const& it : classes) {
+            class_list->add(Element::create(it));
         }
         map->set("require-client-classes", class_list);
     }
index 1580b18d1f2ade6f7158c00fb64a1005370d20de..f7a72e13825b9289a0ddf19636eeff39c441913a 100644 (file)
@@ -303,15 +303,15 @@ public:
                                             const Lease::Type& lease_type) {
 
         auto preferred_subnet = selected_subnet;
-        for (auto s = subnets.begin(); s != subnets.end(); ++s) {
+        for (auto const& s : subnets) {
             // It doesn't make sense to check the subnet against itself.
-            if (preferred_subnet == (*s)) {
+            if (preferred_subnet == s) {
                 continue;
             }
-            if ((*s)->getClientClass().get() != selected_subnet->getClientClass().get()) {
+            if (s->getClientClass().get() != selected_subnet->getClientClass().get()) {
                 continue;
             }
-            auto current_subnet_state = (*s)->getAllocationState(lease_type);
+            auto current_subnet_state = s->getAllocationState(lease_type);
             if (!current_subnet_state) {
                 continue;
             }
@@ -324,7 +324,7 @@ public:
             // instance.
             if (current_subnet_state->getLastAllocatedTime() >
                 preferred_subnet_state->getLastAllocatedTime()) {
-                preferred_subnet = (*s);
+                preferred_subnet = s;
             }
         }
         return (preferred_subnet);
@@ -378,9 +378,9 @@ SharedNetwork4::del(const SubnetID& subnet_id) {
 
 void
 SharedNetwork4::delAll() {
-    for (auto subnet = subnets_.cbegin(); subnet != subnets_.cend(); ++subnet) {
-        (*subnet)->setSharedNetwork(NetworkPtr());
-        (*subnet)->setSharedNetworkName("");
+    for (auto const& subnet : subnets_) {
+        subnet->setSharedNetwork(NetworkPtr());
+        subnet->setSharedNetworkName("");
     }
     subnets_.clear();
 }
@@ -429,8 +429,8 @@ SharedNetwork4::toElement() const {
     }
 
     ElementPtr subnet4 = Element::createList();
-    for (auto subnet = subnets_.cbegin(); subnet != subnets_.cend(); ++subnet) {
-        subnet4->add((*subnet)->toElement());
+    for (auto const& subnet : subnets_) {
+        subnet4->add(subnet->toElement());
     }
 
     map->set("subnet4", subnet4);
@@ -480,8 +480,8 @@ SharedNetwork6::del(const SubnetID& subnet_id) {
 
 void
 SharedNetwork6::delAll() {
-    for (auto subnet = subnets_.cbegin(); subnet != subnets_.cend(); ++subnet) {
-        (*subnet)->setSharedNetwork(NetworkPtr());
+    for (auto const& subnet : subnets_) {
+        subnet->setSharedNetwork(NetworkPtr());
     }
     subnets_.clear();
 }
@@ -518,8 +518,8 @@ SharedNetwork6::toElement() const {
     }
 
     ElementPtr subnet6 = Element::createList();
-    for (auto subnet = subnets_.cbegin(); subnet != subnets_.cend(); ++subnet) {
-        subnet6->add((*subnet)->toElement());
+    for (auto const& subnet : subnets_) {
+        subnet6->add(subnet->toElement());
     }
 
     map->set("subnet6", subnet6);
index a07f964fee6dc7f9029aa56759dc3b9728781986..ab6ee721689f699ed37e82dbd03a430e3699e29d 100644 (file)
@@ -134,9 +134,8 @@ SrvConfig::copy(SrvConfig& new_config) const {
     // Replace configured hooks libraries.
     new_config.hooks_config_.clear();
     using namespace isc::hooks;
-    for (HookLibsCollection::const_iterator it = hooks_config_.get().begin();
-         it != hooks_config_.get().end(); ++it) {
-        new_config.hooks_config_.add(it->first, it->second);
+    for (auto const& it : hooks_config_.get()) {
+        new_config.hooks_config_.add(it.first, it.second);
     }
 }
 
@@ -401,10 +400,10 @@ SrvConfig::extractConfiguredGlobals(isc::data::ConstElementPtr config) {
     }
 
     const std::map<std::string, ConstElementPtr>& values = config->mapValue();
-    for (auto value = values.begin(); value != values.end(); ++value) {
-        if (value->second->getType() != Element::list &&
-            value->second->getType() != Element::map) {
-                addConfiguredGlobal(value->first, value->second);
+    for (auto const& value : values) {
+        if (value.second->getType() != Element::list &&
+            value.second->getType() != Element::map) {
+                addConfiguredGlobal(value.first, value.second);
         }
     }
 }
@@ -688,15 +687,14 @@ SrvConfig::toElement() const {
         // Get plain subnets
         ElementPtr plain_subnets = Element::createList();
         const Subnet4Collection* subnets = cfg_subnets4_->getAll();
-        for (Subnet4Collection::const_iterator subnet = subnets->cbegin();
-             subnet != subnets->cend(); ++subnet) {
+        for (auto const& subnet : *subnets) {
             // Skip subnets which are in a shared-network
             SharedNetwork4Ptr network;
-            (*subnet)->getSharedNetwork(network);
+            subnet->getSharedNetwork(network);
             if (network) {
                 continue;
             }
-            ElementPtr subnet_cfg = (*subnet)->toElement();
+            ElementPtr subnet_cfg = subnet->toElement();
             sn_list.push_back(subnet_cfg);
             plain_subnets->add(subnet_cfg);
         }
@@ -708,13 +706,11 @@ SrvConfig::toElement() const {
 
         // Get subnets in shared network subnet lists
         const std::vector<ElementPtr> networks = shared_networks->listValue();
-        for (auto network = networks.cbegin();
-             network != networks.cend(); ++network) {
+        for (auto const& network : networks) {
             const std::vector<ElementPtr> sh_list =
-                (*network)->get("subnet4")->listValue();
-            for (auto subnet = sh_list.cbegin();
-                 subnet != sh_list.cend(); ++subnet) {
-                sn_list.push_back(*subnet);
+                network->get("subnet4")->listValue();
+            for (auto const& subnet : sh_list) {
+                sn_list.push_back(subnet);
             }
         }
 
@@ -722,15 +718,14 @@ SrvConfig::toElement() const {
         // Get plain subnets
         ElementPtr plain_subnets = Element::createList();
         const Subnet6Collection* subnets = cfg_subnets6_->getAll();
-        for (Subnet6Collection::const_iterator subnet = subnets->cbegin();
-             subnet != subnets->cend(); ++subnet) {
+        for (auto const& subnet : *subnets) {
             // Skip subnets which are in a shared-network
             SharedNetwork6Ptr network;
-            (*subnet)->getSharedNetwork(network);
+            subnet->getSharedNetwork(network);
             if (network) {
                 continue;
             }
-            ElementPtr subnet_cfg = (*subnet)->toElement();
+            ElementPtr subnet_cfg = subnet->toElement();
             sn_list.push_back(subnet_cfg);
             plain_subnets->add(subnet_cfg);
         }
@@ -742,13 +737,11 @@ SrvConfig::toElement() const {
 
         // Get subnets in shared network subnet lists
         const std::vector<ElementPtr> networks = shared_networks->listValue();
-        for (auto network = networks.cbegin();
-             network != networks.cend(); ++network) {
+        for (auto const& network : networks) {
             const std::vector<ElementPtr> sh_list =
-                (*network)->get("subnet6")->listValue();
-            for (auto subnet = sh_list.cbegin();
-                 subnet != sh_list.cend(); ++subnet) {
-                sn_list.push_back(*subnet);
+                network->get("subnet6")->listValue();
+            for (auto const& subnet : sh_list) {
+                sn_list.push_back(subnet);
             }
         }
     }
@@ -764,15 +757,14 @@ SrvConfig::toElement() const {
     }
 
     // Insert subnet reservations
-    for (std::vector<ElementPtr>::const_iterator subnet = sn_list.cbegin();
-         subnet != sn_list.cend(); ++subnet) {
-        ConstElementPtr id = (*subnet)->get("id");
+    for (auto const& subnet : sn_list) {
+        ConstElementPtr id = subnet->get("id");
         if (isNull(id)) {
             isc_throw(ToElementError, "subnet has no id");
         }
         SubnetID subnet_id = id->intValue();
         ConstElementPtr resvs = resv_list.get(subnet_id);
-        (*subnet)->set("reservations", resvs);
+        subnet->set("reservations", resvs);
     }
 
     // Set expired-leases-processing
index 0823bb34518fa8c888624aadb6781712d306db95..700d925d889bc5b55db6207d5ce3f7b8ffaa6f81 100644 (file)
@@ -277,18 +277,18 @@ AllocEngine6Test::allocateTest(AllocEngine& engine, const Pool6Ptr& pool,
     findReservation(engine, ctx);
     EXPECT_NO_THROW(leases = engine.allocateLeases6(ctx));
 
-    for (Lease6Collection::iterator it = leases.begin(); it != leases.end(); ++it) {
+    for (auto const& it : leases) {
 
         // Do all checks on the lease
-        checkLease6(duid_, *it, type, expected_len, in_pool, in_pool);
+        checkLease6(duid_, it, type, expected_len, in_pool, in_pool);
 
         // Check that context has been updated with allocated addresses or
         // prefixes.
-        checkAllocatedResources(*it, ctx);
+        checkAllocatedResources(it, ctx);
 
         // Check that the lease is indeed in LeaseMgr
         Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(type,
-                                                                   (*it)->addr_);
+                                                                   it->addr_);
         if (!fake) {
             // This is a real (REQUEST) allocation, the lease must be in the DB
             EXPECT_TRUE(from_mgr) << "Lease " << from_mgr->addr_.toText()
@@ -299,7 +299,7 @@ AllocEngine6Test::allocateTest(AllocEngine& engine, const Pool6Ptr& pool,
             }
 
             // Now check that the lease in LeaseMgr has the same parameters
-            detailCompareLease(*it, from_mgr);
+            detailCompareLease(it, from_mgr);
         } else {
             // This is a fake (SOLICIT) allocation, the lease must not be in DB
             EXPECT_FALSE(from_mgr) << "Lease " << from_mgr->addr_.toText()
@@ -459,18 +459,18 @@ AllocEngine6Test::renewTest(AllocEngine& engine, const Pool6Ptr& pool,
     findReservation(engine, ctx);
     Lease6Collection leases = engine.renewLeases6(ctx);
 
-    for (Lease6Collection::iterator it = leases.begin(); it != leases.end(); ++it) {
+    for (auto const& it : leases) {
 
         // Do all checks on the lease
-        checkLease6(duid_, *it, type, expected_len, in_subnet, in_pool);
+        checkLease6(duid_, it, type, expected_len, in_subnet, in_pool);
 
         // Check that context has been updated with allocated addresses or
         // prefixes.
-        checkAllocatedResources(*it, ctx);
+        checkAllocatedResources(it, ctx);
 
         // Check that the lease is indeed in LeaseMgr
         Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(type,
-                                                                   (*it)->addr_);
+                                                                   it->addr_);
 
         // This is a real (REQUEST) allocation, the lease must be in the DB
         EXPECT_TRUE(from_mgr) << "Lease " << from_mgr->addr_.toText()
@@ -481,7 +481,7 @@ AllocEngine6Test::renewTest(AllocEngine& engine, const Pool6Ptr& pool,
         }
 
         // Now check that the lease in LeaseMgr has the same parameters
-        detailCompareLease(*it, from_mgr);
+        detailCompareLease(it, from_mgr);
     }
 
     return (leases);
index 15b0c97f3f9e084441311225f14faebe44d03aef..2ceacdd85c8b5022cb1e59b4d51e2cc614383ae9 100644 (file)
@@ -23,6 +23,7 @@
 #include <hooks/callout_manager.h>
 #include <hooks/hooks_manager.h>
 #include <testutils/gtest_utils.h>
+#include <boost/foreach.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/make_shared.hpp>
 #include <gtest/gtest.h>
@@ -176,8 +177,8 @@ public:
         if (!audit_entries_.empty()) {
             auto const& index = audit_entries_.get<AuditEntryObjectTypeTag>();
             auto range = index.equal_range(object_type);
-            for (auto it = range.first; it != range.second; ++it) {
-                if (((*it)->getModificationType() != AuditEntry::ModificationType::DELETE)) {
+            BOOST_FOREACH(auto const& it, range) {
+                if (it->getModificationType() != AuditEntry::ModificationType::DELETE) {
                     return (true);
                 }
             }
@@ -198,8 +199,8 @@ public:
             auto const& index = audit_entries_.get<AuditEntryObjectTypeTag>();
             auto range = index.equal_range(boost::make_tuple(object_type,
                                                              AuditEntry::ModificationType::DELETE));
-            for (auto it = range.first; it != range.second; ++it) {
-                if ((*it)->getObjectId() == object_id) {
+            BOOST_FOREACH(auto const& it, range) {
+                if (it->getObjectId() == object_id) {
                     return (true);
                 }
             }
index 58c0d03a4f25b910e377dd8e797040943d2c772f..177339508a1487f6966a5b1558399bf3893c9b96 100644 (file)
@@ -475,9 +475,8 @@ TEST_F(CfgHostsTest, getAll4ByAddress) {
 
     HostCollection hosts = cfg.getAll4(IOAddress("192.0.2.10"));
     std::set<uint32_t> subnet_ids;
-    for (HostCollection::const_iterator host = hosts.begin(); host != hosts.end();
-         ++host) {
-        subnet_ids.insert((*host)->getIPv4SubnetID());
+    for (auto const& host : hosts) {
+        subnet_ids.insert(host->getIPv4SubnetID());
     }
     ASSERT_EQ(25, subnet_ids.size());
     EXPECT_EQ(1, *subnet_ids.begin());
@@ -726,9 +725,8 @@ TEST_F(CfgHostsTest, deleteAll4) {
     // Get all inserted hosts.
     HostCollection hosts = cfg.getAll4(IOAddress::IPV4_ZERO_ADDRESS());
     std::set<uint32_t> subnet_ids;
-    for (HostCollection::const_iterator host = hosts.begin(); host != hosts.end();
-         ++host) {
-        subnet_ids.insert((*host)->getIPv4SubnetID());
+    for (auto const& host : hosts) {
+        subnet_ids.insert(host->getIPv4SubnetID());
     }
     // Make sure there are two unique subnets: 1 and 2.
     ASSERT_EQ(2, subnet_ids.size());
@@ -741,9 +739,8 @@ TEST_F(CfgHostsTest, deleteAll4) {
     // Gather the host counts again.
     subnet_ids.clear();
     hosts = cfg.getAll4(IOAddress::IPV4_ZERO_ADDRESS());
-    for (HostCollection::const_iterator host = hosts.begin(); host != hosts.end();
-         ++host) {
-        subnet_ids.insert((*host)->getIPv4SubnetID());
+    for (auto const& host : hosts) {
+        subnet_ids.insert(host->getIPv4SubnetID());
     }
     // We should only have hosts for one subnet and it should be the subnet
     // with ID of 1.
index e79817317b15a9b15d2e7a4ef5ea4c45e730f0dd..9dc92341cbd337989f2a5ffdd881c4555083ade7 100644 (file)
@@ -94,11 +94,11 @@ TEST(CfgOptionDefTest, getAllThenDelete) {
     // valid codes. Also, their order should be the same as they
     // were added (codes 100-109).
     uint16_t code = 100;
-    for (OptionDefContainer::const_iterator it = option_defs1->begin();
-         it != option_defs1->end(); ++it, ++code) {
-        OptionDefinitionPtr def(*it);
+    for (auto const& it : *option_defs1) {
+        OptionDefinitionPtr def(it);
         ASSERT_TRUE(def);
         EXPECT_EQ(code, def->getCode());
+        ++code;
     }
 
     // Sanity check that all 10 option definitions are there.
@@ -108,11 +108,11 @@ TEST(CfgOptionDefTest, getAllThenDelete) {
 
     // Check that the option codes are valid.
     code = 105;
-    for (OptionDefContainer::const_iterator it = option_defs2->begin();
-         it != option_defs2->end(); ++it, ++code) {
-        OptionDefinitionPtr def(*it);
+    for (auto const& it : *option_defs2) {
+        OptionDefinitionPtr def(it);
         ASSERT_TRUE(def);
         EXPECT_EQ(code, def->getCode());
+        ++code;
     }
 
     // Let's make one more check that the empty set is returned when
index ab3c1de824eadb787ded9f3c7c0fc6e61c5dd973..55b0995c096c372c9334917f023d26907bd65edc 100644 (file)
@@ -17,7 +17,6 @@
 #include <dhcpsrv/cfg_option.h>
 #include <testutils/gtest_utils.h>
 #include <testutils/test_to_element.h>
-#include <boost/foreach.hpp>
 #include <boost/pointer_cast.hpp>
 #include <gtest/gtest.h>
 #include <iterator>
@@ -278,10 +277,9 @@ TEST_F(CfgOptionTest, add) {
 
     // Validate codes of options added to dhcp6 option space.
     uint16_t expected_code = 100;
-    for (OptionContainer::const_iterator option_desc = options->begin();
-         option_desc != options->end(); ++option_desc) {
-        ASSERT_TRUE(option_desc->option_);
-        EXPECT_EQ(expected_code, option_desc->option_->getType());
+    for (auto const& option_desc : *options) {
+        ASSERT_TRUE(option_desc.option_);
+        EXPECT_EQ(expected_code, option_desc.option_->getType());
         ++expected_code;
     }
 
@@ -292,10 +290,9 @@ TEST_F(CfgOptionTest, add) {
 
     // Validate codes of options added to isc option space.
     expected_code = 105;
-    for (OptionContainer::const_iterator option_desc = options->begin();
-         option_desc != options->end(); ++option_desc) {
-        ASSERT_TRUE(option_desc->option_);
-        EXPECT_EQ(expected_code, option_desc->option_->getType());
+    for (auto const& option_desc : *options) {
+        ASSERT_TRUE(option_desc.option_);
+        EXPECT_EQ(expected_code, option_desc.option_->getType());
         ++expected_code;
     }
 
@@ -720,8 +717,7 @@ TEST_F(CfgOptionTest, encapsulate) {
         ASSERT_EQ(19, first_level.size());
 
         // Iterate over all first level sub-options.
-        std::pair<unsigned int, OptionPtr> first_level_opt;
-        BOOST_FOREACH(first_level_opt, first_level) {
+        for (auto const& first_level_opt : first_level) {
             // Each option in this test comprises a single one byte field and
             // should cast to OptionUint8 type.
             OptionUint8Ptr first_level_uint8 = boost::dynamic_pointer_cast<
@@ -744,8 +740,7 @@ TEST_F(CfgOptionTest, encapsulate) {
 
             // Iterate over sub-options and make sure they include the expected
             // values.
-            std::pair<unsigned int, OptionPtr> second_level_opt;
-            BOOST_FOREACH(second_level_opt, second_level) {
+            for (auto const& second_level_opt : second_level) {
                 OptionUint8Ptr second_level_uint8 = boost::dynamic_pointer_cast<
                     OptionUint8>(second_level_opt.second);
                 ASSERT_TRUE(second_level_uint8);
@@ -1060,10 +1055,9 @@ TEST_F(CfgOptionTest, addNonUniqueOptions) {
         // have been returned for the particular code.
         ASSERT_EQ(2, distance(range.first, range.second));
         // Check that returned options actually have the expected option code.
-        for (OptionContainerTypeIndex::const_iterator option_desc = range.first;
-             option_desc != range.second; ++option_desc) {
-            ASSERT_TRUE(option_desc->option_);
-            EXPECT_EQ(code, option_desc->option_->getType());
+        BOOST_FOREACH(auto const& option_desc, range) {
+            ASSERT_TRUE(option_desc.option_);
+            EXPECT_EQ(code, option_desc.option_->getType());
         }
     }
 
@@ -1186,10 +1180,9 @@ TEST_F(CfgOptionTest, addVendorOptions) {
 
     // Validate codes of options added to dhcp6 option space.
     uint16_t expected_code = 100;
-    for (OptionContainer::const_iterator option_desc = options->begin();
-         option_desc != options->end(); ++option_desc) {
-        ASSERT_TRUE(option_desc->option_);
-        EXPECT_EQ(expected_code, option_desc->option_->getType());
+    for (auto const& option_desc : *options) {
+        ASSERT_TRUE(option_desc.option_);
+        EXPECT_EQ(expected_code, option_desc.option_->getType());
         ++expected_code;
     }
 
@@ -1199,10 +1192,9 @@ TEST_F(CfgOptionTest, addVendorOptions) {
 
     // Validate codes of options added to isc option space.
     expected_code = 105;
-    for (OptionContainer::const_iterator option_desc = options->begin();
-         option_desc != options->end(); ++option_desc) {
-        ASSERT_TRUE(option_desc->option_);
-        EXPECT_EQ(expected_code, option_desc->option_->getType());
+    for (auto const& option_desc : *options) {
+        ASSERT_TRUE(option_desc.option_);
+        EXPECT_EQ(expected_code, option_desc.option_->getType());
         ++expected_code;
     }
 
@@ -1236,13 +1228,12 @@ TEST_F(CfgOptionTest, getVendorIdsSpaceNames) {
     ASSERT_EQ(10, space_names.size());
 
     // Check that the option space names for those vendor ids are correct.
-    for (std::list<std::string>::iterator name = space_names.begin();
-         name != space_names.end(); ++name) {
-        uint16_t id = static_cast<uint16_t>(std::distance(space_names.begin(),
-                                                          name));
+    size_t id = 0;
+    for (auto const& name : space_names) {
         std::ostringstream s;
         s << "vendor-" << (100 + id);
-        EXPECT_EQ(s.str(), *name);
+        EXPECT_EQ(s.str(), name);
+        id++;
     }
 }
 
index d10fd8ee5e555623020f803aabdab3a8a0ad8f6a..dfe3ce4c1354ea9be0522022939debc148db3573 100644 (file)
@@ -31,6 +31,7 @@
 #include <testutils/test_to_element.h>
 #include <util/doubles.h>
 
+#include <boost/range/adaptor/reversed.hpp>
 #include <gtest/gtest.h>
 #include <vector>
 
@@ -122,29 +123,29 @@ TEST(CfgSubnets4Test, getSpecificSubnet) {
     subnets.push_back(subnet3);
 
     // Add all subnets to the configuration.
-    for (auto subnet = subnets.cbegin(); subnet != subnets.cend(); ++subnet) {
-        ASSERT_NO_THROW(cfg.add(*subnet)) << "failed to add subnet with id: "
-            << (*subnet)->getID();
+    for (auto const& subnet : subnets) {
+        ASSERT_NO_THROW(cfg.add(subnet)) << "failed to add subnet with id: "
+            << subnet->getID();
     }
 
     // Iterate over all subnets and make sure they can be retrieved by
     // subnet identifier.
-    for (auto subnet = subnets.rbegin(); subnet != subnets.rend(); ++subnet) {
-        ConstSubnet4Ptr subnet_returned = cfg.getBySubnetId((*subnet)->getID());
+    for (auto const& subnet : boost::adaptors::reverse(subnets)) {
+        ConstSubnet4Ptr subnet_returned = cfg.getBySubnetId(subnet->getID());
         ASSERT_TRUE(subnet_returned) << "failed to return subnet with id: "
-            << (*subnet)->getID();
-        EXPECT_EQ((*subnet)->getID(), subnet_returned->getID());
-        EXPECT_EQ((*subnet)->toText(), subnet_returned->toText());
+            << subnet->getID();
+        EXPECT_EQ(subnet->getID(), subnet_returned->getID());
+        EXPECT_EQ(subnet->toText(), subnet_returned->toText());
     }
 
     // Repeat the previous test, but this time retrieve subnets by their
     // prefixes.
-    for (auto subnet = subnets.rbegin(); subnet != subnets.rend(); ++subnet) {
-        ConstSubnet4Ptr subnet_returned = cfg.getByPrefix((*subnet)->toText());
+    for (auto const& subnet : boost::adaptors::reverse(subnets)) {
+        ConstSubnet4Ptr subnet_returned = cfg.getByPrefix(subnet->toText());
         ASSERT_TRUE(subnet_returned) << "failed to return subnet with id: "
-            << (*subnet)->getID();
-        EXPECT_EQ((*subnet)->getID(), subnet_returned->getID());
-        EXPECT_EQ((*subnet)->toText(), subnet_returned->toText());
+            << subnet->getID();
+        EXPECT_EQ(subnet->getID(), subnet_returned->getID());
+        EXPECT_EQ(subnet->toText(), subnet_returned->toText());
     }
 
     // Make sure that null pointers are returned for non-existing subnets.
@@ -1368,14 +1369,14 @@ TEST(CfgSubnets4Test, teeTimePercentValidation) {
 
     // Iterate over the test scenarios, verifying each prescribed
     // outcome.
-    for (auto test = tests.begin(); test != tests.end(); ++test) {
+    for (auto const& test : tests) {
         {
-            SCOPED_TRACE("test: " + (*test).label);
+            SCOPED_TRACE("test: " + test.label);
 
             // Set this scenario's configuration parameters
-            elems->set("calculate-tee-times", data::Element::create((*test).calculate_tee_times));
-            elems->set("t1-percent", data::Element::create((*test).t1_percent));
-            elems->set("t2-percent", data::Element::create((*test).t2_percent));
+            elems->set("calculate-tee-times", data::Element::create(test.calculate_tee_times));
+            elems->set("t1-percent", data::Element::create(test.t1_percent));
+            elems->set("t2-percent", data::Element::create(test.t2_percent));
 
             Subnet4Ptr subnet;
             try {
@@ -1383,9 +1384,9 @@ TEST(CfgSubnets4Test, teeTimePercentValidation) {
                 Subnet4ConfigParser parser;
                 subnet = parser.parse(elems);
             } catch (const std::exception& ex) {
-                if (!(*test).error_message.empty()) {
+                if (!test.error_message.empty()) {
                     // We expected a failure, did we fail the correct way?
-                    EXPECT_EQ((*test).error_message, ex.what());
+                    EXPECT_EQ(test.error_message, ex.what());
                 } else {
                     // Should not have failed.
                     ADD_FAILURE() << "Scenario should not have failed: " << ex.what();
@@ -1396,9 +1397,9 @@ TEST(CfgSubnets4Test, teeTimePercentValidation) {
             }
 
             // We parsed correctly, make sure the values are right.
-            EXPECT_EQ((*test).calculate_tee_times, subnet->getCalculateTeeTimes());
-            EXPECT_TRUE(util::areDoublesEquivalent((*test).t1_percent, subnet->getT1Percent()));
-            EXPECT_TRUE(util::areDoublesEquivalent((*test).t2_percent, subnet->getT2Percent()));
+            EXPECT_EQ(test.calculate_tee_times, subnet->getCalculateTeeTimes());
+            EXPECT_TRUE(util::areDoublesEquivalent(test.t1_percent, subnet->getT1Percent()));
+            EXPECT_TRUE(util::areDoublesEquivalent(test.t2_percent, subnet->getT2Percent()));
         }
     }
 }
@@ -1779,12 +1780,12 @@ TEST(CfgSubnets4Test, cacheParamValidation) {
 
     // Iterate over the test scenarios, verifying each prescribed
     // outcome.
-    for (auto test = tests.begin(); test != tests.end(); ++test) {
+    for (auto const& test : tests) {
         {
-            SCOPED_TRACE("test: " + (*test).label);
+            SCOPED_TRACE("test: " + test.label);
 
             // Set this scenario's configuration parameters
-            elems->set("cache-threshold", data::Element::create((*test).threshold));
+            elems->set("cache-threshold", data::Element::create(test.threshold));
 
             Subnet4Ptr subnet;
             try {
@@ -1792,9 +1793,9 @@ TEST(CfgSubnets4Test, cacheParamValidation) {
                 Subnet4ConfigParser parser;
                 subnet = parser.parse(elems);
             } catch (const std::exception& ex) {
-                if (!(*test).error_message.empty()) {
+                if (!test.error_message.empty()) {
                     // We expected a failure, did we fail the correct way?
-                    EXPECT_EQ((*test).error_message, ex.what());
+                    EXPECT_EQ(test.error_message, ex.what());
                 } else {
                     // Should not have failed.
                     ADD_FAILURE() << "Scenario should not have failed: " << ex.what();
@@ -1805,7 +1806,7 @@ TEST(CfgSubnets4Test, cacheParamValidation) {
             }
 
             // We parsed correctly, make sure the values are right.
-            EXPECT_TRUE(util::areDoublesEquivalent((*test).threshold, subnet->getCacheThreshold()));
+            EXPECT_TRUE(util::areDoublesEquivalent(test.threshold, subnet->getCacheThreshold()));
         }
     }
 }
index 20707fed8eaf1f8acbc2f2fe4330de1c676c0322..1959fb2cfac0fbb43f38cea4e0f31e7a2c4d21e6 100644 (file)
@@ -28,6 +28,7 @@
 #include <testutils/test_to_element.h>
 #include <util/doubles.h>
 
+#include <boost/range/adaptor/reversed.hpp>
 #include <gtest/gtest.h>
 #include <string>
 
@@ -129,29 +130,29 @@ TEST(CfgSubnets6Test, getSpecificSubnet) {
     subnets.push_back(subnet3);
 
     // Add all subnets to the configuration.
-    for (auto subnet = subnets.cbegin(); subnet != subnets.cend(); ++subnet) {
-        ASSERT_NO_THROW(cfg.add(*subnet)) << "failed to add subnet with id: "
-            << (*subnet)->getID();
+    for (auto const& subnet : subnets) {
+        ASSERT_NO_THROW(cfg.add(subnet)) << "failed to add subnet with id: "
+            << subnet->getID();
     }
 
     // Iterate over all subnets and make sure they can be retrieved by
     // subnet identifier.
-    for (auto subnet = subnets.rbegin(); subnet != subnets.rend(); ++subnet) {
-        ConstSubnet6Ptr subnet_returned = cfg.getBySubnetId((*subnet)->getID());
+    for (auto const& subnet : boost::adaptors::reverse(subnets)) {
+        ConstSubnet6Ptr subnet_returned = cfg.getBySubnetId(subnet->getID());
         ASSERT_TRUE(subnet_returned) << "failed to return subnet with id: "
-            << (*subnet)->getID();
-        EXPECT_EQ((*subnet)->getID(), subnet_returned->getID());
-        EXPECT_EQ((*subnet)->toText(), subnet_returned->toText());
+            << subnet->getID();
+        EXPECT_EQ(subnet->getID(), subnet_returned->getID());
+        EXPECT_EQ(subnet->toText(), subnet_returned->toText());
     }
 
     // Repeat the previous test, but this time retrieve subnets by their
     // prefixes.
-    for (auto subnet = subnets.rbegin(); subnet != subnets.rend(); ++subnet) {
-        ConstSubnet6Ptr subnet_returned = cfg.getByPrefix((*subnet)->toText());
+    for (auto const& subnet : boost::adaptors::reverse(subnets)) {
+        ConstSubnet6Ptr subnet_returned = cfg.getByPrefix(subnet->toText());
         ASSERT_TRUE(subnet_returned) << "failed to return subnet with id: "
-            << (*subnet)->getID();
-        EXPECT_EQ((*subnet)->getID(), subnet_returned->getID());
-        EXPECT_EQ((*subnet)->toText(), subnet_returned->toText());
+            << subnet->getID();
+        EXPECT_EQ(subnet->getID(), subnet_returned->getID());
+        EXPECT_EQ(subnet->toText(), subnet_returned->toText());
     }
 
     // Make sure that null pointers are returned for non-existing subnets.
@@ -1164,14 +1165,14 @@ TEST(CfgSubnets6Test, teeTimePercentValidation) {
 
     // Iterate over the test scenarios, verifying each prescribed
     // outcome.
-    for (auto test = tests.begin(); test != tests.end(); ++test) {
+    for (auto const& test : tests) {
         {
-            SCOPED_TRACE("test: " + (*test).label);
+            SCOPED_TRACE("test: " + test.label);
 
             // Set this scenario's configuration parameters
-            elems->set("calculate-tee-times", data::Element::create((*test).calculate_tee_times));
-            elems->set("t1-percent", data::Element::create((*test).t1_percent));
-            elems->set("t2-percent", data::Element::create((*test).t2_percent));
+            elems->set("calculate-tee-times", data::Element::create(test.calculate_tee_times));
+            elems->set("t1-percent", data::Element::create(test.t1_percent));
+            elems->set("t2-percent", data::Element::create(test.t2_percent));
 
             Subnet6Ptr subnet;
             try {
@@ -1179,9 +1180,9 @@ TEST(CfgSubnets6Test, teeTimePercentValidation) {
                 Subnet6ConfigParser parser;
                 subnet = parser.parse(elems);
             } catch (const std::exception& ex) {
-                if (!(*test).error_message.empty()) {
+                if (!test.error_message.empty()) {
                     // We expected a failure, did we fail the correct way?
-                    EXPECT_EQ((*test).error_message, ex.what());
+                    EXPECT_EQ(test.error_message, ex.what());
                 } else {
                     // Should not have failed.
                     ADD_FAILURE() << "Scenario should not have failed: " << ex.what();
@@ -1192,11 +1193,11 @@ TEST(CfgSubnets6Test, teeTimePercentValidation) {
             }
 
             // We parsed correctly, make sure the values are right.
-            EXPECT_EQ((*test).calculate_tee_times, subnet->getCalculateTeeTimes());
-            EXPECT_TRUE(util::areDoublesEquivalent((*test).t1_percent, subnet->getT1Percent()))
-                << "expected:" << (*test).t1_percent << " actual: " << subnet->getT1Percent();
-            EXPECT_TRUE(util::areDoublesEquivalent((*test).t2_percent, subnet->getT2Percent()))
-                << "expected:" << (*test).t2_percent << " actual: " << subnet->getT2Percent();
+            EXPECT_EQ(test.calculate_tee_times, subnet->getCalculateTeeTimes());
+            EXPECT_TRUE(util::areDoublesEquivalent(test.t1_percent, subnet->getT1Percent()))
+                << "expected:" << test.t1_percent << " actual: " << subnet->getT1Percent();
+            EXPECT_TRUE(util::areDoublesEquivalent(test.t2_percent, subnet->getT2Percent()))
+                << "expected:" << test.t2_percent << " actual: " << subnet->getT2Percent();
         }
     }
 }
@@ -1555,12 +1556,12 @@ TEST(CfgSubnets6Test, cacheParamValidation) {
 
     // Iterate over the test scenarios, verifying each prescribed
     // outcome.
-    for (auto test = tests.begin(); test != tests.end(); ++test) {
+    for (auto const& test : tests) {
         {
-            SCOPED_TRACE("test: " + (*test).label);
+            SCOPED_TRACE("test: " + test.label);
 
             // Set this scenario's configuration parameters
-            elems->set("cache-threshold", data::Element::create((*test).threshold));
+            elems->set("cache-threshold", data::Element::create(test.threshold));
 
             Subnet6Ptr subnet;
             try {
@@ -1568,9 +1569,9 @@ TEST(CfgSubnets6Test, cacheParamValidation) {
                 Subnet6ConfigParser parser;
                 subnet = parser.parse(elems);
             } catch (const std::exception& ex) {
-                if (!(*test).error_message.empty()) {
+                if (!test.error_message.empty()) {
                     // We expected a failure, did we fail the correct way?
-                    EXPECT_EQ((*test).error_message, ex.what());
+                    EXPECT_EQ(test.error_message, ex.what());
                 } else {
                     // Should not have failed.
                     ADD_FAILURE() << "Scenario should not have failed: " << ex.what();
@@ -1581,7 +1582,7 @@ TEST(CfgSubnets6Test, cacheParamValidation) {
             }
 
             // We parsed correctly, make sure the values are right.
-            EXPECT_TRUE(util::areDoublesEquivalent((*test).threshold, subnet->getCacheThreshold()));
+            EXPECT_TRUE(util::areDoublesEquivalent(test.threshold, subnet->getCacheThreshold()));
         }
     }
 }
index bb7b2f67a9f66937b2604e41a9290edc2c80c8e6..1909c8dddf1861752515b11ac85f061cbf922af9 100644 (file)
@@ -602,7 +602,7 @@ TEST(ClientClassDictionary, initMatchExprError) {
     ASSERT_THROW(dictionary->initMatchExpr(AF_INET), std::exception);
 
     // Ensure that no classes have their match expressions modified.
-    for (auto const& c : (*dictionary->getClasses())) {
+    for (auto const& c : *dictionary->getClasses()) {
         EXPECT_FALSE(c->getMatchExpr());
     }
 }
@@ -1448,7 +1448,7 @@ TEST(ClientClassDictionary, templateInitMatchExprError) {
     ASSERT_THROW(dictionary->initMatchExpr(AF_INET), std::exception);
 
     // Ensure that no classes have their match expressions modified.
-    for (auto const& c : (*dictionary->getClasses())) {
+    for (auto const& c : *dictionary->getClasses()) {
         EXPECT_FALSE(c->getMatchExpr());
     }
 }
index 84f429a6e106bda44a0d906bb598e8717f20342a..ce98d2b0d020b1a5f79761608f08f120f9e8587b 100644 (file)
@@ -36,7 +36,6 @@
 #include <testutils/test_to_element.h>
 
 #include <gtest/gtest.h>
-#include <boost/foreach.hpp>
 #include <boost/pointer_cast.hpp>
 
 #include <map>
@@ -197,12 +196,11 @@ public:
             return (answer);
         }
 
-        ConfigPair config_pair;
         try {
             // Iterate over the config elements.
             const std::map<std::string, ConstElementPtr>& values_map =
                                                       config_set->mapValue();
-            BOOST_FOREACH(config_pair, values_map) {
+            for (auto const& config_pair : values_map) {
 
                 // These are the simple parsers. No need to go through
                 // the ParserPtr hooplas with them.
@@ -337,14 +335,14 @@ public:
         // Now set option definition defaults for each specified option definition
         ConstElementPtr option_defs = global->get("option-def");
         if (option_defs) {
-            BOOST_FOREACH(ElementPtr single_def, option_defs->listValue()) {
+            for (auto const& single_def : option_defs->listValue()) {
                 cnt += SimpleParser::setDefaults(single_def, option_def_defaults);
             }
         }
 
         ConstElementPtr options = global->get("option-data");
         if (options) {
-            BOOST_FOREACH(ElementPtr single_option, options->listValue()) {
+            for (auto const& single_option : options->listValue()) {
                 cnt += SimpleParser::setDefaults(single_option, option_defaults);
             }
         }
index fd2ed2e0b98ca56dce4ece5435137f176bdc80d5..b8e81cef9e133a253607c9731f60c286433f4085 100644 (file)
@@ -20,8 +20,9 @@
 #include <dhcpsrv/parsers/host_reservation_parser.h>
 #include <dhcpsrv/testutils/config_result_check.h>
 #include <testutils/test_to_element.h>
-#include <boost/pointer_cast.hpp>
 #include <boost/algorithm/string.hpp>
+#include <boost/foreach.hpp>
+#include <boost/pointer_cast.hpp>
 #include <gtest/gtest.h>
 #include <iterator>
 #include <sstream>
@@ -67,9 +68,8 @@ protected:
     /// in which the reservation will be searched.
     bool
     reservationExists(const IPv6Resrv& resrv, const IPv6ResrvRange& range) {
-        for (IPv6ResrvIterator it = range.first; it != range.second;
-             ++it) {
-            if (resrv == it->second) {
+        BOOST_FOREACH(auto const& it, range) {
+            if (resrv == it.second) {
                 return (true);
             }
         }
index c10adde0bf1ef7edeb5668a8d9fb5b0d1f8e7624..8468e4e63498de2efbc9d3067ff5268c48925775 100644 (file)
@@ -173,8 +173,8 @@ TEST_F(HostReservationsListParserTest, ipv4Reservations) {
     HostReservationsListParser<HostReservationParser4> parser;
     ASSERT_NO_THROW(parser.parse(SubnetID(1), config_element, hosts));
 
-    for (auto h = hosts.begin(); h != hosts.end(); ++h) {
-        CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(*h);
+    for (auto const& h : hosts) {
+        CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(h);
     }
 
     CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
@@ -248,8 +248,8 @@ TEST_F(HostReservationsListParserTest, duplicatedIdentifierValue4) {
         HostReservationsListParser<HostReservationParser4> parser;
         EXPECT_THROW({
                 parser.parse(SubnetID(1), config_element, hosts);
-                for (auto h = hosts.begin(); h != hosts.end(); ++h) {
-                    CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(*h);
+                for (auto const& h : hosts) {
+                    CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(h);
                 }
             }, DuplicateHost);
         // The code threw exception, because the second insertion failed.
@@ -285,8 +285,8 @@ TEST_F(HostReservationsListParserTest, ipv6Reservations) {
     HostReservationsListParser<HostReservationParser6> parser;
     ASSERT_NO_THROW(parser.parse(SubnetID(2), config_element, hosts));
 
-    for (auto h = hosts.begin(); h != hosts.end(); ++h) {
-        CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(*h);
+    for (auto const& h : hosts) {
+        CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(h);
     }
 
     CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
@@ -378,8 +378,8 @@ TEST_F(HostReservationsListParserTest, duplicatedIdentifierValue6) {
         HostReservationsListParser<HostReservationParser6> parser;
         EXPECT_THROW({
             parser.parse(SubnetID(1), config_element, hosts);
-            for (auto h = hosts.begin(); h != hosts.end(); ++h) {
-                CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(*h);
+            for (auto const& h : hosts) {
+                CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(h);
             }
         }, DuplicateHost);
     }
index be8c674448a3f6d9240ed9fd1099115aaa9a8b2e..2661e8e13be6b99451445860f16a419e02dff255 100644 (file)
@@ -11,6 +11,7 @@
 #include <testutils/gtest_utils.h>
 #include <util/encode/hex.h>
 #include <util/range_utilities.h>
+#include <boost/foreach.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <gtest/gtest.h>
 #include <cstdlib>
@@ -167,9 +168,8 @@ public:
     /// @return true if reservation exists, false otherwise.
     bool
     reservationExists(const IPv6Resrv& resrv, const IPv6ResrvRange& range) {
-        for (IPv6ResrvIterator it = range.first; it != range.second;
-             ++it) {
-            if (resrv == it->second) {
+        BOOST_FOREACH(auto const& it, range) {
+            if (resrv == it.second) {
                 return (true);
             }
         }
@@ -925,10 +925,9 @@ TEST_F(HostTest, addOptions4) {
 
     // Validate codes of options added to dhcp4 option space.
     uint16_t expected_code = 100;
-    for (OptionContainer::const_iterator option_desc = options->begin();
-         option_desc != options->end(); ++option_desc) {
-        ASSERT_TRUE(option_desc->option_);
-        EXPECT_EQ(expected_code, option_desc->option_->getType());
+    for (auto const& option_desc : *options) {
+        ASSERT_TRUE(option_desc.option_);
+        EXPECT_EQ(expected_code, option_desc.option_->getType());
         ++expected_code;
     }
 
@@ -938,10 +937,9 @@ TEST_F(HostTest, addOptions4) {
 
     // Validate codes of options added to isc option space.
     expected_code = 105;
-    for (OptionContainer::const_iterator option_desc = options->begin();
-         option_desc != options->end(); ++option_desc) {
-        ASSERT_TRUE(option_desc->option_);
-        EXPECT_EQ(expected_code, option_desc->option_->getType());
+    for (auto const& option_desc : *options) {
+        ASSERT_TRUE(option_desc.option_);
+        EXPECT_EQ(expected_code, option_desc.option_->getType());
         ++expected_code;
     }
 
@@ -1013,10 +1011,9 @@ TEST_F(HostTest, addOptions6) {
 
     // Validate codes of options added to dhcp6 option space.
     uint16_t expected_code = 100;
-    for (OptionContainer::const_iterator option_desc = options->begin();
-         option_desc != options->end(); ++option_desc) {
-        ASSERT_TRUE(option_desc->option_);
-        EXPECT_EQ(expected_code, option_desc->option_->getType());
+    for (auto const& option_desc : *options) {
+        ASSERT_TRUE(option_desc.option_);
+        EXPECT_EQ(expected_code, option_desc.option_->getType());
         ++expected_code;
     }
 
@@ -1026,10 +1023,9 @@ TEST_F(HostTest, addOptions6) {
 
     // Validate codes of options added to isc option space.
     expected_code = 105;
-    for (OptionContainer::const_iterator option_desc = options->begin();
-         option_desc != options->end(); ++option_desc) {
-        ASSERT_TRUE(option_desc->option_);
-        EXPECT_EQ(expected_code, option_desc->option_->getType());
+    for (auto const& option_desc : *options) {
+        ASSERT_TRUE(option_desc.option_);
+        EXPECT_EQ(expected_code, option_desc.option_->getType());
         ++expected_code;
     }
 
index d40ee33a23967069fa134f36ca1808e9be9fcfd6..c1ba3315281d45a7a12e1ae797963a817a6a6067 100644 (file)
@@ -156,10 +156,9 @@ TEST(Pool4Test, addOptions) {
 
     // Validate codes of options added to dhcp4 option space.
     uint16_t expected_code = 100;
-    for (OptionContainer::const_iterator option_desc = options->begin();
-         option_desc != options->end(); ++option_desc) {
-        ASSERT_TRUE(option_desc->option_);
-        EXPECT_EQ(expected_code, option_desc->option_->getType());
+    for (auto const& option_desc : *options) {
+        ASSERT_TRUE(option_desc.option_);
+        EXPECT_EQ(expected_code, option_desc.option_->getType());
         ++expected_code;
     }
 
@@ -169,10 +168,9 @@ TEST(Pool4Test, addOptions) {
 
     // Validate codes of options added to isc option space.
     expected_code = 105;
-    for (OptionContainer::const_iterator option_desc = options->begin();
-         option_desc != options->end(); ++option_desc) {
-        ASSERT_TRUE(option_desc->option_);
-        EXPECT_EQ(expected_code, option_desc->option_->getType());
+    for (auto const& option_desc : *options) {
+        ASSERT_TRUE(option_desc.option_);
+        EXPECT_EQ(expected_code, option_desc.option_->getType());
         ++expected_code;
     }
 
@@ -562,10 +560,9 @@ TEST(Pool6Test, addOptions) {
 
     // Validate codes of options added to dhcp6 option space.
     uint16_t expected_code = 100;
-    for (OptionContainer::const_iterator option_desc = options->begin();
-         option_desc != options->end(); ++option_desc) {
-        ASSERT_TRUE(option_desc->option_);
-        EXPECT_EQ(expected_code, option_desc->option_->getType());
+    for (auto const& option_desc : *options) {
+        ASSERT_TRUE(option_desc.option_);
+        EXPECT_EQ(expected_code, option_desc.option_->getType());
         ++expected_code;
     }
 
@@ -575,10 +572,9 @@ TEST(Pool6Test, addOptions) {
 
     // Validate codes of options added to isc option space.
     expected_code = 105;
-    for (OptionContainer::const_iterator option_desc = options->begin();
-         option_desc != options->end(); ++option_desc) {
-        ASSERT_TRUE(option_desc->option_);
-        EXPECT_EQ(expected_code, option_desc->option_->getType());
+    for (auto const& option_desc : *options) {
+        ASSERT_TRUE(option_desc.option_);
+        EXPECT_EQ(expected_code, option_desc.option_->getType());
         ++expected_code;
     }
 
index 3472e0f19018457f18c08b7edd51047541876aa0..213d628dd018c06ee7625bef1bc7c61693214229 100644 (file)
@@ -92,10 +92,9 @@ public:
         ASSERT_EQ(test.addresses_.size(), network.getRelayAddresses().size());
 
         // Are the expected addresses in the list?
-        for (auto exp_address = test.addresses_.begin(); exp_address != test.addresses_.end();
-             ++exp_address) {
-            EXPECT_TRUE(network.hasRelayAddress(*exp_address))
-                        << " expected address: " << (*exp_address).toText() << " not found" ;
+        for (auto const& exp_address : test.addresses_) {
+            EXPECT_TRUE(network.hasRelayAddress(exp_address))
+                        << " expected address: " << exp_address.toText() << " not found" ;
         }
     }
 
@@ -451,11 +450,9 @@ TEST_F(SharedNetwork4ParserTest, relayInfoTests) {
 
     // Iterate over the test scenarios, verifying each prescribed
     // outcome.
-    for (auto test = tests.begin(); test != tests.end(); ++test) {
-        {
-            SCOPED_TRACE((*test).description_);
-            relayTest(*test);
-        }
+    for (auto const& test : tests) {
+        SCOPED_TRACE(test.description_);
+        relayTest(test);
     }
 }
 
@@ -1030,11 +1027,9 @@ TEST_F(SharedNetwork6ParserTest, relayInfoTests) {
 
     // Iterate over the test scenarios, verifying each prescribed
     // outcome.
-    for (auto test = tests.begin(); test != tests.end(); ++test) {
-        {
-            SCOPED_TRACE((*test).description_);
-            relayTest(*test);
-        }
+    for (auto const& test : tests) {
+        SCOPED_TRACE(test.description_);
+        relayTest(test);
     }
 }
 
index 77673c407438851a73c0695d1efa90951842dd41..e9d3b4f8e387bdf31b69072c20d0a58be43e9637 100644 (file)
@@ -551,21 +551,21 @@ TEST_F(SrvConfigTest, configuredGlobals) {
 
     // Maps and lists should be excluded.
     auto globals = srv_globals->valuesMap();
-    for (auto global = globals.begin(); global != globals.end(); ++global) {
-        if (global->first == "comment") {
-            ASSERT_EQ(Element::string, global->second->getType());
-            EXPECT_EQ("okay", global->second->stringValue());
-        } else if (global->first == "valid-lifetime") {
-            ASSERT_EQ(Element::integer, global->second->getType());
-            EXPECT_EQ(444, global->second->intValue());
-        } else if (global->first == "store-extended-info") {
-            ASSERT_EQ(Element::boolean, global->second->getType());
-            EXPECT_TRUE(global->second->boolValue());
-        } else if (global->first == "t1-percent") {
-            ASSERT_EQ(Element::real, global->second->getType());
-            EXPECT_EQ(1.234, global->second->doubleValue());
+    for (auto const& global : globals) {
+        if (global.first == "comment") {
+            ASSERT_EQ(Element::string, global.second->getType());
+            EXPECT_EQ("okay", global.second->stringValue());
+        } else if (global.first == "valid-lifetime") {
+            ASSERT_EQ(Element::integer, global.second->getType());
+            EXPECT_EQ(444, global.second->intValue());
+        } else if (global.first == "store-extended-info") {
+            ASSERT_EQ(Element::boolean, global.second->getType());
+            EXPECT_TRUE(global.second->boolValue());
+        } else if (global.first == "t1-percent") {
+            ASSERT_EQ(Element::real, global.second->getType());
+            EXPECT_EQ(1.234, global.second->doubleValue());
         } else {
-            ADD_FAILURE() << "unexpected element found:" << global->first;
+            ADD_FAILURE() << "unexpected element found:" << global.first;
         }
     }
 
index 69f762cace67620c85566dff8441692bc66250a6..c13680438a6cbf0bb9fd0e6c7e5b437dc2a9f02a 100644 (file)
@@ -1380,10 +1380,9 @@ TEST(Subnet6Test, addOptions) {
 
     // Validate codes of options added to dhcp6 option space.
     uint16_t expected_code = 100;
-    for (OptionContainer::const_iterator option_desc = options->begin();
-         option_desc != options->end(); ++option_desc) {
-        ASSERT_TRUE(option_desc->option_);
-        EXPECT_EQ(expected_code, option_desc->option_->getType());
+    for (auto const& option_desc : *options) {
+        ASSERT_TRUE(option_desc.option_);
+        EXPECT_EQ(expected_code, option_desc.option_->getType());
         ++expected_code;
     }
 
@@ -1393,10 +1392,9 @@ TEST(Subnet6Test, addOptions) {
 
     // Validate codes of options added to isc option space.
     expected_code = 105;
-    for (OptionContainer::const_iterator option_desc = options->begin();
-         option_desc != options->end(); ++option_desc) {
-        ASSERT_TRUE(option_desc->option_);
-        EXPECT_EQ(expected_code, option_desc->option_->getType());
+    for (auto const& option_desc : *options) {
+        ASSERT_TRUE(option_desc.option_);
+        EXPECT_EQ(expected_code, option_desc.option_->getType());
         ++expected_code;
     }
 
@@ -1435,10 +1433,9 @@ TEST(Subnet6Test, addNonUniqueOptions) {
         // have been returned for the particular code.
         ASSERT_EQ(2, distance(range.first, range.second));
         // Check that returned options actually have the expected option code.
-        for (OptionContainerTypeIndex::const_iterator option_desc = range.first;
-             option_desc != range.second; ++option_desc) {
-            ASSERT_TRUE(option_desc->option_);
-            EXPECT_EQ(code, option_desc->option_->getType());
+        BOOST_FOREACH(auto const& option_desc, range) {
+            ASSERT_TRUE(option_desc.option_);
+            EXPECT_EQ(code, option_desc.option_->getType());
         }
     }
 
@@ -1544,10 +1541,9 @@ TEST(Subnet6Test, addVendorOption) {
 
     // Validate codes of options added to dhcp6 option space.
     uint16_t expected_code = 100;
-    for (OptionContainer::const_iterator option_desc = options->begin();
-         option_desc != options->end(); ++option_desc) {
-        ASSERT_TRUE(option_desc->option_);
-        EXPECT_EQ(expected_code, option_desc->option_->getType());
+    for (auto const& option_desc : *options) {
+        ASSERT_TRUE(option_desc.option_);
+        EXPECT_EQ(expected_code, option_desc.option_->getType());
         ++expected_code;
     }
 
@@ -1557,10 +1553,9 @@ TEST(Subnet6Test, addVendorOption) {
 
     // Validate codes of options added to isc option space.
     expected_code = 105;
-    for (OptionContainer::const_iterator option_desc = options->begin();
-         option_desc != options->end(); ++option_desc) {
-        ASSERT_TRUE(option_desc->option_);
-        EXPECT_EQ(expected_code, option_desc->option_->getType());
+    for (auto const& option_desc : *options) {
+        ASSERT_TRUE(option_desc.option_);
+        EXPECT_EQ(expected_code, option_desc.option_->getType());
         ++expected_code;
     }
 
index d1eba3364337786f4638c6fc224cbcbfe78e5ee4..fbc3c75b46afd3651ec945ba54d78ba5a5ffadf8 100644 (file)
@@ -295,12 +295,12 @@ TimerMgrTest::testUnregisterTimers() {
     doWait(500);
 
     // Make sure that all timers have been executed at least once.
-    for (CallsCount::iterator it = calls_count_.begin();
-         it != calls_count_.end(); ++it) {
-        unsigned int calls_count = it->second;
+    size_t count = 0;
+    for (auto const& it : calls_count_) {
+        unsigned int calls_count = it.second;
         ASSERT_GT(calls_count, 0)
-            << "expected calls counter for timer"
-            << (std::distance(calls_count_.begin(), it) + 1)
+            << "expected calls counter for timer "
+            << ++count
             << " greater than 0";
     }
 
index 55540e0aae70d1d72c8fe8e0d12f19471d013932..462dbdfa09cb8e4e29ff53cc34829ddeddfe506c 100644 (file)
@@ -13,6 +13,8 @@
 #include <typeinfo>
 #include <testutils/gtest_utils.h>
 
+#include <boost/range/adaptor/reversed.hpp>
+
 using namespace isc::data;
 using namespace isc::db;
 
@@ -168,11 +170,13 @@ GenericBackendTest::testNewAuditEntry(const std::string& exp_object_type,
 
     // Iterate over specified number of entries starting from the most recent
     // one and check they have correct values.
-    for (auto audit_entry_it = mod_time_idx.rbegin();
-         ((std::distance(mod_time_idx.rbegin(), audit_entry_it) < new_entries_num) &&
-         (std::distance(mod_time_idx.rbegin(), audit_entry_it) < max_tested_entries));
-         ++audit_entry_it) {
-        auto audit_entry = *audit_entry_it;
+    size_t count = 0;
+    for (auto const& audit_entry_it : boost::adaptors::reverse(mod_time_idx)) {
+        if (count >= new_entries_num || count >= max_tested_entries) {
+            break;
+        }
+        count++;
+        auto audit_entry = audit_entry_it;
         EXPECT_EQ(exp_object_type, audit_entry->getObjectType())
                   << logExistingAuditEntries(tag);
         EXPECT_EQ(exp_modification_type, audit_entry->getModificationType())
@@ -219,11 +223,13 @@ GenericBackendTest::testNewAuditEntry(const std::vector<ExpAuditEntry>& exp_entr
     // Iterate over specified number of entries starting from the most recent
     // one and check they have correct values.
     auto exp_entry = exp_entries.rbegin();
-    for (auto audit_entry_it = mod_time_idx.rbegin();
-         ((std::distance(mod_time_idx.rbegin(), audit_entry_it) < new_entries_num));
-         ++audit_entry_it) {
-
-        auto audit_entry = *audit_entry_it;
+    size_t count = 0;
+    for (auto const& audit_entry_it : boost::adaptors::reverse(mod_time_idx)) {
+        if (count >= new_entries_num) {
+            break;
+        }
+        count++;
+        auto audit_entry = audit_entry_it;
         EXPECT_EQ((*exp_entry).object_type, audit_entry->getObjectType())
                   << logExistingAuditEntries(tag);
         EXPECT_EQ((*exp_entry).modification_type, audit_entry->getModificationType())
@@ -260,10 +266,8 @@ GenericBackendTest::logExistingAuditEntries(const std::string& server_tag) {
 
     auto& mod_time_idx = audit_entries_[server_tag].get<AuditEntryModificationTimeIdTag>();
 
-    for (auto audit_entry_it = mod_time_idx.begin();
-         audit_entry_it != mod_time_idx.end();
-         ++audit_entry_it) {
-        auto audit_entry = *audit_entry_it;
+    for (auto const& audit_entry_it : mod_time_idx) {
+        auto audit_entry = audit_entry_it;
         s << audit_entry->getObjectType() << ", "
           << audit_entry->getObjectId() << ", "
           << static_cast<int>(audit_entry->getModificationType()) << ", "
index 4d71fce430e6621ae154d06763f12f1594385a5c..4abf305689093ededdb1e45485c03a891ed2f381 100644 (file)
@@ -776,9 +776,9 @@ GenericConfigBackendDHCPv4Test::globalParameters4WithServerTagsTest() {
     // Capture the returned values into the map so as we can check the
     // values against the servers.
     std::map<std::string, std::string> values;
-    for (auto g = returned_globals.begin(); g != returned_globals.end(); ++g) {
-        ASSERT_EQ(1, (*g)->getServerTags().size());
-        values[(*g)->getServerTags().begin()->get()] = ((*g)->getValue());
+    for (auto const& g : returned_globals) {
+        ASSERT_EQ(1, g->getServerTags().size());
+        values[g->getServerTags().begin()->get()] = g->getValue();
     }
 
     ASSERT_EQ(3, values.size());
@@ -895,10 +895,9 @@ GenericConfigBackendDHCPv4Test::getAllGlobalParameters4Test() {
     EXPECT_TRUE((*parameters_index.find("name4"))->getBoolValue());
     EXPECT_EQ(1.65, (*parameters_index.find("name5"))->getDoubleValue());
 
-    for (auto param = parameters_index.begin(); param != parameters_index.end();
-         ++param) {
-        ASSERT_EQ(1, (*param)->getServerTags().size());
-        EXPECT_EQ("all", (*param)->getServerTags().begin()->get());
+    for (auto const& param : parameters_index) {
+        ASSERT_EQ(1, param->getServerTags().size());
+        EXPECT_EQ("all", param->getServerTags().begin()->get());
     }
 
     // Should be able to fetch these parameters when explicitly providing
@@ -3101,17 +3100,17 @@ GenericConfigBackendDHCPv4Test::getAllOptionDefs4Test() {
     ASSERT_EQ(test_option_defs_.size() - updates_num, option_defs.size());
 
     // See if option definitions are returned ok.
-    for (auto def = option_defs.begin(); def != option_defs.end(); ++def) {
-        ASSERT_EQ(1, (*def)->getServerTags().size());
-        EXPECT_EQ("all", (*def)->getServerTags().begin()->get());
+    for (auto const& def : option_defs) {
+        ASSERT_EQ(1, def->getServerTags().size());
+        EXPECT_EQ("all", def->getServerTags().begin()->get());
         bool success = false;
         for (auto i = 1; i < test_option_defs_.size(); ++i) {
-            if ((*def)->equals(*test_option_defs_[i])) {
+            if (def->equals(*test_option_defs_[i])) {
                 success = true;
             }
         }
-        ASSERT_TRUE(success) << "failed for option definition " << (*def)->getCode()
-            << ", option space " << (*def)->getOptionSpaceName();
+        ASSERT_TRUE(success) << "failed for option definition " << def->getCode()
+            << ", option space " << def->getOptionSpaceName();
     }
 
     // Deleting non-existing option definition should return 0.
@@ -4610,12 +4609,13 @@ GenericConfigBackendDHCPv4Test::multipleAuditEntriesTest() {
 
     // Check that partial retrieves return the right count.
     auto& mod_time_idx = audit_entries.get<AuditEntryModificationTimeIdTag>();
-    for (auto it = mod_time_idx.begin(); it != mod_time_idx.end(); ++it) {
+    size_t distance = mod_time_idx.size();
+    for (auto const& it : mod_time_idx) {
         size_t partial_size =
             cbptr_->getRecentAuditEntries(server_selector,
-                                          (*it)->getModificationTime(),
-                                          (*it)->getRevisionId()).size();
-        EXPECT_EQ(partial_size + 1,
-                  std::distance(it, mod_time_idx.end()));
+                                          it->getModificationTime(),
+                                          it->getRevisionId()).size();
+        EXPECT_EQ(partial_size + 1, distance);
+        distance--;
     }
 }
index 62985934c56860a17b9278fce16e455ce3fc8754..b9cf42b1ebdec1f214ac2df60922f95389b8681d 100644 (file)
@@ -808,9 +808,9 @@ GenericConfigBackendDHCPv6Test::globalParameters6WithServerTagsTest() {
     // Capture the returned values into the map so as we can check the
     // values against the servers.
     std::map<std::string, std::string> values;
-    for (auto g = returned_globals.begin(); g != returned_globals.end(); ++g) {
-        ASSERT_EQ(1, (*g)->getServerTags().size());
-        values[(*g)->getServerTags().begin()->get()] = ((*g)->getValue());
+    for (auto const& g : returned_globals) {
+        ASSERT_EQ(1, g->getServerTags().size());
+        values[g->getServerTags().begin()->get()] = g->getValue();
     }
 
     ASSERT_EQ(3, values.size());
@@ -927,10 +927,9 @@ GenericConfigBackendDHCPv6Test::getAllGlobalParameters6Test() {
     EXPECT_TRUE((*parameters_index.find("name4"))->getBoolValue());
     EXPECT_EQ(1.65, (*parameters_index.find("name5"))->getDoubleValue());
 
-    for (auto param = parameters_index.begin(); param != parameters_index.end();
-         ++param) {
-        ASSERT_EQ(1, (*param)->getServerTags().size());
-        EXPECT_EQ("all", (*param)->getServerTags().begin()->get());
+    for (auto const& param : parameters_index) {
+        ASSERT_EQ(1, param->getServerTags().size());
+        EXPECT_EQ("all", param->getServerTags().begin()->get());
     }
 
     // Should be able to fetch these parameters when explicitly providing
@@ -3127,17 +3126,17 @@ GenericConfigBackendDHCPv6Test::getAllOptionDefs6Test() {
     ASSERT_EQ(test_option_defs_.size() - updates_num, option_defs.size());
 
     // See if option definitions are returned ok.
-    for (auto def = option_defs.begin(); def != option_defs.end(); ++def) {
-        ASSERT_EQ(1, (*def)->getServerTags().size());
-        EXPECT_EQ("all", (*def)->getServerTags().begin()->get());
+    for (auto const& def : option_defs) {
+        ASSERT_EQ(1, def->getServerTags().size());
+        EXPECT_EQ("all", def->getServerTags().begin()->get());
         bool success = false;
         for (auto i = 1; i < test_option_defs_.size(); ++i) {
-            if ((*def)->equals(*test_option_defs_[i])) {
+            if (def->equals(*test_option_defs_[i])) {
                 success = true;
             }
         }
-        ASSERT_TRUE(success) << "failed for option definition " << (*def)->getCode()
-            << ", option space " << (*def)->getOptionSpaceName();
+        ASSERT_TRUE(success) << "failed for option definition " << def->getCode()
+            << ", option space " << def->getOptionSpaceName();
     }
 
     // Deleting non-existing option definition should return 0.
@@ -4761,12 +4760,13 @@ GenericConfigBackendDHCPv6Test::multipleAuditEntriesTest() {
 
     // Check that partial retrieves return the right count.
     auto& mod_time_idx = audit_entries.get<AuditEntryModificationTimeIdTag>();
-    for (auto it = mod_time_idx.begin(); it != mod_time_idx.end(); ++it) {
+    size_t distance = mod_time_idx.size();
+    for (auto const& it : mod_time_idx) {
         size_t partial_size =
             cbptr_->getRecentAuditEntries(server_selector,
-                                          (*it)->getModificationTime(),
-                                          (*it)->getRevisionId()).size();
-        EXPECT_EQ(partial_size + 1,
-                  std::distance(it, mod_time_idx.end()));
+                                          it->getModificationTime(),
+                                          it->getRevisionId()).size();
+        EXPECT_EQ(partial_size + 1, distance);
+        distance--;
     }
 }
index f3caa3f8c6e1f564461b26907c11f5ab290cbdbb..c14e398c67e3c4882f9cc6c9971ef8a08daeb4e0 100644 (file)
@@ -1446,22 +1446,20 @@ GenericHostDataSourceTest::testHostname(std::string name, int num) {
     }
 
     // Now add them all to the host data source.
-    for (vector<HostPtr>::const_iterator it = hosts.begin(); it != hosts.end();
-         ++it) {
+    for (auto const& it : hosts) {
         // Try to add both of the to the host data source.
-        ASSERT_NO_THROW(hdsptr_->add(*it));
+        ASSERT_NO_THROW(hdsptr_->add(it));
     }
 
     // And finally retrieve them one by one and check
     // if the hostname was preserved.
-    for (vector<HostPtr>::const_iterator it = hosts.begin(); it != hosts.end();
-         ++it) {
+    for (auto const& it : hosts) {
         ConstHostPtr from_hds;
-        ASSERT_NO_THROW(from_hds = hdsptr_->get4((*it)->getIPv4SubnetID(),
-                                                 (*it)->getIPv4Reservation()));
+        ASSERT_NO_THROW(from_hds = hdsptr_->get4(it->getIPv4SubnetID(),
+                                                 it->getIPv4Reservation()));
         ASSERT_TRUE(from_hds);
 
-        EXPECT_EQ((*it)->getHostname(), from_hds->getHostname());
+        EXPECT_EQ(it->getHostname(), from_hds->getHostname());
     }
 }
 
@@ -1542,10 +1540,9 @@ GenericHostDataSourceTest::testMultipleSubnets(int subnets,
 
     // Verify that the values returned are proper.
     int i = 0;
-    for (ConstHostCollection::const_iterator it = all_by_addr.begin();
-         it != all_by_addr.end(); ++it) {
-        EXPECT_EQ(IOAddress("192.0.2.1"), (*it)->getIPv4Reservation());
-        EXPECT_EQ(1000 + i++, (*it)->getIPv4SubnetID());
+    for (auto const& it : all_by_addr) {
+        EXPECT_EQ(IOAddress("192.0.2.1"), it->getIPv4Reservation());
+        EXPECT_EQ(1000 + i++, it->getIPv4SubnetID());
     }
 
     // Finally, check that the hosts can be retrieved by HW address or DUID
@@ -1555,10 +1552,9 @@ GenericHostDataSourceTest::testMultipleSubnets(int subnets,
 
     // Check that the returned values are as expected.
     i = 0;
-    for (ConstHostCollection::const_iterator it = all_by_id.begin();
-         it != all_by_id.end(); ++it) {
-        EXPECT_EQ(IOAddress("192.0.2.1"), (*it)->getIPv4Reservation());
-        EXPECT_EQ(1000 + i++, (*it)->getIPv4SubnetID());
+    for (auto const& it : all_by_id) {
+        EXPECT_EQ(IOAddress("192.0.2.1"), it->getIPv4Reservation());
+        EXPECT_EQ(1000 + i++, it->getIPv4SubnetID());
     }
 }
 
@@ -1678,10 +1674,9 @@ GenericHostDataSourceTest::testSubnetId6(int subnets, Host::IdentifierType id) {
 
     // Check that the returned values are as expected.
     int i = 0;
-    for (ConstHostCollection::const_iterator it = all_by_id.begin();
-         it != all_by_id.end(); ++it) {
-        EXPECT_EQ(IOAddress("0.0.0.0"), (*it)->getIPv4Reservation());
-        EXPECT_EQ(1000 + i++, (*it)->getIPv6SubnetID());
+    for (auto const& it : all_by_id) {
+        EXPECT_EQ(IOAddress("0.0.0.0"), it->getIPv4Reservation());
+        EXPECT_EQ(1000 + i++, it->getIPv6SubnetID());
     }
 }
 
@@ -2354,9 +2349,8 @@ GenericHostDataSourceTest::stressTest(unsigned int nOfHosts /* = 0xfffdU */) {
     start = (struct timespec){0, 0};
     end = (struct timespec){0, 0};
     clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
-    for (std::vector<HostPtr>::const_iterator it = hosts.begin();
-         it != hosts.end(); it++) {
-        ASSERT_NO_THROW(hdsptr_->add(*it));
+    for (auto const& it : hosts) {
+        ASSERT_NO_THROW(hdsptr_->add(it));
     }
     clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
     double s = static_cast<double>(end.tv_sec - start.tv_sec) +
@@ -2371,15 +2365,14 @@ GenericHostDataSourceTest::stressTest(unsigned int nOfHosts /* = 0xfffdU */) {
     start = (struct timespec){0, 0};
     end = (struct timespec){0, 0};
     clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
-    for (std::vector<HostPtr>::const_iterator it = hosts.begin();
-         it != hosts.end(); it++) {
-        IPv6ResrvRange range = (*it)->getIPv6Reservations();
+    for (auto const& it : hosts) {
+        IPv6ResrvRange range = it->getIPv6Reservations();
         // This get6() call is particularly useful to test because it involves a
         // subquery for MySQL and PostgreSQL.
         ConstHostPtr from_hds =
             hdsptr_->get6(range.first->second.getPrefix(), 128);
         ASSERT_TRUE(from_hds);
-        HostDataSourceUtils::compareHosts(*it, from_hds);
+        HostDataSourceUtils::compareHosts(it, from_hds);
     }
     clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
     s = static_cast<double>(end.tv_sec - start.tv_sec) +
index 9e1d87c9eb351e268492fe53b709a967d6652d5a..e832efec09839e24cf92cb29dcd9375c43e7587f 100644 (file)
@@ -20,7 +20,7 @@
 #include <testutils/gtest_utils.h>
 #include <util/bigints.h>
 
-#include <boost/foreach.hpp>
+#include <boost/range/adaptor/reversed.hpp>
 #include <boost/scoped_ptr.hpp>
 
 #include <gtest/gtest.h>
@@ -575,20 +575,18 @@ GenericLeaseMgrTest::testGetLease4HWAddr2() {
 
     // Check the lease[5] (and only this one) has an user context.
     size_t contexts = 0;
-    for (Lease4Collection::const_iterator i = returned.begin();
-         i != returned.end(); ++i) {
-        if ((*i)->getContext()) {
+    for (auto const& i : returned) {
+        if (i->getContext()) {
             ++contexts;
-            EXPECT_EQ("{ \"foo\": true }", (*i)->getContext()->str());
+            EXPECT_EQ("{ \"foo\": true }", i->getContext()->str());
         }
     }
     EXPECT_EQ(1, contexts);
 
     // Easiest way to check is to look at the addresses.
     vector<string> addresses;
-    for (Lease4Collection::const_iterator i = returned.begin();
-         i != returned.end(); ++i) {
-        addresses.push_back((*i)->addr_.toText());
+    for (auto const& i : returned) {
+        addresses.push_back(i->addr_.toText());
     }
     sort(addresses.begin(), addresses.end());
     EXPECT_EQ(straddress4_[1], addresses[0]);
@@ -1172,20 +1170,18 @@ GenericLeaseMgrTest::testGetLease4ClientId2() {
 
     // Check the lease[5] (and only this one) has an user context.
     size_t contexts = 0;
-    for (Lease4Collection::const_iterator i = returned.begin();
-         i != returned.end(); ++i) {
-        if ((*i)->getContext()) {
+    for (auto const& i : returned) {
+        if (i->getContext()) {
             ++contexts;
-            EXPECT_EQ("{ \"foo\": true }", (*i)->getContext()->str());
+            EXPECT_EQ("{ \"foo\": true }", i->getContext()->str());
         }
     }
     EXPECT_EQ(1, contexts);
 
     // Easiest way to check is to look at the addresses.
     vector<string> addresses;
-    for (Lease4Collection::const_iterator i = returned.begin();
-         i != returned.end(); ++i) {
-        addresses.push_back((*i)->addr_.toText());
+    for (auto const& i : returned) {
+        addresses.push_back(i->addr_.toText());
     }
     sort(addresses.begin(), addresses.end());
     EXPECT_EQ(straddress4_[1], addresses[0]);
@@ -1335,7 +1331,7 @@ GenericLeaseMgrTest::testGetLeases4Paged() {
         Lease4Collection page = lmptr_->getLeases4(last_address, LeasePageSize(3));
 
         // Collect leases in a common structure. They may be out of order.
-        for (const Lease4Ptr& lease : page) {
+        for (auto const& lease : page) {
             all_leases.push_back(lease);
         }
 
@@ -1356,9 +1352,9 @@ GenericLeaseMgrTest::testGetLeases4Paged() {
 
     // Make sure that all leases that we stored in the lease database
     // have been retrieved.
-    for (const Lease4Ptr& lease : leases) {
+    for (auto const& lease : leases) {
         bool found = false;
-        for (const Lease4Ptr& returned_lease : all_leases) {
+        for (auto const& returned_lease : all_leases) {
             if (lease->addr_ == returned_lease->addr_) {
                 found = true;
                 break;
@@ -1421,7 +1417,7 @@ GenericLeaseMgrTest::testGetLeases6SubnetIdPaged() {
                                                    LeasePageSize(3));
 
         // Collect leases in a common structure.
-        for (Lease6Ptr lease : page) {
+        for (auto const& lease : page) {
             all_leases.push_back(lease);
         }
 
@@ -1440,12 +1436,12 @@ GenericLeaseMgrTest::testGetLeases6SubnetIdPaged() {
 
     // Make sure that all leases that we stored in the lease database
     // have been retrieved at the exception of the third.
-    for (Lease6Ptr lease : leases) {
+    for (auto const& lease : leases) {
         if (lease == leases[3]) {
             continue;
         }
         bool found = false;
-        for (Lease6Ptr returned_lease : all_leases) {
+        for (auto const& returned_lease : all_leases) {
             if (lease->addr_ == returned_lease->addr_) {
                 found = true;
                 break;
@@ -1517,7 +1513,7 @@ GenericLeaseMgrTest::testGetLeases6Paged() {
         Lease6Collection page = lmptr_->getLeases6(last_address, LeasePageSize(3));
 
         // Collect leases in a common structure. They may be out of order.
-        for (const Lease6Ptr& lease : page) {
+        for (auto const& lease : page) {
             all_leases.push_back(lease);
         }
 
@@ -1538,9 +1534,9 @@ GenericLeaseMgrTest::testGetLeases6Paged() {
 
     // Make sure that all leases that we stored in the lease database
     // have been retrieved.
-    for (const Lease6Ptr& lease : leases) {
+    for (auto const& lease : leases) {
         bool found = false;
-        for (const Lease6Ptr& returned_lease : all_leases) {
+        for (auto const& returned_lease : all_leases) {
             if (lease->addr_ == returned_lease->addr_) {
                 found = true;
                 break;
@@ -1576,9 +1572,8 @@ GenericLeaseMgrTest::testGetLeases6DuidIaid() {
 
     // Easiest way to check is to look at the addresses.
     vector<string> addresses;
-    for (Lease6Collection::const_iterator i = returned.begin();
-         i != returned.end(); ++i) {
-        addresses.push_back((*i)->addr_.toText());
+    for (auto const& i : returned) {
+        addresses.push_back(i->addr_.toText());
     }
     sort(addresses.begin(), addresses.end());
     EXPECT_EQ(straddress6_[1], addresses[0]);
@@ -1694,9 +1689,8 @@ GenericLeaseMgrTest::testLease6LeaseTypeCheck() {
         // Collection order returned is not guaranteed.
         // Easiest way to check is to look at the addresses.
         vector<string> addresses;
-        for (Lease6Collection::const_iterator it = returned.begin();
-            it != returned.end(); ++it) {
-            addresses.push_back((*it)->addr_.toText());
+        for (auto const& it : returned) {
+            addresses.push_back(it->addr_.toText());
         }
 
         auto compare_addr = [](const string& left, const string& right) {
@@ -2205,13 +2199,13 @@ GenericLeaseMgrTest::testGetExpiredLeases4() {
 
     // The expired leases should be returned from the most to least expired.
     // This matches the reverse order to which they have been added.
-    for (Lease4Collection::reverse_iterator lease = expired_leases.rbegin();
-         lease != expired_leases.rend(); ++lease) {
-        int index = static_cast<int>(std::distance(expired_leases.rbegin(), lease));
+    size_t count = 0;
+    for (auto const& lease : boost::adaptors::reverse(expired_leases)) {
+        int index = count++;
         // Multiple current index by two, because only leases with even indexes
         // should have been returned.
         ASSERT_LE(2 * index, leases.size());
-        EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+        EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
     }
 
     // Update current time for the next test.
@@ -2239,11 +2233,11 @@ GenericLeaseMgrTest::testGetExpiredLeases4() {
     ASSERT_EQ(static_cast<size_t>(leases.size() / 2), expired_leases.size());
 
     // This time leases should be returned in the non-reverse order.
-    for (Lease4Collection::iterator lease = expired_leases.begin();
-         lease != expired_leases.end(); ++lease) {
-        int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
+    count = 0;
+    for (auto const& lease : expired_leases) {
+        int index = count++;
         ASSERT_LE(2 * index, leases.size());
-        EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+        EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
     }
 
     // Remember expired leases returned.
@@ -2259,11 +2253,11 @@ GenericLeaseMgrTest::testGetExpiredLeases4() {
     ASSERT_EQ(2, expired_leases.size());
 
     // Test that most expired leases have been returned.
-    for (Lease4Collection::iterator lease = expired_leases.begin();
-         lease != expired_leases.end(); ++lease) {
-        int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
+    count = 0;
+    for (auto const& lease : expired_leases) {
+        int index = count++;
         ASSERT_LE(2 * index, leases.size());
-        EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+        EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
     }
 
     // Mark every other expired lease as reclaimed.
@@ -2284,10 +2278,10 @@ GenericLeaseMgrTest::testGetExpiredLeases4() {
 
     // Make sure that returned leases are those that are not reclaimed, i.e.
     // those that have even index.
-    for (Lease4Collection::iterator lease = expired_leases.begin();
-         lease != expired_leases.end(); ++lease) {
-        int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
-        EXPECT_EQ(saved_expired_leases[2 * index]->addr_, (*lease)->addr_);
+    count = 0;
+    for (auto const& lease : expired_leases) {
+        int index = count++;
+        EXPECT_EQ(saved_expired_leases[2 * index]->addr_, lease->addr_);
     }
 }
 
@@ -2327,12 +2321,12 @@ GenericLeaseMgrTest::testGetExpiredLeases6() {
 
     // The expired leases should be returned from the most to least expired.
     // This matches the reverse order to which they have been added.
-    for (Lease6Collection::reverse_iterator lease = expired_leases.rbegin();
-         lease != expired_leases.rend(); ++lease) {
-        int index = static_cast<int>(std::distance(expired_leases.rbegin(), lease));
+    size_t count = 0;
+    for (auto const& lease : boost::adaptors::reverse(expired_leases)) {
+        int index = count++;
         // Multiple current index by two, because only leases with even indexes
         // should have been returned.
-        EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+        EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
     }
 
     // Update current time for the next test.
@@ -2361,10 +2355,10 @@ GenericLeaseMgrTest::testGetExpiredLeases6() {
     ASSERT_EQ(static_cast<size_t>(leases.size() / 2), expired_leases.size());
 
     // This time leases should be returned in the non-reverse order.
-    for (Lease6Collection::iterator lease = expired_leases.begin();
-         lease != expired_leases.end(); ++lease) {
-        int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
-        EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+    count = 0;
+    for (auto const& lease : expired_leases) {
+        int index = count++;
+        EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
     }
 
     // Remember expired leases returned.
@@ -2380,10 +2374,10 @@ GenericLeaseMgrTest::testGetExpiredLeases6() {
     ASSERT_EQ(2, expired_leases.size());
 
     // Test that most expired leases have been returned.
-    for (Lease6Collection::iterator lease = expired_leases.begin();
-         lease != expired_leases.end(); ++lease) {
-        int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
-        EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+    count = 0;
+    for (auto const& lease : expired_leases) {
+        int index = count++;
+        EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
     }
 
     // Mark every other expired lease as reclaimed.
@@ -2404,10 +2398,10 @@ GenericLeaseMgrTest::testGetExpiredLeases6() {
 
     // Make sure that returned leases are those that are not reclaimed, i.e.
     // those that have even index.
-    for (Lease6Collection::iterator lease = expired_leases.begin();
-         lease != expired_leases.end(); ++lease) {
-        int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
-        EXPECT_EQ(saved_expired_leases[2 * index]->addr_, (*lease)->addr_);
+    count = 0;
+    for (auto const& lease : expired_leases) {
+        int index = count++;
+        EXPECT_EQ(saved_expired_leases[2 * index]->addr_, lease->addr_);
     }
 }
 
@@ -2708,17 +2702,17 @@ GenericLeaseMgrTest::testGetDeclinedLeases4() {
 
     // The expired leases should be returned from the most to least expired.
     // This matches the reverse order to which they have been added.
-    for (Lease4Collection::reverse_iterator lease = expired_leases.rbegin();
-         lease != expired_leases.rend(); ++lease) {
-        int index = static_cast<int>(std::distance(expired_leases.rbegin(), lease));
+    size_t count = 0;
+    for (auto const& lease : boost::adaptors::reverse(expired_leases)) {
+        int index = count++;
         // Multiple current index by two, because only leases with even indexes
         // should have been returned.
-        EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+        EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
 
         // Count leases in default and declined states
-        if ((*lease)->state_ == Lease::STATE_DEFAULT) {
+        if (lease->state_ == Lease::STATE_DEFAULT) {
             default_state++;
-        } else if ((*lease)->state_ == Lease::STATE_DECLINED) {
+        } else if (lease->state_ == Lease::STATE_DECLINED) {
             declined_state++;
         }
     }
@@ -2763,15 +2757,15 @@ GenericLeaseMgrTest::testGetDeclinedLeases4() {
     // This time leases should be returned in the non-reverse order.
     declined_state = 0;
     default_state = 0;
-    for (Lease4Collection::iterator lease = expired_leases.begin();
-         lease != expired_leases.end(); ++lease) {
-        int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
-        EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+    count = 0;
+    for (auto const& lease : expired_leases) {
+        int index = count++;
+        EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
 
         // Count leases in default and declined states
-        if ((*lease)->state_ == Lease::STATE_DEFAULT) {
+        if (lease->state_ == Lease::STATE_DEFAULT) {
             default_state++;
-        } else if ((*lease)->state_ == Lease::STATE_DECLINED) {
+        } else if (lease->state_ == Lease::STATE_DECLINED) {
             declined_state++;
         }
     }
@@ -2790,10 +2784,10 @@ GenericLeaseMgrTest::testGetDeclinedLeases4() {
     ASSERT_EQ(2, expired_leases.size());
 
     // Test that most expired leases have been returned.
-    for (Lease4Collection::iterator lease = expired_leases.begin();
-         lease != expired_leases.end(); ++lease) {
-        int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
-        EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+    count = 0;
+    for (auto const& lease : expired_leases) {
+        int index = count++;
+        EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
     }
 }
 
@@ -2858,17 +2852,17 @@ GenericLeaseMgrTest::testGetDeclinedLeases6() {
 
     // The expired leases should be returned from the most to least expired.
     // This matches the reverse order to which they have been added.
-    for (Lease6Collection::reverse_iterator lease = expired_leases.rbegin();
-         lease != expired_leases.rend(); ++lease) {
-        int index = static_cast<int>(std::distance(expired_leases.rbegin(), lease));
+    size_t count = 0;
+    for (auto const& lease : boost::adaptors::reverse(expired_leases)) {
+        int index = count++;
         // Multiple current index by two, because only leases with even indexes
         // should have been returned.
-        EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+        EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
 
         // Count leases in default and declined states
-        if ((*lease)->state_ == Lease::STATE_DEFAULT) {
+        if (lease->state_ == Lease::STATE_DEFAULT) {
             default_state++;
-        } else if ((*lease)->state_ == Lease::STATE_DECLINED) {
+        } else if (lease->state_ == Lease::STATE_DECLINED) {
             declined_state++;
         }
     }
@@ -2913,15 +2907,15 @@ GenericLeaseMgrTest::testGetDeclinedLeases6() {
     // This time leases should be returned in the non-reverse order.
     declined_state = 0;
     default_state = 0;
-    for (Lease6Collection::iterator lease = expired_leases.begin();
-         lease != expired_leases.end(); ++lease) {
-        int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
-        EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+    count = 0;
+    for (auto const& lease : expired_leases) {
+        int index = count++;
+        EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
 
         // Count leases in default and declined states
-        if ((*lease)->state_ == Lease::STATE_DEFAULT) {
+        if (lease->state_ == Lease::STATE_DEFAULT) {
             default_state++;
-        } else if ((*lease)->state_ == Lease::STATE_DECLINED) {
+        } else if (lease->state_ == Lease::STATE_DECLINED) {
             declined_state++;
         }
     }
@@ -2940,10 +2934,10 @@ GenericLeaseMgrTest::testGetDeclinedLeases6() {
     ASSERT_EQ(2, expired_leases.size());
 
     // Test that most expired leases have been returned.
-    for (Lease6Collection::iterator lease = expired_leases.begin();
-         lease != expired_leases.end(); ++lease) {
-        int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
-        EXPECT_EQ(leases[2 * index]->addr_, (*lease)->addr_);
+    count = 0;
+    for (auto const& lease : expired_leases) {
+        int index = count++;
+        EXPECT_EQ(leases[2 * index]->addr_, lease->addr_);
     }
 }
 
@@ -2955,7 +2949,7 @@ GenericLeaseMgrTest::checkLeaseStats(const StatValMapList& expectedStats) {
 
     // Iterate over all stats for each subnet
     for (int subnet_idx = 0; subnet_idx < expectedStats.size(); ++subnet_idx) {
-        BOOST_FOREACH(StatValPair expectedStat, expectedStats[subnet_idx]) {
+        for (auto const& expectedStat : expectedStats[subnet_idx]) {
             // Verify the per subnet value.
             checkStat(stats::StatsMgr::generateName("subnet", subnet_idx + 1,
                                                     expectedStat.first),
@@ -3886,9 +3880,9 @@ GenericLeaseMgrTest::checkLeaseRange(const Lease4Collection& returned,
                                      const std::vector<std::string>& expected_addresses) {
     ASSERT_EQ(expected_addresses.size(), returned.size());
 
-    for (auto a = returned.cbegin(); a != returned.cend(); ++a) {
-        EXPECT_EQ(expected_addresses[std::distance(returned.cbegin(), a)],
-                  (*a)->addr_.toText());
+    size_t count = 0;
+    for (auto const& a : returned) {
+        EXPECT_EQ(expected_addresses[count++], a->addr_.toText());
     }
 }
 
index 8d378d0e3109e345fec6df5a3d2cb03ddaebe47a..5be6a2b72dc67a3dcc7b255c2a5bb05ab7f9dbcd 100644 (file)
@@ -8,10 +8,11 @@
 
 #include <dhcpsrv/testutils/host_data_source_utils.h>
 #include <asiolink/io_address.h>
-#include <boost/foreach.hpp>
 #include <cc/data.h>
 #include <gtest/gtest.h>
 
+#include <boost/foreach.hpp>
+
 using namespace std;
 using namespace isc::data;
 using namespace isc::asiolink;
@@ -128,8 +129,8 @@ HostDataSourceUtils::initializeHost6(std::string address,
 bool
 HostDataSourceUtils::reservationExists(const IPv6Resrv& resrv,
                                        const IPv6ResrvRange& range) {
-    for (IPv6ResrvIterator it = range.first; it != range.second; ++it) {
-        if (resrv == it->second) {
+    BOOST_FOREACH(auto const& it, range) {
+        if (resrv == it.second) {
             return true;
         }
     }
@@ -332,7 +333,7 @@ HostDataSourceUtils::compareOptions(const ConstCfgOptionPtr& cfg1,
     EXPECT_EQ(vendor_spaces.size(), cfg1->getVendorIdsSpaceNames().size());
 
     // Iterate over all option spaces existing in cfg2.
-    BOOST_FOREACH (std::string space, option_spaces) {
+    for (auto const& space : option_spaces) {
         // Retrieve options belonging to the current option space.
         OptionContainerPtr options1 = cfg1->getAll(space);
         OptionContainerPtr options2 = cfg2->getAll(space);
@@ -344,7 +345,7 @@ HostDataSourceUtils::compareOptions(const ConstCfgOptionPtr& cfg1,
             << "failed for option space " << space;
 
         // Iterate over all options within this option space.
-        BOOST_FOREACH (OptionDescriptor desc1, *options1) {
+        for (auto const& desc1 : *options1) {
             OptionDescriptor desc2 = cfg2->get(space, desc1.option_->getType());
             // Compare persistent flag.
             EXPECT_EQ(desc1.persistent_, desc2.persistent_)
index ef1b2bcd6413ba6e826c041a96040d6c61c46428..f570a4ac04059c81fbb5caa38bcbaa268f6bb436 100644 (file)
@@ -7,6 +7,7 @@
 #include <config.h>
 
 #include <dhcpsrv/testutils/memory_host_data_source.h>
+#include <boost/foreach.hpp>
 
 using namespace isc::db;
 using namespace std;
@@ -21,14 +22,14 @@ MemHostDataSource::getAll(const Host::IdentifierType& identifier_type,
                           const size_t identifier_len) const {
     vector<uint8_t> ident(identifier_begin, identifier_begin + identifier_len);
     ConstHostCollection hosts;
-    for (auto h = store_.begin(); h != store_.end(); ++h) {
+    for (auto const& h : store_) {
         // If identifier type do not match, it's not for us
-        if ((*h)->getIdentifierType() != identifier_type) {
+        if (h->getIdentifierType() != identifier_type) {
             continue;
         }
         // If the identifier matches, we found one!
-        if ((*h)->getIdentifier() == ident) {
-            hosts.push_back(*h);
+        if (h->getIdentifier() == ident) {
+            hosts.push_back(h);
         }
     }
     return (hosts);
@@ -37,10 +38,10 @@ MemHostDataSource::getAll(const Host::IdentifierType& identifier_type,
 ConstHostCollection
 MemHostDataSource::getAll4(const SubnetID& subnet_id) const {
     ConstHostCollection hosts;
-    for (auto h = store_.begin(); h != store_.end(); ++h) {
+    for (auto const& h : store_) {
         // Keep it when subnet_id matches.
-        if ((*h)->getIPv4SubnetID() == subnet_id) {
-            hosts.push_back(*h);
+        if (h->getIPv4SubnetID() == subnet_id) {
+            hosts.push_back(h);
         }
     }
     return (hosts);
@@ -49,10 +50,10 @@ MemHostDataSource::getAll4(const SubnetID& subnet_id) const {
 ConstHostCollection
 MemHostDataSource::getAll6(const SubnetID& subnet_id) const {
     ConstHostCollection hosts;
-    for (auto h = store_.begin(); h != store_.end(); ++h) {
+    for (auto const& h : store_) {
         // Keep it when subnet_id matches.
-        if ((*h)->getIPv6SubnetID() == subnet_id) {
-            hosts.push_back(*h);
+        if (h->getIPv6SubnetID() == subnet_id) {
+            hosts.push_back(h);
         }
     }
     return (hosts);
@@ -61,10 +62,10 @@ MemHostDataSource::getAll6(const SubnetID& subnet_id) const {
 ConstHostCollection
 MemHostDataSource::getAllbyHostname(const std::string& hostname) const {
     ConstHostCollection hosts;
-    for (auto h = store_.begin(); h != store_.end(); ++h) {
+    for (auto const& h : store_) {
         // Keep it when hostname matches.
-        if ((*h)->getLowerHostname() == hostname) {
-            hosts.push_back(*h);
+        if (h->getLowerHostname() == hostname) {
+            hosts.push_back(h);
         }
     }
     return (hosts);
@@ -74,11 +75,11 @@ ConstHostCollection
 MemHostDataSource::getAllbyHostname4(const std::string& hostname,
                                      const SubnetID& subnet_id) const {
     ConstHostCollection hosts;
-    for (auto h = store_.begin(); h != store_.end(); ++h) {
+    for (auto const& h : store_) {
         // Keep it when hostname and subnet_id match.
-        if (((*h)->getLowerHostname() == hostname) &&
-            ((*h)->getIPv4SubnetID() == subnet_id)) {
-            hosts.push_back(*h);
+        if ((h->getLowerHostname() == hostname) &&
+            (h->getIPv4SubnetID() == subnet_id)) {
+            hosts.push_back(h);
         }
     }
     return (hosts);
@@ -88,11 +89,11 @@ ConstHostCollection
 MemHostDataSource::getAllbyHostname6(const std::string& hostname,
                                      const SubnetID& subnet_id) const {
     ConstHostCollection hosts;
-    for (auto h = store_.begin(); h != store_.end(); ++h) {
+    for (auto const& h : store_) {
         // Keep it when hostname and subnet_id match.
-        if (((*h)->getLowerHostname() == hostname) &&
-            ((*h)->getIPv6SubnetID() == subnet_id)) {
-            hosts.push_back(*h);
+        if ((h->getLowerHostname() == hostname) &&
+            (h->getIPv6SubnetID() == subnet_id)) {
+            hosts.push_back(h);
         }
     }
     return (hosts);
@@ -104,15 +105,15 @@ MemHostDataSource::getPage4(const SubnetID& subnet_id,
                             uint64_t lower_host_id,
                             const HostPageSize& page_size) const {
     ConstHostCollection hosts;
-    for (auto h = store_.begin(); h != store_.end(); ++h) {
+    for (auto const& h : store_) {
         // Skip it when subnet_id does not match.
-        if ((*h)->getIPv4SubnetID() != subnet_id) {
+        if (h->getIPv4SubnetID() != subnet_id) {
             continue;
         }
-        if (lower_host_id && ((*h)->getHostId() <= lower_host_id)) {
+        if (lower_host_id && (h->getHostId() <= lower_host_id)) {
             continue;
         }
-        hosts.push_back(*h);
+        hosts.push_back(h);
         if (hosts.size() == page_size.page_size_) {
             break;
         }
@@ -126,15 +127,15 @@ MemHostDataSource::getPage6(const SubnetID& subnet_id,
                             uint64_t lower_host_id,
                             const HostPageSize& page_size) const {
     ConstHostCollection hosts;
-    for (auto h = store_.begin(); h != store_.end(); ++h) {
+    for (auto const& h : store_) {
         // Skip it when subnet_id does not match.
-        if ((*h)->getIPv6SubnetID() != subnet_id) {
+        if (h->getIPv6SubnetID() != subnet_id) {
             continue;
         }
-        if (lower_host_id && ((*h)->getHostId() <= lower_host_id)) {
+        if (lower_host_id && (h->getHostId() <= lower_host_id)) {
             continue;
         }
-        hosts.push_back(*h);
+        hosts.push_back(h);
         if (hosts.size() == page_size.page_size_) {
             break;
         }
@@ -147,11 +148,11 @@ MemHostDataSource::getPage4(size_t& /*source_index*/,
                             uint64_t lower_host_id,
                             const HostPageSize& page_size) const {
     ConstHostCollection hosts;
-    for (auto h = store_.begin(); h != store_.end(); ++h) {
-        if (lower_host_id && ((*h)->getHostId() <= lower_host_id)) {
+    for (auto const& h : store_) {
+        if (lower_host_id && (h->getHostId() <= lower_host_id)) {
             continue;
         }
-        hosts.push_back(*h);
+        hosts.push_back(h);
         if (hosts.size() == page_size.page_size_) {
             break;
         }
@@ -164,11 +165,11 @@ MemHostDataSource::getPage6(size_t& /*source_index*/,
                             uint64_t lower_host_id,
                             const HostPageSize& page_size) const {
     ConstHostCollection hosts;
-    for (auto h = store_.begin(); h != store_.end(); ++h) {
-        if (lower_host_id && ((*h)->getHostId() <= lower_host_id)) {
+    for (auto const& h : store_) {
+        if (lower_host_id && (h->getHostId() <= lower_host_id)) {
             continue;
         }
-        hosts.push_back(*h);
+        hosts.push_back(h);
         if (hosts.size() == page_size.page_size_) {
             break;
         }
@@ -179,7 +180,7 @@ MemHostDataSource::getPage6(size_t& /*source_index*/,
 ConstHostCollection
 MemHostDataSource::getAll4(const asiolink::IOAddress& address) const {
     ConstHostCollection hosts;
-    for (auto const & h : store_) {
+    for (auto const& h : store_) {
         if (h->getIPv4Reservation() == address) {
             hosts.push_back(h);
         }
@@ -194,16 +195,16 @@ MemHostDataSource::get4(const SubnetID& subnet_id,
                         const uint8_t* identifier_begin,
                         const size_t identifier_len) const {
     vector<uint8_t> ident(identifier_begin, identifier_begin + identifier_len);
-    for (auto h = store_.begin(); h != store_.end(); ++h) {
+    for (auto const& h : store_) {
         // If either subnet-id or identifier type do not match,
         // it's not our host
-        if (((*h)->getIPv4SubnetID() != subnet_id) ||
-            ((*h)->getIdentifierType() != identifier_type)) {
+        if ((h->getIPv4SubnetID() != subnet_id) ||
+            (h->getIdentifierType() != identifier_type)) {
             continue;
         }
         // If the identifier matches, we found it!
-        if ((*h)->getIdentifier() == ident) {
-            return (*h);
+        if (h->getIdentifier() == ident) {
+            return (h);
         }
     }
 
@@ -217,16 +218,16 @@ MemHostDataSource::get6(const SubnetID& subnet_id,
                         const uint8_t* identifier_begin,
                         const size_t identifier_len) const {
     vector<uint8_t> ident(identifier_begin, identifier_begin + identifier_len);
-    for (auto h = store_.begin(); h != store_.end(); ++h) {
+    for (auto const& h : store_) {
         // If either subnet-id or identifier type do not match,
         // it's not our host
-        if (((*h)->getIPv6SubnetID() != subnet_id) ||
-            ((*h)->getIdentifierType() != identifier_type)) {
+        if ((h->getIPv6SubnetID() != subnet_id) ||
+            (h->getIdentifierType() != identifier_type)) {
             continue;
         }
         // If the identifier matches, we found it!
-        if ((*h)->getIdentifier() == ident) {
-            return (*h);
+        if (h->getIdentifier() == ident) {
+            return (h);
         }
     }
 
@@ -236,10 +237,10 @@ MemHostDataSource::get6(const SubnetID& subnet_id,
 ConstHostPtr
 MemHostDataSource::get4(const SubnetID& subnet_id,
                         const asiolink::IOAddress& address) const {
-    for (auto h = store_.begin(); h != store_.end(); ++h) {
-        if ((*h)->getIPv4SubnetID() == subnet_id &&
-            (*h)->getIPv4Reservation() == address) {
-            return (*h);
+    for (auto const& h : store_) {
+        if (h->getIPv4SubnetID() == subnet_id &&
+            h->getIPv4Reservation() == address) {
+            return (h);
         }
     }
 
@@ -250,7 +251,7 @@ ConstHostCollection
 MemHostDataSource::getAll4(const SubnetID& subnet_id,
                            const asiolink::IOAddress& address) const {
     ConstHostCollection hosts;
-    for (auto const & h : store_) {
+    for (auto const& h : store_) {
         if (h->getIPv4SubnetID() == subnet_id &&
             h->getIPv4Reservation() == address) {
             hosts.push_back(h);
@@ -269,22 +270,22 @@ MemHostDataSource::get6(const asiolink::IOAddress& /*prefix*/,
 ConstHostPtr
 MemHostDataSource::get6(const SubnetID& subnet_id,
                         const asiolink::IOAddress& address) const {
-    for (auto h = store_.begin(); h != store_.end(); ++h) {
+    for (auto const& h : store_) {
 
         // Naive approach: check hosts one by one
 
         // First check: subnet-id must match.
-        if ((*h)->getIPv6SubnetID() != subnet_id) {
+        if (h->getIPv6SubnetID() != subnet_id) {
             // wrong subnet-id? ok, skip this one
             continue;
         }
 
         // Second check: the v6 reservation must much. This is very simple
         // as we ignore the reservation type.
-        auto resrvs = (*h)->getIPv6Reservations();
-        for (auto r = resrvs.first; r != resrvs.second; ++r) {
-            if ((*r).second.getPrefix() == address) {
-                return (*h);
+        auto const& resrvs = h->getIPv6Reservations();
+        BOOST_FOREACH(auto const& r, resrvs) {
+            if (r.second.getPrefix() == address) {
+                return (h);
             }
         }
     }
@@ -296,14 +297,14 @@ ConstHostCollection
 MemHostDataSource::getAll6(const SubnetID& subnet_id,
                            const asiolink::IOAddress& address) const {
     ConstHostCollection hosts;
-    for (auto const & h : store_) {
+    for (auto const& h : store_) {
         if (h->getIPv6SubnetID() != subnet_id) {
             continue;
         }
 
-        auto resrvs = h->getIPv6Reservations();
-        for (auto r = resrvs.first; r != resrvs.second; ++r) {
-            if ((*r).second.getPrefix() == address) {
+        auto const& resrvs = h->getIPv6Reservations();
+        BOOST_FOREACH(auto const& r, resrvs) {
+            if (r.second.getPrefix() == address) {
                 hosts.push_back(h);
             }
         }
@@ -315,10 +316,10 @@ MemHostDataSource::getAll6(const SubnetID& subnet_id,
 ConstHostCollection
 MemHostDataSource::getAll6(const asiolink::IOAddress& address) const {
     ConstHostCollection hosts;
-    for (auto const & h : store_) {
-        auto resrvs = h->getIPv6Reservations();
-        for (auto r = resrvs.first; r != resrvs.second; ++r) {
-            if ((*r).second.getPrefix() == address) {
+    for (auto const& h : store_) {
+        auto const& resrvs = h->getIPv6Reservations();
+        BOOST_FOREACH(auto const& r, resrvs) {
+            if (r.second.getPrefix() == address) {
                 hosts.push_back(h);
             }
         }
@@ -351,9 +352,9 @@ MemHostDataSource::del(const SubnetID& subnet_id,
 
             // Second check: the v6 reservation must much. This is very simple
             // as we ignore the reservation type.
-            auto resrvs = (*h)->getIPv6Reservations();
-            for (auto r = resrvs.first; r != resrvs.second; ++r) {
-                if ((*r).second.getPrefix() == addr) {
+            auto const& resrvs = (*h)->getIPv6Reservations();
+            BOOST_FOREACH(auto const& r, resrvs) {
+                if (r.second.getPrefix() == addr) {
                     store_.erase(h);
                     return (true);
                 }
index 98be2a13377909333f16617a8be6129fa0d2d969..51adf520fe0dfea73ee60ce87ae4bfd9ffb3c855 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <database/database_connection.h>
 #include <test_config_backend_dhcp4.h>
+#include <boost/foreach.hpp>
 #include <list>
 
 using namespace isc::data;
@@ -296,17 +297,15 @@ TestConfigBackendDHCPv4::getOptionDef4(const db::ServerSelector& server_selector
     auto const& index = option_defs_.get<1>();
     auto option_def_it_pair = index.equal_range(code);
 
-    for (auto option_def_it = option_def_it_pair.first;
-         option_def_it != option_def_it_pair.second;
-         ++option_def_it) {
-        if ((*option_def_it)->getOptionSpaceName() == space) {
+    BOOST_FOREACH(auto const& option_def_it, option_def_it_pair) {
+        if (option_def_it->getOptionSpaceName() == space) {
             for (auto const& tag : tags) {
-                if ((*option_def_it)->hasServerTag(ServerTag(tag))) {
-                    return (*option_def_it);
+                if (option_def_it->hasServerTag(ServerTag(tag))) {
+                    return (option_def_it);
                 }
             }
-            if ((*option_def_it)->hasAllServerTag()) {
-                candidate = *option_def_it;
+            if (option_def_it->hasAllServerTag()) {
+                candidate = option_def_it;
             }
         }
     }
@@ -378,16 +377,15 @@ TestConfigBackendDHCPv4::getOption4(const db::ServerSelector& server_selector,
     auto const& index = options_.get<1>();
     auto option_it_pair = index.equal_range(code);
 
-    for (auto option_it = option_it_pair.first; option_it != option_it_pair.second;
-         ++option_it) {
-        if (option_it->space_name_ == space) {
+    BOOST_FOREACH(auto const& option_it, option_it_pair) {
+        if (option_it.space_name_ == space) {
             for (auto const& tag : tags) {
-                if (option_it->hasServerTag(ServerTag(tag))) {
-                    return (OptionDescriptorPtr(new OptionDescriptor(*option_it)));
+                if (option_it.hasServerTag(ServerTag(tag))) {
+                    return (OptionDescriptorPtr(new OptionDescriptor(option_it)));
                 }
             }
-            if (option_it->hasAllServerTag()) {
-                candidate = OptionDescriptorPtr(new OptionDescriptor(*option_it));
+            if (option_it.hasAllServerTag()) {
+                candidate = OptionDescriptorPtr(new OptionDescriptor(option_it));
             }
         }
     }
@@ -451,15 +449,14 @@ TestConfigBackendDHCPv4::getGlobalParameter4(const db::ServerSelector& server_se
     auto candidate = StampedValuePtr();
     auto const& index = globals_.get<StampedValueNameIndexTag>();
     auto global_range = index.equal_range(name);
-    for (auto global_it = global_range.first; global_it != global_range.second;
-         ++global_it) {
+    BOOST_FOREACH(auto const& global_it, global_range) {
         for (auto const& tag : tags) {
-            if ((*global_it)->hasServerTag(ServerTag(tag))) {
-                return (*global_it);
+            if (global_it->hasServerTag(ServerTag(tag))) {
+                return (global_it);
             }
         }
-        if ((*global_it)->hasAllServerTag()) {
-            candidate = *global_it;
+        if (global_it->hasAllServerTag()) {
+            candidate = global_it;
         }
     }
 
@@ -1091,9 +1088,9 @@ TestConfigBackendDHCPv4::deleteSharedNetwork4(const db::ServerSelector& server_s
     }
 
     // Remove this shared network.
-    for (auto subnet = subnets_.begin(); subnet != subnets_.end(); ++subnet) {
-        if ((*subnet)->getSharedNetworkName() == name) {
-            (*subnet)->setSharedNetworkName("");
+    for (auto const& subnet : subnets_) {
+        if (subnet->getSharedNetworkName() == name) {
+            subnet->setSharedNetworkName("");
         }
     }
     (*network_it)->delAll();
index 9a3fe1d6d7fbeca8fb45095ea156a932f77a1ff8..c31b14745b529e9e796ecf894d9b17befa718913 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <database/database_connection.h>
 #include <test_config_backend_dhcp6.h>
+#include <boost/foreach.hpp>
 
 using namespace isc::data;
 using namespace isc::db;
@@ -48,7 +49,7 @@ TestConfigBackendDHCPv6::getSubnet6(const db::ServerSelector& server_selector,
     if (server_selector.amUnassigned()) {
         return (subnet->getServerTags().empty() ? subnet : Subnet6Ptr());
     }
-    auto tags = server_selector.getTags();
+    auto const& tags = server_selector.getTags();
     for (auto const& tag : tags) {
         if (subnet->hasServerTag(ServerTag(tag))) {
             return (subnet);
@@ -72,7 +73,7 @@ TestConfigBackendDHCPv6::getSubnet6(const db::ServerSelector& server_selector,
     if (server_selector.amUnassigned()) {
         return (subnet->getServerTags().empty() ? subnet : Subnet6Ptr());
     }
-    auto tags = server_selector.getTags();
+    auto const& tags = server_selector.getTags();
     for (auto const& tag : tags) {
         if (subnet->hasServerTag(ServerTag(tag))) {
             return (subnet);
@@ -96,7 +97,7 @@ TestConfigBackendDHCPv6::getAllSubnets6(const db::ServerSelector& server_selecto
             continue;
         }
         bool got = false;
-        auto tags = server_selector.getTags();
+        auto const& tags = server_selector.getTags();
         for (auto const& tag : tags) {
             if (subnet->hasServerTag(ServerTag(tag))) {
                 subnets.insert(subnet);
@@ -132,7 +133,7 @@ TestConfigBackendDHCPv6::getModifiedSubnets6(const db::ServerSelector& server_se
             continue;
         }
         bool got = false;
-        auto tags = server_selector.getTags();
+        auto const& tags = server_selector.getTags();
         for (auto const& tag : tags) {
             if ((*subnet)->hasServerTag(ServerTag(tag))) {
                 subnets.insert(*subnet);
@@ -166,7 +167,7 @@ TestConfigBackendDHCPv6::getSharedNetworkSubnets6(const db::ServerSelector& serv
         }
         if (!server_selector.amAny()) {
             bool got = false;
-            auto tags = server_selector.getTags();
+            auto const& tags = server_selector.getTags();
             for (auto const& tag : tags) {
                 if (subnet->hasServerTag(ServerTag(tag))) {
                     got = true;
@@ -208,7 +209,7 @@ TestConfigBackendDHCPv6::getSharedNetwork6(const db::ServerSelector& server_sele
     if (server_selector.amUnassigned()) {
         return (network->getServerTags().empty() ? network : SharedNetwork6Ptr());
     }
-    auto tags = server_selector.getTags();
+    auto const& tags = server_selector.getTags();
     for (auto const& tag : tags) {
         if (network->hasServerTag(ServerTag(tag))) {
             return (network);
@@ -232,7 +233,7 @@ TestConfigBackendDHCPv6::getAllSharedNetworks6(const db::ServerSelector& server_
             continue;
         }
         bool got = false;
-        auto tags = server_selector.getTags();
+        auto const& tags = server_selector.getTags();
         for (auto const& tag : tags) {
             if (shared_network->hasServerTag(ServerTag(tag))) {
                 shared_networks.push_back(shared_network);
@@ -268,7 +269,7 @@ TestConfigBackendDHCPv6::getModifiedSharedNetworks6(const db::ServerSelector& se
             continue;
         }
         bool got = false;
-        auto tags = server_selector.getTags();
+        auto const& tags = server_selector.getTags();
         for (auto const& tag : tags) {
             if ((*shared_network)->hasServerTag(ServerTag(tag))) {
                 shared_networks.push_back(*shared_network);
@@ -290,22 +291,20 @@ OptionDefinitionPtr
 TestConfigBackendDHCPv6::getOptionDef6(const db::ServerSelector& server_selector,
                                        const uint16_t code,
                                        const std::string& space) const {
-    auto tags = server_selector.getTags();
+    auto const& tags = server_selector.getTags();
     auto candidate = OptionDefinitionPtr();
     auto const& index = option_defs_.get<1>();
     auto option_def_it_pair = index.equal_range(code);
 
-    for (auto option_def_it = option_def_it_pair.first;
-         option_def_it != option_def_it_pair.second;
-         ++option_def_it) {
-        if ((*option_def_it)->getOptionSpaceName() == space) {
+    BOOST_FOREACH(auto const& option_def_it, option_def_it_pair) {
+        if (option_def_it->getOptionSpaceName() == space) {
             for (auto const& tag : tags) {
-                if ((*option_def_it)->hasServerTag(ServerTag(tag))) {
-                    return (*option_def_it);
+                if (option_def_it->hasServerTag(ServerTag(tag))) {
+                    return (option_def_it);
                 }
             }
-            if ((*option_def_it)->hasAllServerTag()) {
-                candidate = *option_def_it;
+            if (option_def_it->hasAllServerTag()) {
+                candidate = option_def_it;
             }
         }
     }
@@ -314,7 +313,7 @@ TestConfigBackendDHCPv6::getOptionDef6(const db::ServerSelector& server_selector
 
 OptionDefContainer
 TestConfigBackendDHCPv6::getAllOptionDefs6(const db::ServerSelector& server_selector) const {
-    auto tags = server_selector.getTags();
+    auto const& tags = server_selector.getTags();
     OptionDefContainer option_defs;
     for (auto const& option_def : option_defs_) {
         bool got = false;
@@ -345,7 +344,7 @@ TestConfigBackendDHCPv6::getAllOptionDefs6(const db::ServerSelector& server_sele
 OptionDefContainer
 TestConfigBackendDHCPv6::getModifiedOptionDefs6(const db::ServerSelector& server_selector,
                                                 const boost::posix_time::ptime& modification_time) const {
-    auto tags = server_selector.getTags();
+    auto const& tags = server_selector.getTags();
     OptionDefContainer option_defs;
     auto const& index = option_defs_.get<3>();
     auto lb = index.lower_bound(modification_time);
@@ -372,21 +371,20 @@ OptionDescriptorPtr
 TestConfigBackendDHCPv6::getOption6(const db::ServerSelector& server_selector,
                                     const uint16_t code,
                                     const std::string& space) const {
-    auto tags = server_selector.getTags();
+    auto const& tags = server_selector.getTags();
     auto candidate = OptionDescriptorPtr();
     auto const& index = options_.get<1>();
     auto option_it_pair = index.equal_range(code);
 
-    for (auto option_it = option_it_pair.first; option_it != option_it_pair.second;
-         ++option_it) {
-        if (option_it->space_name_ == space) {
+    BOOST_FOREACH(auto const& option_it, option_it_pair) {
+        if (option_it.space_name_ == space) {
             for (auto const& tag : tags) {
-                if (option_it->hasServerTag(ServerTag(tag))) {
-                    return (OptionDescriptorPtr(new OptionDescriptor(*option_it)));
+                if (option_it.hasServerTag(ServerTag(tag))) {
+                    return (OptionDescriptorPtr(new OptionDescriptor(option_it)));
                 }
             }
-            if (option_it->hasAllServerTag()) {
-                candidate = OptionDescriptorPtr(new OptionDescriptor(*option_it));
+            if (option_it.hasAllServerTag()) {
+                candidate = OptionDescriptorPtr(new OptionDescriptor(option_it));
             }
         }
     }
@@ -396,7 +394,7 @@ TestConfigBackendDHCPv6::getOption6(const db::ServerSelector& server_selector,
 
 OptionContainer
 TestConfigBackendDHCPv6::getAllOptions6(const db::ServerSelector& server_selector) const {
-    auto tags = server_selector.getTags();
+    auto const& tags = server_selector.getTags();
     OptionContainer options;
     for (auto const& option : options_) {
         bool got = false;
@@ -420,7 +418,7 @@ TestConfigBackendDHCPv6::getAllOptions6(const db::ServerSelector& server_selecto
 OptionContainer
 TestConfigBackendDHCPv6::getModifiedOptions6(const db::ServerSelector& server_selector,
                                              const boost::posix_time::ptime& modification_time) const {
-    auto tags = server_selector.getTags();
+    auto const& tags = server_selector.getTags();
     OptionContainer options;
     auto const& index = options_.get<3>();
     auto lb = index.lower_bound(modification_time);
@@ -446,19 +444,18 @@ TestConfigBackendDHCPv6::getModifiedOptions6(const db::ServerSelector& server_se
 StampedValuePtr
 TestConfigBackendDHCPv6::getGlobalParameter6(const db::ServerSelector& server_selector,
                                              const std::string& name) const {
-    auto tags = server_selector.getTags();
+    auto const& tags = server_selector.getTags();
     auto candidate = StampedValuePtr();
     auto const& index = globals_.get<StampedValueNameIndexTag>();
     auto global_range = index.equal_range(name);
-    for (auto global_it = global_range.first; global_it != global_range.second;
-         ++global_it) {
+    BOOST_FOREACH(auto const& global_it, global_range) {
         for (auto const& tag : tags) {
-            if ((*global_it)->hasServerTag(ServerTag(tag))) {
-                return (*global_it);
+            if (global_it->hasServerTag(ServerTag(tag))) {
+                return (global_it);
             }
         }
-        if ((*global_it)->hasAllServerTag()) {
-            candidate = *global_it;
+        if (global_it->hasAllServerTag()) {
+            candidate = global_it;
         }
     }
 
@@ -468,7 +465,7 @@ TestConfigBackendDHCPv6::getGlobalParameter6(const db::ServerSelector& server_se
 
 StampedValueCollection
 TestConfigBackendDHCPv6::getAllGlobalParameters6(const db::ServerSelector& server_selector) const {
-    auto tags = server_selector.getTags();
+    auto const& tags = server_selector.getTags();
     StampedValueCollection globals;
     for (auto const& global : globals_) {
         bool got = false;
@@ -492,7 +489,7 @@ TestConfigBackendDHCPv6::getAllGlobalParameters6(const db::ServerSelector& serve
 StampedValueCollection
 TestConfigBackendDHCPv6::getModifiedGlobalParameters6(const db::ServerSelector& server_selector,
                                                       const boost::posix_time::ptime& modification_time) const {
-    auto tags = server_selector.getTags();
+    auto const& tags = server_selector.getTags();
     StampedValueCollection globals;
     auto const& index = globals_.get<StampedValueModificationTimeIndexTag>();
     auto lb = index.lower_bound(modification_time);
@@ -531,7 +528,7 @@ TestConfigBackendDHCPv6::getClientClass6(const db::ServerSelector& server_select
     if (server_selector.amUnassigned()) {
         return (client_class->getServerTags().empty() ? client_class : ClientClassDefPtr());
     }
-    auto tags = server_selector.getTags();
+    auto const& tags = server_selector.getTags();
     for (auto const& tag : tags) {
         if (client_class->hasServerTag(ServerTag(tag))) {
             return (client_class);
@@ -542,7 +539,7 @@ TestConfigBackendDHCPv6::getClientClass6(const db::ServerSelector& server_select
 
 ClientClassDictionary
 TestConfigBackendDHCPv6::getAllClientClasses6(const db::ServerSelector& server_selector) const {
-    auto tags = server_selector.getTags();
+    auto const& tags = server_selector.getTags();
     ClientClassDictionary all_classes;
     for (auto const& client_class : classes_) {
         if (server_selector.amAny()) {
@@ -576,7 +573,7 @@ TestConfigBackendDHCPv6::getAllClientClasses6(const db::ServerSelector& server_s
 ClientClassDictionary
 TestConfigBackendDHCPv6::getModifiedClientClasses6(const db::ServerSelector& server_selector,
                                                    const boost::posix_time::ptime& modification_time) const {
-    auto tags = server_selector.getTags();
+    auto const& tags = server_selector.getTags();
     ClientClassDictionary modified_classes;
     for (auto const& client_class : classes_) {
         if (client_class->getModificationTime() >= modification_time) {
@@ -695,7 +692,7 @@ TestConfigBackendDHCPv6::createUpdateSharedNetwork6(const db::ServerSelector& se
 void
 TestConfigBackendDHCPv6::createUpdateOptionDef6(const db::ServerSelector& server_selector,
                                                 const OptionDefinitionPtr& option_def) {
-    auto tag = getServerTag(server_selector);
+    auto const& tag = getServerTag(server_selector);
     option_def->setServerTag(tag);
 
     // Index #1 is by option code.
@@ -734,7 +731,7 @@ TestConfigBackendDHCPv6::createUpdateOptionDef6(const db::ServerSelector& server
 void
 TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_selector,
                                              const OptionDescriptorPtr& option) {
-    auto tag = getServerTag(server_selector);
+    auto const& tag = getServerTag(server_selector);
     option->setServerTag(tag);
 
     auto& index = options_.get<1>();
@@ -776,7 +773,7 @@ TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_se
     } else if (shared_network->hasAllServerTag()) {
         found = true;
     } else {
-        auto tags = server_selector.getTags();
+        auto const& tags = server_selector.getTags();
         for (auto const& tag : tags) {
             if (shared_network->hasServerTag(ServerTag(tag))) {
                 found = true;
@@ -817,7 +814,7 @@ TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_se
     } else if (subnet->hasAllServerTag()) {
         found = true;
     } else {
-        auto tags = server_selector.getTags();
+        auto const& tags = server_selector.getTags();
         for (auto const& tag : tags) {
             if (subnet->hasServerTag(ServerTag(tag))) {
                 found = true;
@@ -856,7 +853,7 @@ TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_se
             }
         } else if (!server_selector.amAny() && !subnet->hasAllServerTag()) {
             auto in_tags = false;
-            auto tags = server_selector.getTags();
+            auto const& tags = server_selector.getTags();
             for (auto const& tag : tags) {
                 if (subnet->hasServerTag(ServerTag(tag))) {
                     in_tags = true;
@@ -910,7 +907,7 @@ TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_se
             }
         } else if (!server_selector.amAny() && !subnet->hasAllServerTag()) {
             auto in_tags = false;
-            auto tags = server_selector.getTags();
+            auto const& tags = server_selector.getTags();
             for (auto const& tag : tags) {
                 if (subnet->hasServerTag(ServerTag(tag))) {
                     in_tags = true;
@@ -946,7 +943,7 @@ TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_se
 void
 TestConfigBackendDHCPv6::createUpdateGlobalParameter6(const db::ServerSelector& server_selector,
                                                       const data::StampedValuePtr& value) {
-    auto tag = getServerTag(server_selector);
+    auto const& tag = getServerTag(server_selector);
     value->setServerTag(tag);
 
     auto& index = globals_.get<StampedValueNameIndexTag>();
@@ -991,7 +988,7 @@ TestConfigBackendDHCPv6::deleteSubnet6(const db::ServerSelector& server_selector
     }
     if (!server_selector.amAny()) {
         bool got = false;
-        auto tags = server_selector.getTags();
+        auto const& tags = server_selector.getTags();
         for (auto const& tag : tags) {
             if ((*subnet_it)->hasServerTag(ServerTag(tag))) {
                 got = true;
@@ -1019,7 +1016,7 @@ TestConfigBackendDHCPv6::deleteSubnet6(const db::ServerSelector& server_selector
     }
     if (!server_selector.amAny()) {
         bool got = false;
-        auto tags = server_selector.getTags();
+        auto const& tags = server_selector.getTags();
         for (auto const& tag : tags) {
             if ((*subnet_it)->hasServerTag(ServerTag(tag))) {
                 got = true;
@@ -1049,7 +1046,7 @@ TestConfigBackendDHCPv6::deleteAllSubnets6(const db::ServerSelector& server_sele
             continue;
         }
         bool got = false;
-        auto tags = server_selector.getTags();
+        auto const& tags = server_selector.getTags();
         for (auto const& tag : tags) {
             if (subnet->hasServerTag(ServerTag(tag))) {
                 ids.push_back(subnet->getID());
@@ -1087,7 +1084,7 @@ TestConfigBackendDHCPv6::deleteSharedNetworkSubnets6(const db::ServerSelector& s
         }
         if (!server_selector.amAny()) {
             bool got = false;
-            auto tags = server_selector.getTags();
+            auto const& tags = server_selector.getTags();
             for (auto const& tag : tags) {
                 if ((*subnet)->hasServerTag(ServerTag(tag))) {
                     got = true;
@@ -1131,7 +1128,7 @@ TestConfigBackendDHCPv6::deleteSharedNetwork6(const db::ServerSelector& server_s
     }
     if (!server_selector.amAny()) {
         bool got = false;
-        auto tags = server_selector.getTags();
+        auto const& tags = server_selector.getTags();
         for (auto const& tag : tags) {
             if ((*network_it)->hasServerTag(ServerTag(tag))) {
                 got = true;
@@ -1144,9 +1141,9 @@ TestConfigBackendDHCPv6::deleteSharedNetwork6(const db::ServerSelector& server_s
     }
 
     // Remove this shared network.
-    for (auto subnet = subnets_.begin(); subnet != subnets_.end(); ++subnet) {
-        if ((*subnet)->getSharedNetworkName() == name) {
-            (*subnet)->setSharedNetworkName("");
+    for (auto const& subnet : subnets_) {
+        if (subnet->getSharedNetworkName() == name) {
+            subnet->setSharedNetworkName("");
         }
     }
     (*network_it)->delAll();
@@ -1169,7 +1166,7 @@ TestConfigBackendDHCPv6::deleteAllSharedNetworks6(const db::ServerSelector& serv
             continue;
         }
         bool got = false;
-        auto tags = server_selector.getTags();
+        auto const& tags = server_selector.getTags();
         for (auto const& tag : tags) {
             if (shared_network->hasServerTag(ServerTag(tag))) {
                 names.push_back(shared_network->getName());
@@ -1198,7 +1195,7 @@ uint64_t
 TestConfigBackendDHCPv6::deleteOptionDef6(const db::ServerSelector& server_selector,
                                           const uint16_t code,
                                           const std::string& space) {
-    auto tag = getServerTag(server_selector);
+    auto const& tag = getServerTag(server_selector);
     uint64_t erased = 0;
     for (auto option_def_it = option_defs_.begin(); option_def_it != option_defs_.end(); ) {
         if (((*option_def_it)->getCode() == code) &&
@@ -1215,7 +1212,7 @@ TestConfigBackendDHCPv6::deleteOptionDef6(const db::ServerSelector& server_selec
 
 uint64_t
 TestConfigBackendDHCPv6::deleteAllOptionDefs6(const db::ServerSelector& server_selector) {
-    auto tag = getServerTag(server_selector);
+    auto const& tag = getServerTag(server_selector);
     uint64_t erased = 0;
     for (auto option_def_it = option_defs_.begin(); option_def_it != option_defs_.end(); ) {
         if ((*option_def_it)->hasServerTag(ServerTag(tag))) {
@@ -1232,7 +1229,7 @@ uint64_t
 TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector,
                                        const uint16_t code,
                                        const std::string& space) {
-    auto tag = getServerTag(server_selector);
+    auto const& tag = getServerTag(server_selector);
     uint64_t erased = 0;
     for (auto option_it = options_.begin(); option_it != options_.end(); ) {
         if ((option_it->option_->getType() == code) &&
@@ -1271,7 +1268,7 @@ TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector
     } else if (shared_network->hasAllServerTag()) {
         found = true;
     } else {
-        auto tags = server_selector.getTags();
+        auto const& tags = server_selector.getTags();
         for (auto const& tag : tags) {
             if (shared_network->hasServerTag(ServerTag(tag))) {
                 found = true;
@@ -1312,7 +1309,7 @@ TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector
     } else if (subnet->hasAllServerTag()) {
         found = true;
     } else {
-        auto tags = server_selector.getTags();
+        auto const& tags = server_selector.getTags();
         for (auto const& tag : tags) {
             if (subnet->hasServerTag(ServerTag(tag))) {
                 found = true;
@@ -1352,7 +1349,7 @@ TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector
             }
         } else if (!server_selector.amAny() && !subnet->hasAllServerTag()) {
             auto in_tags = false;
-            auto tags = server_selector.getTags();
+            auto const& tags = server_selector.getTags();
             for (auto const& tag : tags) {
                 if (subnet->hasServerTag(ServerTag(tag))) {
                     in_tags = true;
@@ -1401,7 +1398,7 @@ TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector
             }
         } else if (!server_selector.amAny() && !subnet->hasAllServerTag()) {
             auto in_tags = false;
-            auto tags = server_selector.getTags();
+            auto const& tags = server_selector.getTags();
             for (auto const& tag : tags) {
                 if (subnet->hasServerTag(ServerTag(tag))) {
                     in_tags = true;
@@ -1433,7 +1430,7 @@ TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector
 uint64_t
 TestConfigBackendDHCPv6::deleteGlobalParameter6(const db::ServerSelector& server_selector,
                                                 const std::string& name) {
-    auto tag = getServerTag(server_selector);
+    auto const& tag = getServerTag(server_selector);
     auto& index = globals_.get<StampedValueNameIndexTag>();
     auto global_it_pair = index.equal_range(name);
 
@@ -1450,7 +1447,7 @@ TestConfigBackendDHCPv6::deleteGlobalParameter6(const db::ServerSelector& server
 
 uint64_t
 TestConfigBackendDHCPv6::deleteAllGlobalParameters6(const db::ServerSelector& server_selector) {
-    auto tag = getServerTag(server_selector);
+    auto const& tag = getServerTag(server_selector);
     uint64_t cnt = 0;
     for (auto global_it = globals_.begin(); global_it != globals_.end(); ) {
         auto value = *global_it;
@@ -1484,7 +1481,7 @@ TestConfigBackendDHCPv6::deleteClientClass6(const db::ServerSelector& server_sel
     }
     if (!server_selector.amAny()) {
         bool got = false;
-        auto tags = server_selector.getTags();
+        auto const& tags = server_selector.getTags();
         for (auto const& tag : tags) {
             if (existing_class->hasServerTag(ServerTag(tag))) {
                 got = true;
@@ -1517,8 +1514,8 @@ TestConfigBackendDHCPv6::deleteAllClientClasses6(const db::ServerSelector& serve
             continue;
         }
         bool got = false;
-        auto tags = server_selector.getTags();
-        for (auto tag : tags) {
+        auto const& tags = server_selector.getTags();
+        for (auto const& tag : tags) {
             if (client_class->hasServerTag(ServerTag(tag))) {
                 c = classes_.erase(c);
                 ++count;
index cc4005b1770e9d385c5b2bb4ae756edee7cba98b..e5adce66efddd1f724154d64cd15893b3177a7ad 100644 (file)
@@ -334,9 +334,8 @@ TimerMgrImpl::unregisterTimersInternal() {
     TimerInfoMap registered_timers_copy(registered_timers_);
 
     // Iterate over the existing timers and unregister them.
-    for (TimerInfoMap::iterator timer_info_it = registered_timers_copy.begin();
-         timer_info_it != registered_timers_copy.end(); ++timer_info_it) {
-        unregisterTimerInternal(timer_info_it->first);
+    for (auto const& timer_info_it : registered_timers_copy) {
+        unregisterTimerInternal(timer_info_it.first);
     }
 }
 
index 35c8192b474b3cc4fd5cbbcd378e3afc966d94c2..2424e2642af701326b59a77c31df49e13fda59b3 100644 (file)
@@ -10,6 +10,7 @@
 #include <dhcpsrv/dhcpsrv_log.h>
 #include <dhcpsrv/tracking_lease_mgr.h>
 #include <util/multi_threading_mgr.h>
+#include <boost/foreach.hpp>
 #include <boost/tuple/tuple.hpp>
 
 using namespace isc::asiolink;
@@ -139,8 +140,7 @@ TrackingLeaseMgr::runCallbacksForSubnetID(CallbackType type, SubnetID subnet_id,
     if (cbs.first == cbs.second) {
         return;
     }
-    for (auto it = cbs.first; it != cbs.second; ++it) {
-        auto cb = *it;
+    BOOST_FOREACH(auto const& cb, cbs) {
         try {
             cb.fn(lease);
         } catch (const std::exception& ex) {
index 0d1292e0c30889ee76b2eb7c9bbaaea5500dbc32..a9fa83591fb0caa61425b3b5de80feb881cc63e4 100644 (file)
@@ -12,7 +12,6 @@
 #include <dns/master_lexer_inputsource.h>
 #include <dns/master_lexer_state.h>
 
-#include <boost/foreach.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/lexical_cast.hpp>
 
@@ -213,7 +212,7 @@ MasterLexer::getTotalSourceSize() const {
 size_t
 MasterLexer::getPosition() const {
     size_t position = impl_->popped_size_;
-    BOOST_FOREACH(InputSourcePtr& src, impl_->sources_) {
+    for (auto const& src : impl_->sources_) {
         position += src->getPosition();
     }
     return (position);
index 568fdea507bd77787d6742de5e75f186bb5a40ba..c1ed91a09448c054322f93be249c8362c35d3124 100644 (file)
@@ -638,7 +638,7 @@ MasterLoader::MasterLoaderImpl::generateForIter(const std::string& str,
 {
   std::string rstr;
 
-  for (std::string::const_iterator it = str.begin(); it != str.end();) {
+  for (auto it = str.begin(); it != str.end();) {
       switch (*it) {
       case '$':
           // This is the case when the '$' character is encountered in
index fe05a3e588ca6cb61f4a5794f1465cdd2346041e..4fb105b477823fa5ce8a2d807cc53c4e9f1a2bd3 100644 (file)
@@ -14,7 +14,6 @@
 #include <sstream>
 #include <vector>
 
-#include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/shared_ptr.hpp>
 
@@ -527,7 +526,7 @@ Message::hasRRset(const Section section, const Name& name,
         isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
     }
 
-    BOOST_FOREACH(ConstRRsetPtr r, impl_->rrsets_[section]) {
+    for (auto const& r : impl_->rrsets_[section]) {
         if (r->getClass() == rrclass &&
             r->getType() == rrtype &&
             r->getName() == name) {
@@ -551,8 +550,7 @@ Message::removeRRset(const Section section, RRsetIterator& iterator) {
     }
 
     bool removed = false;
-    for (vector<RRsetPtr>::iterator i = impl_->rrsets_[section].begin();
-            i != impl_->rrsets_[section].end(); ++i) {
+    for (auto i = impl_->rrsets_[section].begin(); i != impl_->rrsets_[section].end(); ++i) {
         if (((*i)->getName() == (*iterator)->getName()) &&
             ((*i)->getClass() == (*iterator)->getClass()) &&
             ((*i)->getType() == (*iterator)->getType())) {
@@ -1001,15 +999,11 @@ Message::appendSection(const Section section, const Message& source) {
     }
 
     if (section == SECTION_QUESTION) {
-        for (QuestionIterator qi = source.beginQuestion();
-             qi != source.endQuestion();
-             ++qi) {
+        for (auto qi = source.beginQuestion(); qi != source.endQuestion(); ++qi) {
             addQuestion(*qi);
         }
     } else {
-        for (RRsetIterator rrsi = source.beginSection(section);
-             rrsi != source.endSection(section);
-             ++rrsi) {
+        for (auto rrsi = source.beginSection(section); rrsi != source.endSection(section); ++rrsi) {
             addRRset(section, *rrsi);
         }
     }
index 3f75fa00642a33bf79a1ca988ac4ea092e3baf0d..cec88f03d202e3d0295a3afae2f9309f1f0094c3 100644 (file)
@@ -359,8 +359,7 @@ Name::Name(const char* namedata, size_t data_len, const Name* origin,
         size_t offset_count = offsets_.size();
         offsets_.insert(offsets_.end(), origin->offsets_.begin(),
                         origin->offsets_.end());
-        for (NameOffsets::iterator it(offsets_.begin() + offset_count);
-             it != offsets_.end(); ++it) {
+        for (auto it(offsets_.begin() + offset_count); it != offsets_.end(); ++it) {
             *it += offset;
         }
 
index 8eee8c0edc31db2117e233c0e652f44003751fcb..485eba395af64611e4429bb33d455f70f67b5357 100644 (file)
@@ -123,9 +123,13 @@ stringToCharStringData(const MasterToken::StringRegion& str_region,
 std::string
 charStringToString(const CharString& char_string) {
     std::string s;
-    for (CharString::const_iterator it = char_string.begin() + 1;
-         it != char_string.end(); ++it) {
-        const uint8_t ch = *it;
+    bool first = true;
+    for (auto const& it : char_string) {
+        if (first) {
+            first = false;
+            continue;
+        }
+        const uint8_t ch = it;
         if ((ch < 0x20) || (ch >= 0x7f)) {
             // convert to escaped \xxx (decimal) format
             s.push_back('\\');
@@ -146,9 +150,8 @@ charStringToString(const CharString& char_string) {
 std::string
 charStringDataToString(const CharStringData& char_string) {
     std::string s;
-    for (CharString::const_iterator it = char_string.begin();
-         it != char_string.end(); ++it) {
-        const uint8_t ch = *it;
+    for (auto const& it : char_string) {
+        const uint8_t ch = it;
         if ((ch < 0x20) || (ch >= 0x7f)) {
             // convert to escaped \xxx (decimal) format
             s.push_back('\\');
index 7bea8474279c9f93d71a69828dfdb62584d20807..f1b60f3c254633fb5bd9e9f364176f97f72a3bf5 100644 (file)
@@ -12,7 +12,6 @@
 #include <vector>
 
 #include <boost/lexical_cast.hpp>
-#include <boost/foreach.hpp>
 
 #include <util/encode/base64.h>
 #include <util/buffer.h>
index 40cb1c73ae4214bac678c8a5e29a6e03c9eef24c..6dcb6ff7f68301a3f89c85405a8ec3bd3f31b8d3 100644 (file)
@@ -11,8 +11,6 @@
 #include <dns/rdata.h>
 #include <dns/rdataclass.h>
 
-#include <boost/foreach.hpp>
-
 #include <string>
 #include <string.h>
 
@@ -157,7 +155,7 @@ OPT::toText() const {
 
 void
 OPT::toWire(OutputBuffer& buffer) const {
-    BOOST_FOREACH(const PseudoRR& pseudo_rr, impl_->pseudo_rrs_) {
+    for (auto const& pseudo_rr : impl_->pseudo_rrs_) {
         buffer.writeUint16(pseudo_rr.getCode());
         const uint16_t length = pseudo_rr.getLength();
         buffer.writeUint16(length);
@@ -169,7 +167,7 @@ OPT::toWire(OutputBuffer& buffer) const {
 
 void
 OPT::toWire(AbstractMessageRenderer& renderer) const {
-    BOOST_FOREACH(const PseudoRR& pseudo_rr, impl_->pseudo_rrs_) {
+    for (auto const& pseudo_rr : impl_->pseudo_rrs_) {
         renderer.writeUint16(pseudo_rr.getCode());
         const uint16_t length = pseudo_rr.getLength();
         renderer.writeUint16(length);
index dcd5e13895c3a4b604d3a4497b43aca5d7470982..9b50b9a054e56c13b695c72f81e04de9ac3632ad 100644 (file)
@@ -1549,7 +1549,6 @@ DNAME::getDname() const {
 #include <vector>
 
 #include <boost/lexical_cast.hpp>
-#include <boost/foreach.hpp>
 
 #include <util/encode/base64.h>
 #include <util/buffer.h>
@@ -3646,8 +3645,6 @@ NSEC::compare(const Rdata& other) const {
 #include <dns/rdata.h>
 #include <dns/rdataclass.h>
 
-#include <boost/foreach.hpp>
-
 #include <string>
 #include <string.h>
 
@@ -3794,7 +3791,7 @@ OPT::toText() const {
 
 void
 OPT::toWire(OutputBuffer& buffer) const {
-    BOOST_FOREACH(const PseudoRR& pseudo_rr, impl_->pseudo_rrs_) {
+    for (auto const& pseudo_rr : impl_->pseudo_rrs_) {
         buffer.writeUint16(pseudo_rr.getCode());
         const uint16_t length = pseudo_rr.getLength();
         buffer.writeUint16(length);
@@ -3806,7 +3803,7 @@ OPT::toWire(OutputBuffer& buffer) const {
 
 void
 OPT::toWire(AbstractMessageRenderer& renderer) const {
-    BOOST_FOREACH(const PseudoRR& pseudo_rr, impl_->pseudo_rrs_) {
+    for (auto const& pseudo_rr : impl_->pseudo_rrs_) {
         renderer.writeUint16(pseudo_rr.getCode());
         const uint16_t length = pseudo_rr.getLength();
         renderer.writeUint16(length);
index b2170029d48f21fa4ddceb421e2c6765d5d953d5..5359cd77abf344d713f7f4a57dd0e5230af4594b 100644 (file)
@@ -11,7 +11,6 @@
 #include <vector>
 
 #include <boost/shared_ptr.hpp>
-#include <boost/foreach.hpp>
 
 #include <util/buffer.h>
 #include <dns/messagerenderer.h>
@@ -202,7 +201,7 @@ BasicRRsetImpl::toWire(AbstractMessageRenderer& renderer, size_t limit) const {
 
     // sort the set of Rdata based on rrset-order and sortlist, and possible
     // other options.  Details to be considered.
-    BOOST_FOREACH(const ConstRdataPtr& rdata, rdatalist_) {
+    for (auto const& rdata : rdatalist_) {
         const size_t pos0 = renderer.getLength();
         assert(pos0 < 65536);
 
index 8b6832b7dc593e195250d027fd18bfa72be34519..5dbf687a91ff7e9b3c9433654d7cdf3fdbca8308 100644 (file)
@@ -880,10 +880,8 @@ commonTSIGToWireCheck(Message& message, MessageRenderer& renderer,
     if (answer_data != NULL) {
         RRsetPtr ans_rrset(new RRset(Name("www.example.com"), RRClass::IN(),
                                      qtype, RRTTL(86400)));
-        for (vector<const char*>::const_iterator it = answer_data->begin();
-             it != answer_data->end();
-             ++it) {
-            ans_rrset->addRdata(createRdata(qtype, RRClass::IN(), *it));
+        for (auto const& it : *answer_data) {
+            ans_rrset->addRdata(createRdata(qtype, RRClass::IN(), it));
         }
         message.addRRset(Message::SECTION_ANSWER, ans_rrset);
     }
index caf1f12e16a0baffc4eca4e563b6eee52b42ac20..f9a3dbc7fe318b339d229fbdfe5103fb8b05656b 100644 (file)
@@ -226,9 +226,8 @@ TEST_F(NameTest, fromText) {
     // decimal representation for "WWW"
     strnames.push_back("\\087\\087\\087.example.com");
 
-    vector<string>::const_iterator it;
-    for (it = strnames.begin(); it != strnames.end(); ++it) {
-        EXPECT_PRED_FORMAT2(UnitTestUtil::matchName, example_name, Name(*it));
+    for (auto const& it : strnames) {
+        EXPECT_PRED_FORMAT2(UnitTestUtil::matchName, example_name, Name(it));
     }
 
     // root names
@@ -595,13 +594,11 @@ TEST_F(NameTest, compare) {
                                        NameComparisonResult::EQUAL,
                                        0, 5));
 
-    vector<CompareParameters>::const_iterator it;
-    for (it = params.begin(); it != params.end(); ++it) {
-        NameComparisonResult result = (*it).name1.compare((*it).name2);
-        EXPECT_EQ((*it).reln, result.getRelation());
-        EXPECT_EQ((*it).order,
-                  CompareParameters::normalizeOrder(result.getOrder()));
-        EXPECT_EQ((*it).labels, result.getCommonLabels());
+    for (auto const& it : params) {
+        NameComparisonResult result = it.name1.compare(it.name2);
+        EXPECT_EQ(it.reln, result.getRelation());
+        EXPECT_EQ(it.order, CompareParameters::normalizeOrder(result.getOrder()));
+        EXPECT_EQ(it.labels, result.getCommonLabels());
     }
 }
 
index 570a2abb583904482c2c06095cbe0479898fd226..613ef2634760dd9ee796c9d753bb09e54fc42356 100644 (file)
@@ -126,6 +126,7 @@ TEST_F(Rdata_NSEC_Test, compare) {
     vector<generic::NSEC> compare_set;
     compare_set.push_back(generic::NSEC("a.example. A"));
     compare_set.push_back(generic::NSEC("example. A"));
+
     vector<generic::NSEC>::const_iterator it;
     const vector<generic::NSEC>::const_iterator it_end = compare_set.end();
     for (it = compare_set.begin(); it != it_end - 1; ++it) {
index e2828c2d3a04761fdc894bb5678d05453641c4cb..a9f5cee74de62d215526c5fcbaf6e36add49bb3e 100644 (file)
@@ -186,9 +186,8 @@ TYPED_TEST(Rdata_TXT_LIKE_Test, createMultiStringsFromText) {
     texts.push_back("Test-String\"Test-String\""); // and no space either
 
     std::stringstream ss;
-    for (std::vector<std::string >::const_iterator it = texts.begin();
-         it != texts.end(); ++it) {
-        ss << *it << "\n";
+    for (auto const& it : texts) {
+        ss << it << "\n";
     }
     this->lexer.pushSource(ss);
 
@@ -199,10 +198,9 @@ TYPED_TEST(Rdata_TXT_LIKE_Test, createMultiStringsFromText) {
 
     // Confirm we can construct the Rdata from the test text, both from
     // std::string and with lexer, and that matches the from-wire data.
-    for (std::vector<std::string >::const_iterator it = texts.begin();
-         it != texts.end(); ++it) {
-        SCOPED_TRACE(*it);
-        EXPECT_EQ(0, TypeParam(*it).compare(*rdata));
+    for (auto const& it : texts) {
+        SCOPED_TRACE(it);
+        EXPECT_EQ(0, TypeParam(it).compare(*rdata));
 
         EXPECT_EQ(0, TypeParam(this->lexer, NULL, MasterLoader::MANY_ERRORS,
                                this->loader_cb).compare(*rdata));
index be16ab5b5163fa49be8b2f04dfc18b01d5ce4982..fa6923535b3ceb82e4be555d478df99765a0df4b 100644 (file)
@@ -154,10 +154,9 @@ TEST_F(RRsetCollectionTest, iteratorTest) {
 
     // Here, we just count the records and do some basic tests on them.
     size_t count = 0;
-    for (RRsetCollection::Iterator it = collection.begin();
-         it != collection.end(); ++it) {
+    for (auto const& it : collection) {
          ++count;
-         const AbstractRRset& rrset = *it;
+         const AbstractRRset& rrset = it;
          EXPECT_EQ(rrclass, rrset.getClass());
          EXPECT_EQ(RRTTL(3600), rrset.getTTL());
     }
index 66e36007ec04d2711b36a29af0f598c38c9f9f2f..98b61bc6f85439d65fad96eb513fe5427654f430 100644 (file)
@@ -25,13 +25,13 @@ bool dependOnClass(const ExpressionPtr& expr, const std::string& name) {
     if (!expr) {
         return (false);
     }
-    for (auto it = expr->cbegin(); it != expr->cend(); ++it) {
-        if (dependOnClass(*it, name)) {
+    for (auto const& it : *expr) {
+        if (dependOnClass(it, name)) {
             return (true);
         }
     }
     return (false);
 }
 
-}; // end of isc::dhcp namespace
-}; // end of isc namespace
+} // end of isc::dhcp namespace
+} // end of isc namespace
index f2cadce925ef3035a920e17c3f701093914d09e2..530f1a902ed83b7e07d041dee988c99f52179975 100644 (file)
@@ -13,9 +13,8 @@ namespace dhcp {
 
 bool evaluateBool(const Expression& expr, Pkt& pkt) {
     ValueStack values;
-    for (Expression::const_iterator it = expr.begin();
-         it != expr.end(); ++it) {
-        (*it)->evaluate(pkt, values);
+    for (auto const& it : expr) {
+        it->evaluate(pkt, values);
     }
     if (values.size() != 1) {
         isc_throw(EvalBadStack, "Incorrect stack order. Expected exactly "
@@ -27,8 +26,8 @@ bool evaluateBool(const Expression& expr, Pkt& pkt) {
 std::string
 evaluateString(const Expression& expr, Pkt& pkt) {
     ValueStack values;
-    for (auto it = expr.begin(); it != expr.end(); ++it) {
-        (*it)->evaluate(pkt, values);
+    for (auto const& it : expr) {
+        it->evaluate(pkt, values);
     }
     if (values.size() != 1) {
         isc_throw(EvalBadStack, "Incorrect stack order. Expected exactly "
@@ -37,6 +36,5 @@ evaluateString(const Expression& expr, Pkt& pkt) {
     return (values.top());
 }
 
-
-}; // end of isc::dhcp namespace
-}; // end of isc namespace
+} // end of isc::dhcp namespace
+} // end of isc namespace
index 6877b65ac6739fec47d92397fbd3c70c4b8395be..d5f792f1e96541e8aab286e8c8eb1e7f0fd626ce 100644 (file)
@@ -64,9 +64,8 @@ CalloutHandle::~CalloutHandle() {
 vector<string>
 CalloutHandle::getArgumentNames() const {
     vector<string> names;
-    for (ElementCollection::const_iterator i = arguments_.begin();
-         i != arguments_.end(); ++i) {
-        names.push_back(i->first);
+    for (auto const& i : arguments_) {
+        names.push_back(i.first);
     }
 
     return (names);
@@ -111,9 +110,8 @@ vector<string>
 CalloutHandle::getContextNames() const {
     vector<string> names;
     const ElementCollection& elements = getContextForLibrary();
-    for (ElementCollection::const_iterator i = elements.begin();
-         i != elements.end(); ++i) {
-        names.push_back(i->first);
+    for (auto const& i : elements) {
+        names.push_back(i.first);
     }
 
     return (names);
index 575d1479830e0208f2370646c75897665e2ad9d6..ac95eb45bfc620533a3fb636441c2db96a1cd336 100644 (file)
@@ -149,31 +149,30 @@ CalloutManager::callCallouts(int hook_index, CalloutHandle& callout_handle) {
             .arg(server_hooks_.getName(callout_handle.getCurrentHook()));
 
         // Call all the callouts.
-        for (CalloutVector::const_iterator i = hook_vector_[hook_index].begin();
-             i != hook_vector_[hook_index].end(); ++i) {
+        for (auto const& i : hook_vector_[hook_index]) {
             // In case the callout requires access to the context associated
             // with the library, set the current library index to the index
             // associated with the library that registered the callout being
             // called.
-            callout_handle.setCurrentLibrary(i->first);
+            callout_handle.setCurrentLibrary(i.first);
 
             // Call the callout
             try {
                 stopwatch.start();
-                int status = (*i->second)(callout_handle);
+                int status = (*i.second)(callout_handle);
                 stopwatch.stop();
                 if (status == 0) {
                     LOG_DEBUG(callouts_logger, HOOKS_DBG_EXTENDED_CALLS,
                               HOOKS_CALLOUT_CALLED)
                         .arg(callout_handle.getCurrentLibrary())
                         .arg(server_hooks_.getName(callout_handle.getCurrentHook()))
-                        .arg(PointerConverter(i->second).dlsymPtr())
+                        .arg(PointerConverter(i.second).dlsymPtr())
                         .arg(stopwatch.logFormatLastDuration());
                 } else {
                     LOG_ERROR(callouts_logger, HOOKS_CALLOUT_ERROR)
                         .arg(server_hooks_.getName(callout_handle.getCurrentHook()))
                         .arg(callout_handle.getCurrentLibrary())
-                        .arg(PointerConverter(i->second).dlsymPtr())
+                        .arg(PointerConverter(i.second).dlsymPtr())
                         .arg(stopwatch.logFormatLastDuration());
                 }
             } catch (const std::exception& e) {
@@ -184,7 +183,7 @@ CalloutManager::callCallouts(int hook_index, CalloutHandle& callout_handle) {
                 LOG_ERROR(callouts_logger, HOOKS_CALLOUT_EXCEPTION)
                     .arg(server_hooks_.getName(callout_handle.getCurrentHook()))
                     .arg(callout_handle.getCurrentLibrary())
-                    .arg(PointerConverter(i->second).dlsymPtr())
+                    .arg(PointerConverter(i.second).dlsymPtr())
                     .arg(e.what())
                     .arg(stopwatch.logFormatLastDuration());
                 callout_handle.setStatus(CalloutHandle::NEXT_STEP_DROP);
@@ -196,7 +195,7 @@ CalloutManager::callCallouts(int hook_index, CalloutHandle& callout_handle) {
                 LOG_ERROR(callouts_logger, HOOKS_CALLOUT_EXCEPTION)
                     .arg(server_hooks_.getName(callout_handle.getCurrentHook()))
                     .arg(callout_handle.getCurrentLibrary())
-                    .arg(PointerConverter(i->second).dlsymPtr())
+                    .arg(PointerConverter(i.second).dlsymPtr())
                     .arg("Unspecified exception")
                     .arg(stopwatch.logFormatLastDuration());
                 callout_handle.setStatus(CalloutHandle::NEXT_STEP_DROP);
index e8e0f05735d32890f717928b66395cdb68f30891..93a509cda72b1cb07e4db6b3a830a6fff123358c 100644 (file)
@@ -76,22 +76,20 @@ HooksConfig::equal(const HooksConfig& other) const {
     /// We don't have any libraries that are interacting (or would change their behavior
     /// depending on the order in which their callouts are executed), so the code is
     /// ok for now.
-    for (isc::hooks::HookLibsCollection::const_iterator this_it = libraries_.begin();
-         this_it != libraries_.end(); ++this_it) {
+    for (auto const& this_it : libraries_) {
         bool match = false;
-        for (isc::hooks::HookLibsCollection::const_iterator other_it =
-                 other.libraries_.begin(); other_it != other.libraries_.end(); ++other_it) {
-            if (this_it->first != other_it->first) {
+        for (auto const& other_it : other.libraries_) {
+            if (this_it.first != other_it.first) {
                 continue;
             }
-            if (isNull(this_it->second) && isNull(other_it->second)) {
+            if (isNull(this_it.second) && isNull(other_it.second)) {
                 match = true;
                 break;
             }
-            if (isNull(this_it->second) || isNull(other_it->second)) {
+            if (isNull(this_it.second) || isNull(other_it.second)) {
                 continue;
             }
-            if (this_it->second->equals(*other_it->second)) {
+            if (this_it.second->equals(*other_it.second)) {
                 match = true;
                 break;
             }
@@ -109,15 +107,14 @@ HooksConfig::toElement() const {
     // hooks-libraries is a list of maps
     ElementPtr result = Element::createList();
     // Iterate through libraries
-    for (HookLibsCollection::const_iterator hl = libraries_.begin();
-         hl != libraries_.end(); ++hl) {
+    for (auto const& hl : libraries_) {
         // Entries are maps
         ElementPtr map = Element::createMap();
         // Set the library name
-        map->set("library", Element::create(hl->first));
+        map->set("library", Element::create(hl.first));
         // Set parameters (not set vs set empty map)
-        if (!isNull(hl->second)) {
-            map->set("parameters", hl->second);
+        if (!isNull(hl.second)) {
+            map->set("parameters", hl.second);
         }
         // Push to the list
         result->add(map);
@@ -125,5 +122,5 @@ HooksConfig::toElement() const {
     return (result);
 }
 
-};
-};
+}
+}
index 976f6a0bd00e6c89f991cf9cd713b0a3d084b64e..fc707f80fbc0054b92ffa93ccb65d30897408b2f 100644 (file)
@@ -10,7 +10,6 @@
 #include <cc/dhcp_config_error.h>
 #include <hooks/hooks_parser.h>
 #include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
 #include <util/strutil.h>
 #include <vector>
 
@@ -34,7 +33,7 @@ HooksLibrariesParser::parse(HooksConfig& libraries, ConstElementPtr value) {
     }
 
     // This is the new syntax.  Iterate through it and get each map.
-    BOOST_FOREACH(ConstElementPtr library_entry, value->listValue()) {
+    for (auto const& library_entry : value->listValue()) {
         ConstElementPtr parameters;
 
         // Is it a map?
@@ -54,7 +53,7 @@ HooksLibrariesParser::parse(HooksConfig& libraries, ConstElementPtr value) {
         // values from the previous loop round.
         parameters.reset();
 
-        BOOST_FOREACH(auto const& entry_item, library_entry->mapValue()) {
+        for (auto const& entry_item : library_entry->mapValue()) {
             if (entry_item.first == "library") {
                 if (entry_item.second->getType() != Element::string) {
                     isc_throw(DhcpConfigError, "hooks library configuration"
index 2abf3a1d479e563f142b71ef08d9dae1c69be4d8..7e13588cf41c31f00bd8211cf8e83f43fe792d5b 100644 (file)
@@ -19,12 +19,11 @@ std::vector<std::string>
 extractNames(const isc::hooks::HookLibsCollection& libraries) {
     std::vector<std::string> names;
 
-    for (isc::hooks::HookLibsCollection::const_iterator it = libraries.begin();
-         it != libraries.end(); ++it) {
-        names.push_back(it->first);
+    for (auto const& it : libraries) {
+        names.push_back(it.first);
     }
     return (names);
 }
 
-};
-};
+}
+}
index 88cda6f3e4e89c7809ca57467720d8cba6739a17..ef94c9ef8d8c1d1aa3818b1edb41f3be504d552c 100644 (file)
@@ -120,12 +120,11 @@ LibraryHandle::getParameterNames() {
         return (names);
     }
     auto const& map = params->mapValue();
-    for (auto elem = map.begin(); elem != map.end(); ++elem) {
-        names.push_back(elem->first);
+    for (auto const& elem : map) {
+        names.push_back(elem.first);
     }
     return (names);
 }
 
-
 } // namespace util
 } // namespace isc
index 09b7912f3c778c24742c27c44ad8b537a94e5d81..7f6c14127fa25899c87f598c3884814d5c63784b 100644 (file)
@@ -10,6 +10,7 @@
 #include <hooks/hooks_manager.h>
 #include <hooks/library_manager.h>
 #include <hooks/library_manager_collection.h>
+#include <boost/range/adaptor/reversed.hpp>
 
 namespace isc {
 namespace hooks {
@@ -41,9 +42,8 @@ LibraryManagerCollection::LibraryManagerCollection(const HookLibsCollection& lib
     : library_info_(libraries) {
 
     // We need to split hook libs into library names and library parameters.
-    for (HookLibsCollection::const_iterator it = libraries.begin();
-         it != libraries.end(); ++it) {
-        library_names_.push_back(it->first);
+    for (auto const& it : libraries) {
+        library_names_.push_back(it.first);
     }
 }
 
@@ -122,8 +122,8 @@ bool
 LibraryManagerCollection::prepareUnloadLibraries() {
     bool result = true;
     // Iterate on library managers in reverse order.
-    for (auto lm = lib_managers_.rbegin(); lm != lib_managers_.rend(); ++lm) {
-        result = (*lm)->prepareUnloadLibrary() && result;
+    for (auto const& lm : boost::adaptors::reverse(lib_managers_)) {
+        result = lm->prepareUnloadLibrary() && result;
     }
     return (result);
 }
index 5ca1a5059657f788018376834de09e4300798602..1c087004144d97627b9aff858ab38939db87a188 100644 (file)
@@ -158,11 +158,9 @@ ServerHooks::findIndex(const std::string& name) const {
 
 vector<string>
 ServerHooks::getHookNames() const {
-
     vector<string> names;
-    HookCollection::const_iterator i;
-    for (i = hooks_.begin(); i != hooks_.end(); ++i) {
-        names.push_back(i->first);
+    for (auto const& i : hooks_) {
+        names.push_back(i.first);
     }
 
     return (names);
@@ -215,7 +213,5 @@ ServerHooks::hookToCommandName(const std::string& hook_name) {
     return ("");
 }
 
-
-
 } // namespace hooks
 } // namespace isc
index de92eb20e6bbc9a959c6733d1ce52f3882c8ee15..b32c397843aa590211db9a0d99ce1abd9267eedc 100644 (file)
@@ -61,10 +61,8 @@ HttpConnectionPool::stopAll() {
 
 void
 HttpConnectionPool::stopAllInternal() {
-    for (auto connection = connections_.begin();
-         connection != connections_.end();
-         ++connection) {
-        (*connection)->close();
+    for (auto const& connection : connections_) {
+        connection->close();
     }
 
     connections_.clear();
index f753fea5492d7d4db6d4db194b3388e47fc9871a..15a4ea2e0413278ba8eb9c96bdd314c019890c9d 100644 (file)
@@ -90,10 +90,8 @@ HttpRequest::create() {
         }
 
         // Copy headers from the context.
-        for (auto header = context_->headers_.begin();
-             header != context_->headers_.end();
-             ++header) {
-            HttpHeaderPtr hdr(new HttpHeader(header->name_, header->value_));
+        for (auto const& header : context_->headers_) {
+            HttpHeaderPtr hdr(new HttpHeader(header.name_, header.value_));
             headers_[hdr->getLowerCaseName()] = hdr;
         }
 
@@ -105,19 +103,17 @@ HttpRequest::create() {
 
         // Iterate over required headers and check that they exist
         // in the HTTP request.
-        for (auto req_header = required_headers_.begin();
-             req_header != required_headers_.end();
-             ++req_header) {
-            auto header = headers_.find(req_header->first);
+        for (auto const& req_header : required_headers_) {
+            auto header = headers_.find(req_header.first);
             if (header == headers_.end()) {
-                isc_throw(BadValue, "required header " << req_header->first
+                isc_throw(BadValue, "required header " << req_header.first
                           << " not found in the HTTP request");
-            } else if (!req_header->second->getValue().empty() &&
-                       !header->second->isValueEqual(req_header->second->getValue())) {
+            } else if (!req_header.second->getValue().empty() &&
+                       !header->second->isValueEqual(req_header.second->getValue())) {
                 // If specific value is required for the header, check
                 // that the value in the HTTP request matches it.
                 isc_throw(BadValue, "required header's " << header->first
-                          << " value is " << req_header->second->getValue()
+                          << " value is " << req_header.second->getValue()
                           << ", but " << header->second->getValue() << " was found");
             }
         }
@@ -200,10 +196,9 @@ HttpRequest::toString() const {
     }
 
     // Add all other headers.
-    for (auto header_it = headers_.cbegin(); header_it != headers_.cend();
-         ++header_it) {
-        if (header_it->second->getName() != "Host") {
-            s << header_it->second->getName() << ": " << header_it->second->getValue()
+    for (auto const& header_it : headers_) {
+        if (header_it.second->getName() != "Host") {
+            s << header_it.second->getName() << ": " << header_it.second->getValue()
               << crlf;
         }
     }
index cdc419a4068a4ca453a7d607e53092b56ae833c5..fc52311cdf5215e86a0a1ef58cb7277c10be32f5 100644 (file)
@@ -80,10 +80,8 @@ HttpResponse::create() {
         }
 
         // Copy headers from the context.
-        for (auto header = context_->headers_.begin();
-             header != context_->headers_.end();
-             ++header) {
-            HttpHeaderPtr hdr(new HttpHeader(header->name_, header->value_));
+        for (auto const& header : context_->headers_) {
+            HttpHeaderPtr hdr(new HttpHeader(header.name_, header.value_));
             headers_[hdr->getLowerCaseName()] = hdr;
         }
 
@@ -98,19 +96,17 @@ HttpResponse::create() {
 
         // Iterate over required headers and check that they exist
         // in the HTTP response.
-        for (auto req_header = required_headers_.begin();
-             req_header != required_headers_.end();
-             ++req_header) {
-            auto header = headers_.find(req_header->first);
+        for (auto const& req_header : required_headers_) {
+            auto header = headers_.find(req_header.first);
             if (header == headers_.end()) {
-                isc_throw(BadValue, "required header " << req_header->first
+                isc_throw(BadValue, "required header " << req_header.first
                           << " not found in the HTTP response");
-            } else if (!req_header->second->getValue().empty() &&
-                       !header->second->isValueEqual(req_header->second->getValue())) {
+            } else if (!req_header.second->getValue().empty() &&
+                       !header->second->isValueEqual(req_header.second->getValue())) {
                 // If specific value is required for the header, check
                 // that the value in the HTTP response matches it.
                 isc_throw(BadValue, "required header's " << header->first
-                          << " value is " << req_header->second->getValue()
+                          << " value is " << req_header.second->getValue()
                           << ", but " << header->second->getValue() << " was found");
             }
         }
@@ -215,9 +211,8 @@ HttpResponse::toString() const {
     // HTTP version number and status code.
     s << toBriefString() << crlf;
 
-    for (auto header_it = headers_.cbegin(); header_it != headers_.cend();
-         ++header_it) {
-        s << header_it->second->getName() << ": " << header_it->second->getValue()
+    for (auto const& header_it : headers_) {
+        s << header_it.second->getName() << ": " << header_it.second->getValue()
           << crlf;
     }
 
index 517d1c8ce9a65b09a7b6c4fe4b7d5f6c08c0c4c2..ab94490ccf8196ea498bae61d39b2b0fb7ca8f9f 100644 (file)
@@ -409,9 +409,8 @@ public:
     ///
     /// Removes active HTTP clients.
     virtual ~HttpListenerTest() {
-        for (auto client = clients_.begin(); client != clients_.end();
-             ++client) {
-            (*client)->close();
+        for (auto const& client : clients_) {
+            client->close();
         }
     }
 
index 3f41eb1ca3e643738156013ee0a63a9e5fe302ab..e0d91b1b26871770856ab13d609c3ef71912404c 100644 (file)
@@ -657,9 +657,8 @@ public:
     ///
     /// Removes active HTTP clients.
     virtual ~HttpsListenerTest() {
-        for (auto client = clients_.begin(); client != clients_.end();
-             ++client) {
-            (*client)->close();
+        for (auto const& client : clients_) {
+            client->close();
         }
     }
 
index 6ce8d402afe185c52c8feeb79274edd5f110c6e3..1e09805ff7a7e3e0cd1207bcbc33dcf729991411 100644 (file)
@@ -39,10 +39,9 @@ BufferAppender::flushStdout() {
     // be a good idea; as we can't reliably know whether in what
     // state the logger instance is now (or what the specific logger's
     // settings were).
-    LogEventList::const_iterator it;
-    for (it = stored_.begin(); it != stored_.end(); ++it) {
-        const std::string level(it->first);
-        LogEventPtr event(it->second);
+    for (auto const& it : stored_) {
+        const std::string level(it.first);
+        LogEventPtr event(it.second);
         std::printf("%s [%s]: %s\n", level.c_str(),
                     event->getLoggerName().c_str(),
                     event->getMessage().c_str());
@@ -55,9 +54,8 @@ BufferAppender::flush() {
     LogEventList stored_copy;
     stored_.swap(stored_copy);
 
-    LogEventList::const_iterator it;
-    for (it = stored_copy.begin(); it != stored_copy.end(); ++it) {
-        LogEventPtr event(it->second);
+    for (auto const& it : stored_copy) {
+        LogEventPtr event(it.second);
         log4cplus::Logger logger =
             log4cplus::Logger::getInstance(event->getLoggerName());
 
index 8f19c5a3a6c1df7b1e3ba73ef29945ac5b5cd157..2d80af3892cd31a735ab470c7be99d270cf7e72f 100644 (file)
@@ -31,8 +31,6 @@
 
 #include <log/logger.h>
 
-#include <boost/foreach.hpp>
-
 using namespace std;
 using namespace isc::log;
 using namespace isc::util;
@@ -144,9 +142,8 @@ vector<string>
 sortedIdentifiers(MessageDictionary& dictionary) {
     vector<string> ident;
 
-    for (MessageDictionary::const_iterator i = dictionary.begin();
-         i != dictionary.end(); ++i) {
-        ident.push_back(i->first);
+    for (auto const& i : dictionary) {
+        ident.push_back(i.first);
     }
     sort(ident.begin(), ident.end());
 
@@ -267,9 +264,8 @@ writeHeaderFile(const string& file,
     writeOpeningNamespace(hfile, ns_components);
 
     vector<string> idents = sortedIdentifiers(dictionary);
-    for (vector<string>::const_iterator j = idents.begin();
-        j != idents.end(); ++j) {
-        hfile << "extern const isc::log::MessageID " << *j << ";\n";
+    for (auto const& j : idents) {
+        hfile << "extern const isc::log::MessageID " << j << ";\n";
     }
     hfile << "\n";
 
@@ -368,10 +364,9 @@ writeProgramFile(const string& file,
     writeOpeningNamespace(ccfile, ns_components);
 
     vector<string> idents = sortedIdentifiers(dictionary);
-    for (vector<string>::const_iterator j = idents.begin();
-        j != idents.end(); ++j) {
-        ccfile << "extern const isc::log::MessageID " << *j <<
-            " = \"" << *j << "\";\n";
+    for (auto const& j : idents) {
+        ccfile << "extern const isc::log::MessageID " << j <<
+            " = \"" << j << "\";\n";
     }
     ccfile << "\n";
 
@@ -386,10 +381,8 @@ writeProgramFile(const string& file,
 
     // Output the identifiers and the associated text.
     idents = sortedIdentifiers(dictionary);
-    for (vector<string>::const_iterator i = idents.begin();
-        i != idents.end(); ++i) {
-            ccfile << "    \"" << *i << "\", \"" <<
-                quoteString(dictionary.getText(*i)) << "\",\n";
+    for (auto const& i : idents) {
+        ccfile << "    \"" << i << "\", \"" << quoteString(dictionary.getText(i)) << "\",\n";
     }
 
     // ... and the postamble
@@ -431,9 +424,9 @@ errorDuplicates(MessageReader& reader) {
         sort(duplicates.begin(), duplicates.end());
         MessageReader::MessageIDCollection::iterator new_end =
             unique(duplicates.begin(), duplicates.end());
-        for (MessageReader::MessageIDCollection::iterator i = duplicates.begin();
-            i != new_end; ++i) {
-            cout << "    " << *i << "\n";
+        duplicates.erase(new_end, duplicates.end());
+        for (auto const& i : duplicates) {
+            cout << "    " << i << "\n";
         }
         exit(1);
     }
index 1890706898027811443b6a0fe9ddad804ab47966..5da754bac0fbb8092fe63aac646409a5e7a6e5f1 100644 (file)
@@ -144,9 +144,8 @@ LoggerManager::logDuplicatedMessages() {
         // There are duplicates present. This list itself may contain
         // duplicates; if so, the message ID is listed as many times as
         // there are duplicates.
-        for (list<string>::const_iterator i = duplicates.begin();
-             i != duplicates.end(); ++i) {
-            LOG_WARN(logger, LOG_DUPLICATE_MESSAGE_ID).arg(*i);
+        for (auto const& i : duplicates) {
+            LOG_WARN(logger, LOG_DUPLICATE_MESSAGE_ID).arg(i);
         }
         MessageInitializer::clearDuplicates();
     }
index 946e16348f33959840c65f341e4b2ed7afc799d2..e25bb9cce4749a8492534e46611718a2998b5735 100644 (file)
@@ -295,10 +295,8 @@ void LoggerManagerImpl::setAppenderLayout(
 void LoggerManagerImpl::storeBufferAppenders() {
     // Walk through all loggers, and find any buffer appenders there
     log4cplus::LoggerList loggers = log4cplus::Logger::getCurrentLoggers();
-    log4cplus::LoggerList::iterator it;
-    for (it = loggers.begin(); it != loggers.end(); ++it) {
-        log4cplus::SharedAppenderPtr buffer_appender =
-            it->getAppender("buffer");
+    for (auto& it : loggers) {
+        log4cplus::SharedAppenderPtr buffer_appender = it.getAppender("buffer");
         if (buffer_appender) {
             buffer_appender_store_.push_back(buffer_appender);
         }
@@ -309,10 +307,8 @@ void LoggerManagerImpl::flushBufferAppenders() {
     std::vector<log4cplus::SharedAppenderPtr> copy;
     buffer_appender_store_.swap(copy);
 
-    std::vector<log4cplus::SharedAppenderPtr>::iterator it;
-    for (it = copy.begin(); it != copy.end(); ++it) {
-        internal::BufferAppender* app =
-            dynamic_cast<internal::BufferAppender*>(it->get());
+    for (auto const& it : copy) {
+        internal::BufferAppender* app = dynamic_cast<internal::BufferAppender*>(it.get());
         isc_throw_assert(app);
         app->flush();
     }
index a7c85ed2e68bd0a71aa07ed3c0b5c229e485f9c9..94e5be15a7353d9706f5a65e786a3982ea3d25b7 100644 (file)
@@ -103,9 +103,8 @@ MessageInitializer::loadDictionary(bool ignore_duplicates) {
     const MessageDictionaryPtr& global = MessageDictionary::globalDictionary();
     const LoggerValuesListPtr& logger_values = getNonConstLoggerValues();
 
-    for (LoggerValuesList::const_iterator values = logger_values->begin();
-         values != logger_values->end(); ++values) {
-        std::vector<std::string> repeats = global->load(*values);
+    for (auto const& values : *logger_values) {
+        std::vector<std::string> repeats = global->load(values);
 
         // Append the IDs in the list just loaded (the "repeats") to the
         // global list of duplicate IDs.
index b333d5463c2ffeb032783cc6f6218ac0e81eb178..11d72189725d10824cae94910f3f31e8811bbbaf 100644 (file)
@@ -13,6 +13,7 @@
 #include <database/server_selector.h>
 #include <process/config_base.h>
 #include <process/config_ctl_info.h>
+#include <boost/foreach.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/date_time/gregorian/gregorian.hpp>
 #include <process/d_log.h>
@@ -271,9 +272,9 @@ protected:
         db::AuditEntryCollection result;
         auto const& index = audit_entries.get<db::AuditEntryObjectTypeTag>();
         auto range = index.equal_range(object_type);
-        for (auto it = range.first; it != range.second; ++it) {
-            if ((*it)->getModificationType() != db::AuditEntry::ModificationType::DELETE) {
-                result.insert(*it);
+        BOOST_FOREACH(auto const& it, range) {
+            if (it->getModificationType() != db::AuditEntry::ModificationType::DELETE) {
+                result.insert(it);
             }
         }
 
index 1e02fad2ac10d7e4c03391de479a8364a0b14b9c..96c9e4600839412eb6949439331c9c86a78cc385 100644 (file)
@@ -77,9 +77,8 @@ void
 ConfigBase::copy(ConfigBase& other) const {
     // We will entirely replace loggers in the new configuration.
     other.logging_info_.clear();
-    for (LoggingInfoStorage::const_iterator it = logging_info_.begin();
-         it != logging_info_.end(); ++it) {
-        other.addLoggingInfo(*it);
+    for (auto const& it : logging_info_) {
+        other.addLoggingInfo(it);
     }
 
     // Clone the config control info
index b7b87a388fcd35b9a9de68ef1a55868459b9f4c7..c4eeb1b69b43ada7bd70faa3101095935f07b902 100644 (file)
@@ -71,13 +71,11 @@ ConfigControlInfo::addConfigDatabase(const std::string& access_str) {
 const ConfigDbInfo&
 ConfigControlInfo::findConfigDb(const std::string& param_name,
                                 const std::string& param_value) {
-    for (ConfigDbInfoList::iterator db = db_infos_.begin();
-         db != db_infos_.end(); ++db) {
+    for (auto const& db : db_infos_) {
         std::string db_value;
-        if (db->getParameterValue(param_name, db_value) &&
-            (param_value == db_value)) {
-                return (*db);
-            }
+        if (db.getParameterValue(param_name, db_value) && (param_value == db_value)) {
+            return (db);
+        }
     }
 
     return (EMPTY_DB());
index 38f7ac06fe4b1fe471a80679998b653ed5b79912..f6adb9eef4d788a8417a6ba63f73d3d8aeb62144 100644 (file)
@@ -32,10 +32,10 @@ ConfigControlParser::parse(const data::ConstElementPtr& config_control) {
             }
 
             const std::vector<data::ElementPtr>& db_list = elem->listValue();
-            for (auto db = db_list.cbegin(); db != db_list.end(); ++db) {
+            for (auto const& db : db_list) {
                 db::DbAccessParser parser;
                 std::string access_string;
-                parser.parse(access_string, *db);
+                parser.parse(access_string, db);
                 /// @todo do we still need access_string for this at all?
                 /// can't we just use params directly and get rid of the
                 /// string now that DatabaseConnection::toElement(map) exists?
index a08a90386215f08a9e4cf3e2a77d74ce03923b57..e0cb701387550494fcf2aef9fc3333d4b55eabc5 100644 (file)
@@ -15,7 +15,6 @@
 #include <util/encode/hex.h>
 #include <util/strutil.h>
 
-#include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/algorithm/string.hpp>
 
index 01a61671123e3b571f52e36f4d2896310513195c..5fa33561f27ba52e99fd2e0db0c75058acab04cc 100644 (file)
@@ -7,7 +7,6 @@
 #include <config.h>
 #include <cc/data.h>
 #include <process/log_parser.h>
-#include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
 #include <log/logger_specification.h>
 #include <log/logger_support.h>
@@ -33,7 +32,7 @@ void LogConfigParser::parseConfiguration(const isc::data::ConstElementPtr& logge
     verbose_ = verbose;
 
     // Iterate over all entries in "Server/loggers" list
-    BOOST_FOREACH(ConstElementPtr logger, loggers->listValue()) {
+    for (auto const& logger : loggers->listValue()) {
         parseConfigEntry(logger);
     }
 }
@@ -119,7 +118,7 @@ void LogConfigParser::parseOutputOptions(std::vector<LoggingDestination>& destin
         isc_throw(BadValue, "Missing 'output-options' structure in 'loggers'");
     }
 
-    BOOST_FOREACH(ConstElementPtr output_option, output_options->listValue()) {
+    for (auto const& output_option : output_options->listValue()) {
 
         LoggingDestination dest;
 
index f75c9acdbcb129254b78bf5657314bcaa3530c9a..0fadde502a6a566f620b8dc16f8547ce5557e4da 100644 (file)
@@ -88,7 +88,7 @@ LoggingInfo::equals(const LoggingInfo& other) const {
     // that they are at the same index of the vectors.
     for (auto const& dest : destinations_) {
         bool match = false;
-        for (auto const &dest_other : other.destinations_) {
+        for (auto constdest_other : other.destinations_) {
             if (dest.equals(dest_other)) {
                 match = true;
                 break;
index faa3e928970dba282ccea15bba5269cd5c68e788..80d14a3161d6a599dd21bcf79b5ea30106aa3812 100644 (file)
@@ -12,7 +12,6 @@
 #include <process/d_cfg_mgr.h>
 #include <process/redact_config.h>
 
-#include <boost/foreach.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <gtest/gtest.h>
 
index 034f2b974568669fa4bb8e19859512425d96a241..933683e99ba20f1e020d74d9836d1ab0e76c7cbd 100644 (file)
@@ -443,10 +443,10 @@ Observation::getJSON() const {
 
         // Iteration over all elements in the list
         // and adding alternately value and timestamp to the entry
-        for (std::list<IntegerSample>::iterator it = s.begin(); it != s.end(); ++it) {
+        for (auto const& it : s) {
             entry = isc::data::Element::createList();
-            value = isc::data::Element::create(static_cast<int64_t>((*it).first));
-            timestamp = isc::data::Element::create(isc::util::clockToText((*it).second));
+            value = isc::data::Element::create(static_cast<int64_t>(it.first));
+            timestamp = isc::data::Element::create(isc::util::clockToText(it.second));
 
             entry->add(value);
             entry->add(timestamp);
@@ -477,10 +477,10 @@ Observation::getJSON() const {
 
         // Iteration over all elements in the list
         // and adding alternately value and timestamp to the entry
-        for (std::list<FloatSample>::iterator it = s.begin(); it != s.end(); ++it) {
+        for (auto const& it : s) {
             entry = isc::data::Element::createList();
-            value = isc::data::Element::create((*it).first);
-            timestamp = isc::data::Element::create(isc::util::clockToText((*it).second));
+            value = isc::data::Element::create(it.first);
+            timestamp = isc::data::Element::create(isc::util::clockToText(it.second));
 
             entry->add(value);
             entry->add(timestamp);
@@ -494,10 +494,10 @@ Observation::getJSON() const {
 
         // Iteration over all elements in the list
         // and adding alternately value and timestamp to the entry
-        for (std::list<DurationSample>::iterator it = s.begin(); it != s.end(); ++it) {
+        for (auto const& it : s) {
             entry = isc::data::Element::createList();
-            value = isc::data::Element::create(isc::util::durationToText((*it).first));
-            timestamp = isc::data::Element::create(isc::util::clockToText((*it).second));
+            value = isc::data::Element::create(isc::util::durationToText(it.first));
+            timestamp = isc::data::Element::create(isc::util::clockToText(it.second));
 
             entry->add(value);
             entry->add(timestamp);
@@ -511,10 +511,10 @@ Observation::getJSON() const {
 
         // Iteration over all elements in the list
         // and adding alternately value and timestamp to the entry
-        for (std::list<StringSample>::iterator it = s.begin(); it != s.end(); ++it) {
+        for (auto const& it : s) {
             entry = isc::data::Element::createList();
-            value = isc::data::Element::create((*it).first);
-            timestamp = isc::data::Element::create(isc::util::clockToText((*it).second));
+            value = isc::data::Element::create(it.first);
+            timestamp = isc::data::Element::create(isc::util::clockToText(it.second));
 
             entry->add(value);
             entry->add(timestamp);
index 63fbecea2d574dfd352b70b423fe55683a25544c..7b9fad6a61748303eab0e1fc0b89dc99fa1ee426 100644 (file)
@@ -219,27 +219,27 @@ TEST_F(ObservationTest, moreThanOne) {
     std::list<BigIntegerSample> samples_bigint = e.getBigIntegers(); // List of all big integer samples
 
     uint32_t i = 2; // Index pointed to the end of array of samples
-    for (std::list<IntegerSample>::iterator it = samples_int.begin(); it != samples_int.end(); ++it) {
-        EXPECT_EQ(int_samples[i], static_cast<int64_t>((*it).first));
+    for (auto const& it : samples_int) {
+        EXPECT_EQ(int_samples[i], static_cast<int64_t>(it.first));
         --i;
     }
     i = 2;
-    for (std::list<FloatSample>::iterator it = samples_float.begin(); it != samples_float.end(); ++it) {
-        EXPECT_EQ(float_samples[i], (*it).first);
+    for (auto const& it : samples_float) {
+        EXPECT_EQ(float_samples[i], it.first);
         --i;
     }
     i = 2;
-    for (std::list<DurationSample>::iterator it = samples_dur.begin(); it != samples_dur.end(); ++it) {
-        EXPECT_EQ(duration_samples[i], (*it).first);
+    for (auto const& it : samples_dur) {
+        EXPECT_EQ(duration_samples[i], it.first);
         --i;
     }
     i = 2;
-    for (std::list<StringSample>::iterator it = samples_str.begin(); it != samples_str.end(); ++it) {
-        EXPECT_EQ(string_samples[i], (*it).first);
+    for (auto const& it : samples_str) {
+        EXPECT_EQ(string_samples[i], it.first);
         --i;
     }
     i = 2;
-    for (BigIntegerSample const& sample : samples_bigint) {
+    for (auto const& sample : samples_bigint) {
         EXPECT_EQ(bigint_samples[i], sample.first);
         --i;
     }
@@ -345,27 +345,27 @@ TEST_F(ObservationTest, setCountLimit) {
 
     // And whether stored values are correct
     uint32_t i = 20; // index of the last element in array of test's samples
-    for (std::list<IntegerSample>::iterator it = samples_int.begin(); it != samples_int.end(); ++it) {
-        EXPECT_EQ((*it).first, int_samples[i]);
+    for (auto const& it : samples_int) {
+        EXPECT_EQ(it.first, int_samples[i]);
         --i;
     }
     i = 20; // index of last element in array of test's samples
-    for (std::list<FloatSample>::iterator it = samples_float.begin(); it != samples_float.end(); ++it) {
-        EXPECT_EQ((*it).first, float_samples[i]);
+    for (auto const& it : samples_float) {
+        EXPECT_EQ(it.first, float_samples[i]);
         --i;
     }
     i = 20; // index of last element in array of test's samples
-    for (std::list<DurationSample>::iterator it = samples_duration.begin(); it != samples_duration.end(); ++it) {
-        EXPECT_EQ((*it).first, duration_samples[i]);
+    for (auto const& it : samples_duration) {
+        EXPECT_EQ(it.first, duration_samples[i]);
         --i;
     }
     i = 20; // index of last element in array of test's samples
-    for (std::list<StringSample>::iterator it = samples_string.begin(); it != samples_string.end(); ++it) {
-        EXPECT_EQ((*it).first, string_samples[i]);
+    for (auto const& it : samples_string) {
+        EXPECT_EQ(it.first, string_samples[i]);
         --i;
     }
     i = 20; // index of last element in array of test's samples
-    for (BigIntegerSample const& sample : samples_bigint) {
+    for (auto const& sample : samples_bigint) {
         EXPECT_EQ(sample.first, int_samples[i]);
         --i;
     }
@@ -392,27 +392,27 @@ TEST_F(ObservationTest, setCountLimit) {
 
     // And whether storages contain only the 10 newest values
     i = 20; // index of last element in array of test's samples
-    for (std::list<IntegerSample>::iterator it = samples_int.begin(); it != samples_int.end(); ++it) {
-        EXPECT_EQ((*it).first, int_samples[i]);
+    for (auto const& it : samples_int) {
+        EXPECT_EQ(it.first, int_samples[i]);
         --i;
     }
     i = 20; // index of last element in array of test's samples
-    for (std::list<FloatSample>::iterator it = samples_float.begin(); it != samples_float.end(); ++it) {
-        EXPECT_EQ((*it).first, float_samples[i]);
+    for (auto const& it : samples_float) {
+        EXPECT_EQ(it.first, float_samples[i]);
         --i;
     }
     i = 20; // index of last element in array of test's samples
-    for (std::list<DurationSample>::iterator it = samples_duration.begin(); it != samples_duration.end(); ++it) {
-        EXPECT_EQ((*it).first, duration_samples[i]);
+    for (auto const& it : samples_duration) {
+        EXPECT_EQ(it.first, duration_samples[i]);
         --i;
     }
     i = 20; // index of last element in array of test's samples
-    for (std::list<StringSample>::iterator it = samples_string.begin(); it != samples_string.end(); ++it) {
-        EXPECT_EQ((*it).first, string_samples[i]);
+    for (auto const& it : samples_string) {
+        EXPECT_EQ(it.first, string_samples[i]);
         --i;
     }
     i = 20; // index of last element in array of test's samples
-    for (BigIntegerSample const& sample : samples_bigint) {
+    for (auto const& sample : samples_bigint) {
         EXPECT_EQ(sample.first, int_samples[i]);
         --i;
     }
@@ -451,27 +451,27 @@ TEST_F(ObservationTest, setCountLimit) {
     ASSERT_EQ(e.getSize(), 11);
 
     i = 21; // index of last element in array of test's samples
-    for (std::list<IntegerSample>::iterator it = samples_int.begin(); it != samples_int.end(); ++it) {
-        EXPECT_EQ((*it).first, int_samples[i]);
+    for (auto const& it : samples_int) {
+        EXPECT_EQ(it.first, int_samples[i]);
         --i;
     }
     i = 21; // index of last element in array of test's samples
-    for (std::list<FloatSample>::iterator it = samples_float.begin(); it != samples_float.end(); ++it) {
-        EXPECT_EQ((*it).first, float_samples[i]);
+    for (auto const& it : samples_float) {
+        EXPECT_EQ(it.first, float_samples[i]);
         --i;
     }
     i = 21; // index of last element in array of test's samples
-    for (std::list<DurationSample>::iterator it = samples_duration.begin(); it != samples_duration.end(); ++it) {
-        EXPECT_EQ((*it).first, duration_samples[i]);
+    for (auto const& it : samples_duration) {
+        EXPECT_EQ(it.first, duration_samples[i]);
         --i;
     }
     i = 21; // index of last element in array of test's samples
-    for (std::list<StringSample>::iterator it = samples_string.begin(); it != samples_string.end(); ++it) {
-        EXPECT_EQ((*it).first, string_samples[i]);
+    for (auto const& it : samples_string) {
+        EXPECT_EQ(it.first, string_samples[i]);
         --i;
     }
     i = 21; // index of last element in array of test's samples
-    for (BigIntegerSample const& sample : samples_bigint) {
+    for (auto const& sample : samples_bigint) {
         EXPECT_EQ(sample.first, int_samples[i]);
         --i;
     }
@@ -510,8 +510,8 @@ TEST_F(ObservationTest, setAgeLimit) {
 
     // and whether it contains expected values
     uint32_t i = 9;
-    for (std::list<DurationSample>::iterator it = samples_duration.begin(); it != samples_duration.end(); ++it) {
-        EXPECT_EQ((*it).first, milliseconds(i));
+    for (auto const& it : samples_duration) {
+        EXPECT_EQ(it.first, milliseconds(i));
         --i;
     }
 }
index b7de361c88829197ed7c034471410b8cef4d5e21..9182776f2cb22bc32d95fe6c3c9b0214b6c4fa3d 100644 (file)
@@ -86,10 +86,8 @@ TcpConnectionPool::stopAll() {
 
 void
 TcpConnectionPool::stopAllInternal() {
-    for (auto connection = connections_.begin();
-         connection != connections_.end();
-         ++connection) {
-        (*connection)->close();
+    for (auto const& connection : connections_) {
+        connection->close();
     }
 
     size_t cnt = connections_.size();
index bad26bc87cc3829dfd6a46f80eb1d0f94c4c4521..6e3d4d8ed8a2bf837a1648ad67994ffb246a0a95 100644 (file)
@@ -59,9 +59,8 @@ Value<EP> moveComments1(EP element) {
         ElementPtr result = ElementPtr(new ListElement());
         typedef std::vector<ElementPtr> ListType;
         const ListType& list = element->listValue();
-        for (ListType::const_iterator it = list.cbegin();
-             it != list.cend(); ++it) {
-            Value<ElementPtr> item = moveComments1(*it);
+        for (auto const& it : list) {
+            Value<ElementPtr> item = moveComments1(it);
             result->add(item.get());
             if (!item.isShared()) {
                 modified = true;
@@ -81,17 +80,17 @@ Value<EP> moveComments1(EP element) {
     bool has_comment = false;
     typedef std::map<std::string, ConstElementPtr> map_type;
     const map_type& map = element->mapValue();
-    for (map_type::const_iterator it = map.cbegin(); it != map.cend(); ++it) {
-        if (it->first == "comment") {
+    for (auto const& it : map) {
+        if (it.first == "comment") {
             // Note there is a comment entry to move
             has_comment = true;
-        } else if (it->first == "user-context") {
+        } else if (it.first == "user-context") {
             // Do not traverse user-context entries
-            result->set("user-context", it->second);
+            result->set("user-context", it.second);
         } else {
             // Not comment or user-context
-            Value<ConstElementPtr> item = moveComments1(it->second);
-            result->set(it->first, item.get());
+            Value<ConstElementPtr> item = moveComments1(it.second);
+            result->set(it.first, item.get());
             if (!item.isShared()) {
                 modified = true;
             }
index cf3eaa8b67b202ce12ecd745247c44a5b19d7dde..b85bfe13ecf47a7261d19f5c0fa019182de9f734 100644 (file)
@@ -8,6 +8,8 @@
 
 #include <util/multi_threading_mgr.h>
 
+#include <boost/range/adaptor/reversed.hpp>
+
 namespace isc {
 namespace util {
 
@@ -178,9 +180,9 @@ void
 MultiThreadingMgr::callEntryCallbacks() {
     if (getMode()) {
         auto const& callbacks = cs_callbacks_.getCallbackSets();
-        for (auto cb_it = callbacks.begin(); cb_it != callbacks.end(); cb_it++) {
+        for (auto const& cb_it : callbacks) {
             try {
-                (cb_it->entry_cb_)();
+                (cb_it.entry_cb_)();
             } catch (...) {
                 // We can't log it and throwing could be chaos.
                 // We'll swallow it and tell people their callbacks
@@ -194,9 +196,9 @@ void
 MultiThreadingMgr::callExitCallbacks() {
     if (getMode()) {
         auto const& callbacks = cs_callbacks_.getCallbackSets();
-        for (auto cb_it = callbacks.rbegin(); cb_it != callbacks.rend(); cb_it++) {
+        for (auto const& cb_it : boost::adaptors::reverse(callbacks)) {
             try {
-                (cb_it->exit_cb_)();
+                (cb_it.exit_cb_)();
             } catch (...) {
                 // We can't log it and throwing could be chaos.
                 // We'll swallow it and tell people their callbacks
index 55f5f9750b329c3ac9bd61d2486dca345a114f83..449e38f9a8e1e775dcaf82ae65e853784a2f7028 100644 (file)
@@ -79,15 +79,15 @@ tokens(const std::string& text, const std::string& delim, bool escape) {
     string token;
     bool in_token = false;
     bool escaped = false;
-    for (auto c = text.cbegin(); c != text.cend(); ++c) {
-        if (delim.find(*c) != string::npos) {
+    for (auto const& c : text) {
+        if (delim.find(c) != string::npos) {
             // Current character is a delimiter
             if (!in_token) {
                 // Two or more delimiters, eat them
             } else if (escaped) {
                 // Escaped delimiter in a token: reset escaped and keep it
                 escaped = false;
-                token.push_back(*c);
+                token.push_back(c);
             } else {
                 // End of the current token: save it if not empty
                 if (!token.empty()) {
@@ -97,7 +97,7 @@ tokens(const std::string& text, const std::string& delim, bool escape) {
                 in_token = false;
                 token.clear();
             }
-        } else if (escape && (*c == '\\')) {
+        } else if (escape && (c == '\\')) {
             // Current character is the escape character
             if (!in_token) {
                 // The escape character is the first character of a new token
@@ -106,7 +106,7 @@ tokens(const std::string& text, const std::string& delim, bool escape) {
             if (escaped) {
                 // Escaped escape: reset escaped and keep one character
                 escaped = false;
-                token.push_back(*c);
+                token.push_back(c);
             } else {
                 // Remember to keep the next character
                 escaped = true;
@@ -121,10 +121,10 @@ tokens(const std::string& text, const std::string& delim, bool escape) {
                 // Escaped common character: as escape was false
                 escaped = false;
                 token.push_back('\\');
-                token.push_back(*c);
+                token.push_back(c);
             } else {
                 // The common case: keep it
-                token.push_back(*c);
+                token.push_back(c);
             }
         }
     }
index 4182692efe64f16e849469577dae940982f50e55..d4a1914f19f53b1cb61d2417cac7af2d9b67cf1b 100644 (file)
@@ -71,8 +71,8 @@ std::string trim(const std::string& instring);
 template<typename Iterator>
 Iterator
 seekTrimmed(Iterator begin, Iterator end, uint8_t trim_val) {
-    for ( ; end != begin && *(end - 1) == trim_val; --end);
-    return(end);
+    for (; end != begin && *(end - 1) == trim_val; --end);
+    return (end);
 }
 
 /// @brief Split String into Tokens
index bf28f6295e92c48311cd135b662944f8164475f1..83616b235453bef1df849090ecf9e54226a36859 100644 (file)
@@ -64,10 +64,8 @@ decodeCheck(const string& input_string, vector<uint8_t>& output,
 }
 
 TEST_F(Base32HexTest, decode) {
-    for (vector<StringPair>::const_iterator it = test_sequence.begin();
-         it != test_sequence.end();
-         ++it) {
-        decodeCheck((*it).second, decoded_data, (*it).first);
+    for (auto const& it : test_sequence) {
+        decodeCheck(it.second, decoded_data, it.first);
     }
 
     // whitespace should be allowed
@@ -94,19 +92,15 @@ TEST_F(Base32HexTest, decode) {
 }
 
 TEST_F(Base32HexTest, decodeLower) {
-    for (vector<StringPair>::const_iterator it = test_sequence_lower.begin();
-         it != test_sequence_lower.end();
-         ++it) {
-        decodeCheck((*it).second, decoded_data, (*it).first);
+    for (auto const& it : test_sequence_lower) {
+        decodeCheck(it.second, decoded_data, it.first);
     }
 }
 
 TEST_F(Base32HexTest, encode) {
-    for (vector<StringPair>::const_iterator it = test_sequence.begin();
-         it != test_sequence.end();
-         ++it) {
-        decoded_data.assign((*it).first.begin(), (*it).first.end());
-        EXPECT_EQ((*it).second, encodeBase32Hex(decoded_data));
+    for (auto const& it : test_sequence) {
+        decoded_data.assign(it.first.begin(), it.first.end());
+        EXPECT_EQ(it.second, encodeBase32Hex(decoded_data));
     }
 }
 
index 516925e539cd8565aac25799d06e8cbc361665ad..95b518bcad19d898b7fe585f0812de36f86e63bc 100644 (file)
@@ -50,10 +50,8 @@ decodeCheck(const string& input_string, vector<uint8_t>& output,
 }
 
 TEST_F(Base64Test, decode) {
-    for (vector<StringPair>::const_iterator it = test_sequence.begin();
-         it != test_sequence.end();
-         ++it) {
-        decodeCheck((*it).second, decoded_data, (*it).first);
+    for (auto const& it : test_sequence) {
+        decodeCheck(it.second, decoded_data, it.first);
     }
 
     // whitespace should be allowed
@@ -83,11 +81,9 @@ TEST_F(Base64Test, decode) {
 }
 
 TEST_F(Base64Test, encode) {
-    for (vector<StringPair>::const_iterator it = test_sequence.begin();
-         it != test_sequence.end();
-         ++it) {
-        decoded_data.assign((*it).first.begin(), (*it).first.end());
-        EXPECT_EQ((*it).second, encodeBase64(decoded_data));
+    for (auto const& it : test_sequence) {
+        decoded_data.assign(it.first.begin(), it.first.end());
+        EXPECT_EQ(it.second, encodeBase64(decoded_data));
     }
 }
 }
index 111cc37204057ab4be58cd60ccfc6f8bb5705423..8f01af3f4a37fc0c7010861ea6821aa690996075 100644 (file)
@@ -34,9 +34,8 @@ addTestDataPath(const string& path) {
 
 void
 openTestData(const char* const datafile, ifstream& ifs) {
-    for (vector<string>::const_iterator it = getDataPaths().begin();
-         it != getDataPaths().end(); ++it) {
-        string data_path = *it;
+    for (auto const& it : getDataPaths()) {
+        string data_path = it;
         if (data_path.empty() || *data_path.rbegin() != '/') {
             data_path.push_back('/');
         }
index 990a103f7238e813964bf18142a353bb9b8ee4a1..d6ff1f37d4903ffef63657b1017cfb1dae99d75b 100644 (file)
@@ -49,12 +49,11 @@ AdaptorHost::quoteIdentifier(ElementPtr host) {
     stringstream tmp;
     tmp << hex;
     bool delim = false;
-    for (vector<uint8_t>::const_iterator it = binary.begin();
-         it != binary.end(); ++it) {
+    for (auto const& it : binary) {
         if (delim) {
             tmp << ":";
         }
-        tmp << setw(2) << setfill('0') << static_cast<unsigned int>(*it);
+        tmp << setw(2) << setfill('0') << static_cast<unsigned int>(it);
         delim = true;
     }
     host->set("flex-id", Element::create(tmp.str()));
index cb7396ca391ec85bd3748fa9e75fe001da8e3067..a25bf8e8025cbe5f72026d78700759ca2d8907eb 100644 (file)
@@ -324,7 +324,7 @@ TEST_F(ConfigTestKeaV4, examples4) {
         "vivso.json",
         //"with-ddns.json",
     };
-    for (const string& file : examples) {
+    for (auto const& file : examples) {
         resetSession();
         string path = string(CFG_EXAMPLES) + "/kea4/" + file;
         SCOPED_TRACE("\n* Tested file: " + path);
@@ -367,7 +367,7 @@ TEST_F(ConfigTestKeaV6, examples6) {
         "tee-times.json",
         //"with-ddns.json",
     };
-    for (const string& file : examples) {
+    for (auto const& file : examples) {
         resetSession();
         string path = string(CFG_EXAMPLES) + "/kea6/" + file;
         SCOPED_TRACE("\n* Tested file: " + path);