face/rib/tools: avoid deprecate Block::fromBuffer overloads

refs #2553

Change-Id: I32ea424ab7547f59fea2fca70ad6f41cd90bab58
diff --git a/tools/nfd-status.cpp b/tools/nfd-status.cpp
index 42a35be..9824d64 100644
--- a/tools/nfd-status.cpp
+++ b/tools/nfd-status.cpp
@@ -1,12 +1,12 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California,
- *                      Arizona Board of Regents,
- *                      Colorado State University,
- *                      University Pierre & Marie Curie, Sorbonne University,
- *                      Washington University in St. Louis,
- *                      Beijing Institute of Technology,
- *                      The University of Memphis
+ * Copyright (c) 2014-2015,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
  *
  * This file is part of NFD (Named Data Networking Forwarding Daemon).
  * See AUTHORS.md for complete list of NFD authors and contributors.
@@ -287,55 +287,51 @@
   afterFetchedChannelStatusInformation()
   {
     ConstBufferPtr buf = m_buffer->buf();
-    if (m_isOutputXml)
-      {
-        std::cout << "<channels>";
+    if (m_isOutputXml) {
+      std::cout << "<channels>";
 
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode ChannelStatus TLV" << std::endl;
-                break;
-              }
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode ChannelStatus TLV" << std::endl;
+          break;
+        }
 
-            offset += block.size();
+        offset += block.size();
 
-            nfd::ChannelStatus channelStatus(block);
+        nfd::ChannelStatus channelStatus(block);
 
-            std::cout << "<channel>";
-
-            std::string localUri(channelStatus.getLocalUri());
-            escapeSpecialCharacters(&localUri);
-            std::cout << "<localUri>" << localUri << "</localUri>";
-            std::cout << "</channel>";
-          }
-        std::cout << "</channels>";
+        std::cout << "<channel>";
+        std::string localUri(channelStatus.getLocalUri());
+        escapeSpecialCharacters(&localUri);
+        std::cout << "<localUri>" << localUri << "</localUri>";
+        std::cout << "</channel>";
       }
-    else
-      {
-        std::cout << "Channels:" << std::endl;
 
+      std::cout << "</channels>";
+    }
+    else {
+      std::cout << "Channels:" << std::endl;
+
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode ChannelStatus TLV" << std::endl;
-                break;
-              }
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode ChannelStatus TLV" << std::endl;
+          break;
+        }
 
-            offset += block.size();
+        offset += block.size();
 
-            nfd::ChannelStatus channelStatus(block);
-            std::cout << "  " << channelStatus.getLocalUri() << std::endl;
-          }
-       }
+        nfd::ChannelStatus channelStatus(block);
+        std::cout << "  " << channelStatus.getLocalUri() << std::endl;
+      }
+    }
 
     runNextStep();
   }
@@ -362,117 +358,113 @@
   afterFetchedFaceStatusInformation()
   {
     ConstBufferPtr buf = m_buffer->buf();
-    if (m_isOutputXml)
-      {
-        std::cout << "<faces>";
+    if (m_isOutputXml) {
+      std::cout << "<faces>";
 
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl;
-                break;
-              }
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl;
+          break;
+        }
 
-            offset += block.size();
+        offset += block.size();
 
-            nfd::FaceStatus faceStatus(block);
+        nfd::FaceStatus faceStatus(block);
 
-            std::cout << "<face>";
-            std::cout << "<faceId>" << faceStatus.getFaceId() << "</faceId>";
+        std::cout << "<face>";
+        std::cout << "<faceId>" << faceStatus.getFaceId() << "</faceId>";
 
-            std::string remoteUri(faceStatus.getRemoteUri());
-            escapeSpecialCharacters(&remoteUri);
-            std::cout << "<remoteUri>" << remoteUri << "</remoteUri>";
+        std::string remoteUri(faceStatus.getRemoteUri());
+        escapeSpecialCharacters(&remoteUri);
+        std::cout << "<remoteUri>" << remoteUri << "</remoteUri>";
 
-            std::string localUri(faceStatus.getLocalUri());
-            escapeSpecialCharacters(&localUri);
-            std::cout << "<localUri>" << localUri << "</localUri>";
+        std::string localUri(faceStatus.getLocalUri());
+        escapeSpecialCharacters(&localUri);
+        std::cout << "<localUri>" << localUri << "</localUri>";
 
-            if (faceStatus.hasExpirationPeriod()) {
-              std::cout << "<expirationPeriod>PT"
-                        << time::duration_cast<time::seconds>(faceStatus.getExpirationPeriod())
-                             .count() << "S"
-                        << "</expirationPeriod>";
-            }
+        if (faceStatus.hasExpirationPeriod()) {
+          std::cout << "<expirationPeriod>PT"
+                    << time::duration_cast<time::seconds>(faceStatus.getExpirationPeriod())
+                       .count() << "S"
+                    << "</expirationPeriod>";
+        }
 
-            std::cout << "<faceScope>" << faceStatus.getFaceScope()
-                      << "</faceScope>";
-            std::cout << "<facePersistency>" << faceStatus.getFacePersistency()
-                      << "</facePersistency>";
-            std::cout << "<linkType>" << faceStatus.getLinkType()
-                      << "</linkType>";
+        std::cout << "<faceScope>" << faceStatus.getFaceScope()
+                  << "</faceScope>";
+        std::cout << "<facePersistency>" << faceStatus.getFacePersistency()
+                  << "</facePersistency>";
+        std::cout << "<linkType>" << faceStatus.getLinkType()
+                  << "</linkType>";
 
-            std::cout << "<packetCounters>";
-            std::cout << "<incomingPackets>";
-            std::cout << "<nInterests>"       << faceStatus.getNInInterests()
-                      << "</nInterests>";
-            std::cout << "<nDatas>"           << faceStatus.getNInDatas()
-                      << "</nDatas>";
-            std::cout << "</incomingPackets>";
-            std::cout << "<outgoingPackets>";
-            std::cout << "<nInterests>"       << faceStatus.getNOutInterests()
-                      << "</nInterests>";
-            std::cout << "<nDatas>"           << faceStatus.getNOutDatas()
-                      << "</nDatas>";
-            std::cout << "</outgoingPackets>";
-            std::cout << "</packetCounters>";
+        std::cout << "<packetCounters>";
+        std::cout << "<incomingPackets>";
+        std::cout << "<nInterests>"       << faceStatus.getNInInterests()
+                  << "</nInterests>";
+        std::cout << "<nDatas>"           << faceStatus.getNInDatas()
+                  << "</nDatas>";
+        std::cout << "</incomingPackets>";
+        std::cout << "<outgoingPackets>";
+        std::cout << "<nInterests>"       << faceStatus.getNOutInterests()
+                  << "</nInterests>";
+        std::cout << "<nDatas>"           << faceStatus.getNOutDatas()
+                  << "</nDatas>";
+        std::cout << "</outgoingPackets>";
+        std::cout << "</packetCounters>";
 
-            std::cout << "<byteCounters>";
-            std::cout << "<incomingBytes>"    << faceStatus.getNInBytes()
-                      << "</incomingBytes>";
-            std::cout << "<outgoingBytes>"    << faceStatus.getNOutBytes()
-                      << "</outgoingBytes>";
-            std::cout << "</byteCounters>";
+        std::cout << "<byteCounters>";
+        std::cout << "<incomingBytes>"    << faceStatus.getNInBytes()
+                  << "</incomingBytes>";
+        std::cout << "<outgoingBytes>"    << faceStatus.getNOutBytes()
+                  << "</outgoingBytes>";
+        std::cout << "</byteCounters>";
 
-            std::cout << "</face>";
-          }
-        std::cout << "</faces>";
+        std::cout << "</face>";
       }
-    else
-      {
-        std::cout << "Faces:" << std::endl;
+      std::cout << "</faces>";
+    }
+    else {
+      std::cout << "Faces:" << std::endl;
 
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl;
-                break;
-              }
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl;
+          break;
+        }
 
-            offset += block.size();
+        offset += block.size();
 
-            nfd::FaceStatus faceStatus(block);
+        nfd::FaceStatus faceStatus(block);
 
-            std::cout << "  faceid=" << faceStatus.getFaceId()
-                      << " remote=" << faceStatus.getRemoteUri()
-                      << " local=" << faceStatus.getLocalUri();
-            if (faceStatus.hasExpirationPeriod()) {
-              std::cout  << " expires="
-                         << time::duration_cast<time::seconds>(faceStatus.getExpirationPeriod())
-                              .count() << "s";
-            }
-            std::cout << " counters={"
-                      << "in={" << faceStatus.getNInInterests() << "i "
-                      << faceStatus.getNInDatas() << "d "
-                      << faceStatus.getNInBytes() << "B}"
-                      << " out={" << faceStatus.getNOutInterests() << "i "
-                      << faceStatus.getNOutDatas() << "d "
-                      << faceStatus.getNOutBytes() << "B}"
-                      << "}";
-            std::cout << " " << faceStatus.getFaceScope()
-                      << " " << faceStatus.getFacePersistency()
-                      << " " << faceStatus.getLinkType();
-            std::cout << std::endl;
-          }
-       }
+        std::cout << "  faceid=" << faceStatus.getFaceId()
+                  << " remote=" << faceStatus.getRemoteUri()
+                  << " local=" << faceStatus.getLocalUri();
+        if (faceStatus.hasExpirationPeriod()) {
+          std::cout  << " expires="
+                     << time::duration_cast<time::seconds>(faceStatus.getExpirationPeriod())
+                        .count() << "s";
+        }
+        std::cout << " counters={"
+                  << "in={" << faceStatus.getNInInterests() << "i "
+                  << faceStatus.getNInDatas() << "d "
+                  << faceStatus.getNInBytes() << "B}"
+                  << " out={" << faceStatus.getNOutInterests() << "i "
+                  << faceStatus.getNOutDatas() << "d "
+                  << faceStatus.getNOutBytes() << "B}"
+                  << "}";
+        std::cout << " " << faceStatus.getFaceScope()
+                  << " " << faceStatus.getFacePersistency()
+                  << " " << faceStatus.getLinkType();
+        std::cout << std::endl;
+      }
+    }
 
     runNextStep();
   }
@@ -498,77 +490,69 @@
   afterFetchedFibEnumerationInformation()
   {
     ConstBufferPtr buf = m_buffer->buf();
-    if (m_isOutputXml)
-      {
-        std::cout << "<fib>";
+    if (m_isOutputXml) {
+      std::cout << "<fib>";
 
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode FibEntry TLV";
-                break;
-              }
-            offset += block.size();
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode FibEntry TLV";
+          break;
+        }
+        offset += block.size();
 
-            nfd::FibEntry fibEntry(block);
+        nfd::FibEntry fibEntry(block);
 
-            std::cout << "<fibEntry>";
-            std::string prefix(fibEntry.getPrefix().toUri());
-            escapeSpecialCharacters(&prefix);
-            std::cout << "<prefix>" << prefix << "</prefix>";
-            std::cout << "<nextHops>";
-            for (std::list<nfd::NextHopRecord>::const_iterator
-                   nextHop = fibEntry.getNextHopRecords().begin();
-                 nextHop != fibEntry.getNextHopRecords().end();
-                 ++nextHop)
-              {
-                std::cout << "<nextHop>" ;
-                std::cout << "<faceId>"  << nextHop->getFaceId() << "</faceId>";
-                std::cout << "<cost>"    << nextHop->getCost()   << "</cost>";
-                std::cout << "</nextHop>";
-              }
-            std::cout << "</nextHops>";
-            std::cout << "</fibEntry>";
-          }
-
-        std::cout << "</fib>";
+        std::cout << "<fibEntry>";
+        std::string prefix(fibEntry.getPrefix().toUri());
+        escapeSpecialCharacters(&prefix);
+        std::cout << "<prefix>" << prefix << "</prefix>";
+        std::cout << "<nextHops>";
+        for (const nfd::NextHopRecord& nextHop : fibEntry.getNextHopRecords()) {
+          std::cout << "<nextHop>" ;
+          std::cout << "<faceId>"  << nextHop.getFaceId() << "</faceId>";
+          std::cout << "<cost>"    << nextHop.getCost()   << "</cost>";
+          std::cout << "</nextHop>";
+        }
+        std::cout << "</nextHops>";
+        std::cout << "</fibEntry>";
       }
-    else
-      {
-        std::cout << "FIB:" << std::endl;
 
+      std::cout << "</fib>";
+    }
+    else {
+      std::cout << "FIB:" << std::endl;
+
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode FibEntry TLV" << std::endl;
-                break;
-              }
-            offset += block.size();
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode FibEntry TLV" << std::endl;
+          break;
+        }
+        offset += block.size();
 
-            nfd::FibEntry fibEntry(block);
+        nfd::FibEntry fibEntry(block);
 
-            std::cout << "  " << fibEntry.getPrefix() << " nexthops={";
-            for (std::list<nfd::NextHopRecord>::const_iterator
-                   nextHop = fibEntry.getNextHopRecords().begin();
-                 nextHop != fibEntry.getNextHopRecords().end();
-                 ++nextHop)
-              {
-                if (nextHop != fibEntry.getNextHopRecords().begin())
-                  std::cout << ", ";
-                std::cout << "faceid=" << nextHop->getFaceId()
-                          << " (cost=" << nextHop->getCost() << ")";
-              }
-            std::cout << "}" << std::endl;
-          }
+        std::cout << "  " << fibEntry.getPrefix() << " nexthops={";
+        bool isFirst = true;
+        for (const nfd::NextHopRecord& nextHop : fibEntry.getNextHopRecords()) {
+          if (isFirst)
+            isFirst = false;
+          else
+            std::cout << ", ";
+
+          std::cout << "faceid=" << nextHop.getFaceId()
+                    << " (cost=" << nextHop.getCost() << ")";
+        }
+        std::cout << "}" << std::endl;
       }
+    }
 
     runNextStep();
   }
@@ -594,63 +578,59 @@
   afterFetchedStrategyChoiceInformationInformation()
   {
     ConstBufferPtr buf = m_buffer->buf();
-    if (m_isOutputXml)
-      {
-        std::cout << "<strategyChoices>";
+    if (m_isOutputXml) {
+      std::cout << "<strategyChoices>";
 
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode StrategyChoice TLV";
-                break;
-              }
-            offset += block.size();
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode StrategyChoice TLV";
+          break;
+        }
+        offset += block.size();
 
-            nfd::StrategyChoice strategyChoice(block);
+        nfd::StrategyChoice strategyChoice(block);
 
-            std::cout << "<strategyChoice>";
+        std::cout << "<strategyChoice>";
 
-            std::string name(strategyChoice.getName().toUri());
-            escapeSpecialCharacters(&name);
-            std::cout << "<namespace>" << name << "</namespace>";
-            std::cout << "<strategy>";
+        std::string name(strategyChoice.getName().toUri());
+        escapeSpecialCharacters(&name);
+        std::cout << "<namespace>" << name << "</namespace>";
+        std::cout << "<strategy>";
 
-            std::string strategy(strategyChoice.getStrategy().toUri());
-            escapeSpecialCharacters(&strategy);
+        std::string strategy(strategyChoice.getStrategy().toUri());
+        escapeSpecialCharacters(&strategy);
 
-            std::cout << "<name>" << strategy << "</name>";
-            std::cout << "</strategy>";
-            std::cout << "</strategyChoice>";
-          }
-
-        std::cout << "</strategyChoices>";
+        std::cout << "<name>" << strategy << "</name>";
+        std::cout << "</strategy>";
+        std::cout << "</strategyChoice>";
       }
-    else
-      {
-        std::cout << "Strategy choices:" << std::endl;
 
+      std::cout << "</strategyChoices>";
+    }
+    else {
+      std::cout << "Strategy choices:" << std::endl;
+
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode StrategyChoice TLV" << std::endl;
-                break;
-              }
-            offset += block.size();
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode StrategyChoice TLV" << std::endl;
+          break;
+        }
+        offset += block.size();
 
-            nfd::StrategyChoice strategyChoice(block);
+        nfd::StrategyChoice strategyChoice(block);
 
-            std::cout << "  " << strategyChoice.getName()
-                      << " strategy=" << strategyChoice.getStrategy() << std::endl;
-          }
+        std::cout << "  " << strategyChoice.getName()
+                  << " strategy=" << strategyChoice.getStrategy() << std::endl;
       }
+    }
 
     runNextStep();
   }
@@ -674,106 +654,98 @@
   afterFetchedRibStatusInformation()
   {
     ConstBufferPtr buf = m_buffer->buf();
-    if (m_isOutputXml)
-      {
-        std::cout << "<rib>";
+    if (m_isOutputXml) {
+      std::cout << "<rib>";
 
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode RibEntry TLV";
-                break;
-              }
-            offset += block.size();
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode RibEntry TLV";
+          break;
+        }
+        offset += block.size();
 
-            nfd::RibEntry ribEntry(block);
+        nfd::RibEntry ribEntry(block);
 
-            std::cout << "<ribEntry>";
-            std::string prefix(ribEntry.getName().toUri());
-            escapeSpecialCharacters(&prefix);
-            std::cout << "<prefix>" << prefix << "</prefix>";
-            std::cout << "<routes>";
-            for (std::list<nfd::Route>::const_iterator
-                   nextRoute = ribEntry.begin();
-                 nextRoute != ribEntry.end();
-                 ++nextRoute)
-              {
-                std::cout << "<route>" ;
-                std::cout << "<faceId>"  << nextRoute->getFaceId() << "</faceId>";
-                std::cout << "<origin>"  << nextRoute->getOrigin() << "</origin>";
-                std::cout << "<cost>"    << nextRoute->getCost()   << "</cost>";
+        std::cout << "<ribEntry>";
+        std::string prefix(ribEntry.getName().toUri());
+        escapeSpecialCharacters(&prefix);
+        std::cout << "<prefix>" << prefix << "</prefix>";
+        std::cout << "<routes>";
+        for (const nfd::Route& nextRoute : ribEntry) {
+          std::cout << "<route>" ;
+          std::cout << "<faceId>"  << nextRoute.getFaceId() << "</faceId>";
+          std::cout << "<origin>"  << nextRoute.getOrigin() << "</origin>";
+          std::cout << "<cost>"    << nextRoute.getCost()   << "</cost>";
 
-                std::cout << "<flags>";
-                if (nextRoute->isChildInherit())
-                  std::cout << "<childInherit/>";
-                if (nextRoute->isRibCapture())
-                  std::cout << "<ribCapture/>";
-                std::cout << "</flags>";
+          std::cout << "<flags>";
+          if (nextRoute.isChildInherit())
+            std::cout << "<childInherit/>";
+          if (nextRoute.isRibCapture())
+            std::cout << "<ribCapture/>";
+          std::cout << "</flags>";
 
-                if (!nextRoute->hasInfiniteExpirationPeriod()) {
-                  std::cout << "<expirationPeriod>PT"
-                            << time::duration_cast<time::seconds>(nextRoute->getExpirationPeriod())
-                                 .count() << "S"
-                            << "</expirationPeriod>";
-                }
-                std::cout << "</route>";
-              }
-            std::cout << "</routes>";
-            std::cout << "</ribEntry>";
+          if (!nextRoute.hasInfiniteExpirationPeriod()) {
+            std::cout << "<expirationPeriod>PT"
+                      << time::duration_cast<time::seconds>(nextRoute.getExpirationPeriod())
+                         .count() << "S"
+                      << "</expirationPeriod>";
           }
-
-        std::cout << "</rib>";
+          std::cout << "</route>";
+        }
+        std::cout << "</routes>";
+        std::cout << "</ribEntry>";
       }
-    else
-      {
-        std::cout << "RIB:" << std::endl;
 
+      std::cout << "</rib>";
+    }
+    else {
+      std::cout << "RIB:" << std::endl;
+
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode RibEntry TLV" << std::endl;
-                break;
-              }
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode RibEntry TLV" << std::endl;
+          break;
+        }
 
-            offset += block.size();
+        offset += block.size();
 
-            nfd::RibEntry ribEntry(block);
+        nfd::RibEntry ribEntry(block);
 
-            std::cout << "  " << ribEntry.getName().toUri() << " route={";
-            for (std::list<nfd::Route>::const_iterator
-                   nextRoute = ribEntry.begin();
-                 nextRoute != ribEntry.end();
-                 ++nextRoute)
-              {
-                if (nextRoute != ribEntry.begin())
-                  std::cout << ", ";
-                std::cout << "faceid="   << nextRoute->getFaceId()
-                          << " (origin="  << nextRoute->getOrigin()
-                          << " cost="    << nextRoute->getCost();
-                if (!nextRoute->hasInfiniteExpirationPeriod()) {
-                  std::cout << " expires="
-                            << time::duration_cast<time::seconds>(nextRoute->getExpirationPeriod())
-                               .count() << "s";
-                }
+        std::cout << "  " << ribEntry.getName().toUri() << " route={";
+        bool isFirst = true;
+        for (const nfd::Route& nextRoute : ribEntry) {
+          if (isFirst)
+            isFirst = false;
+          else
+            std::cout << ", ";
 
-                if (nextRoute->isChildInherit())
-                  std::cout << " ChildInherit";
-                if (nextRoute->isRibCapture())
-                  std::cout << " RibCapture";
-
-                std::cout << ")";
-              }
-            std::cout << "}" << std::endl;
+          std::cout << "faceid="   << nextRoute.getFaceId()
+                    << " (origin="  << nextRoute.getOrigin()
+                    << " cost="    << nextRoute.getCost();
+          if (!nextRoute.hasInfiniteExpirationPeriod()) {
+            std::cout << " expires="
+                      << time::duration_cast<time::seconds>(nextRoute.getExpirationPeriod())
+                         .count() << "s";
           }
-       }
+
+          if (nextRoute.isChildInherit())
+            std::cout << " ChildInherit";
+          if (nextRoute.isRibCapture())
+            std::cout << " RibCapture";
+
+          std::cout << ")";
+        }
+        std::cout << "}" << std::endl;
+      }
+    }
 
     runNextStep();
   }