dissect+peek: avoid deprecated ndn-cxx functions

Change-Id: Ibd9f8ad30e315f537d1560db823372af3d58d713
diff --git a/core/common.hpp b/core/common.hpp
index 614dd4e..06e4fe1 100644
--- a/core/common.hpp
+++ b/core/common.hpp
@@ -44,6 +44,7 @@
 #include <iostream>
 #include <limits>
 #include <memory>
+#include <optional>
 #include <stdexcept>
 #include <string>
 #include <string_view>
diff --git a/tests/chunks/discover-version.t.cpp b/tests/chunks/discover-version.t.cpp
index 7d18886..a07ecce 100644
--- a/tests/chunks/discover-version.t.cpp
+++ b/tests/chunks/discover-version.t.cpp
@@ -63,8 +63,8 @@
   util::DummyClientFace face{m_io};
   Options opt;
   unique_ptr<DiscoverVersion> discover;
-  optional<Name> discoveredName;
-  optional<uint64_t> discoveredVersion;
+  std::optional<Name> discoveredName;
+  std::optional<uint64_t> discoveredVersion;
   bool isDiscoveryFinished = false;
 };
 
diff --git a/tests/peek/ndnpeek.t.cpp b/tests/peek/ndnpeek.t.cpp
index 30c305a..c3979fd 100644
--- a/tests/peek/ndnpeek.t.cpp
+++ b/tests/peek/ndnpeek.t.cpp
@@ -86,7 +86,7 @@
   checkOutput(output_test_stream& output, const Data& data)
   {
     const Block& block = data.wireEncode();
-    std::string expected(reinterpret_cast<const char*>(block.wire()), block.size());
+    std::string expected(reinterpret_cast<const char*>(block.data()), block.size());
     BOOST_CHECK(output.is_equal(expected));
   }
 
@@ -94,7 +94,7 @@
   checkOutput(output_test_stream& output, const lp::Nack& nack)
   {
     const Block& block = nack.getHeader().wireEncode();
-    std::string expected(reinterpret_cast<const char*>(block.wire()), block.size());
+    std::string expected(reinterpret_cast<const char*>(block.data()), block.size());
     BOOST_CHECK(output.is_equal(expected));
   }
 };
@@ -252,7 +252,7 @@
 {
   auto options = makeDefaultOptions();
   options.interestLifetime = 1_s;
-  options.timeout = nullopt;
+  options.timeout = std::nullopt;
   initialize(options);
 
   BOOST_CHECK_EQUAL(face.sentInterests.size(), 0);
diff --git a/tools/dissect/dissector.cpp b/tools/dissect/dissector.cpp
index c612352..4a64f18 100644
--- a/tools/dissect/dissector.cpp
+++ b/tools/dissect/dissector.cpp
@@ -27,7 +27,7 @@
 #include <map>
 
 #include <ndn-cxx/encoding/tlv.hpp>
-#include <ndn-cxx/name-component.hpp>
+#include <ndn-cxx/util/string-helper.hpp>
 
 namespace ndn::dissect {
 
@@ -168,7 +168,7 @@
   const auto& elements = block.elements();
   if (elements.empty()) {
     m_out << " [[";
-    name::Component(block.value(), block.value_size()).toUri(m_out);
+    escape(m_out, reinterpret_cast<const char*>(block.value()), block.value_size());
     m_out << "]]";
   }
   m_out << "\n";
diff --git a/tools/dump/ndndump.hpp b/tools/dump/ndndump.hpp
index 9d786e7..83b0710 100644
--- a/tools/dump/ndndump.hpp
+++ b/tools/dump/ndndump.hpp
@@ -105,7 +105,7 @@
   std::string interface;
   std::string inputFile;
   std::string pcapFilter{getDefaultPcapFilter()};
-  optional<std::regex> nameFilter;
+  std::optional<std::regex> nameFilter;
   bool wantPromisc = true;
   bool wantTimestamp = true;
   bool wantVerbose = false;
diff --git a/tools/peek/ndnpeek/ndnpeek.cpp b/tools/peek/ndnpeek/ndnpeek.cpp
index d58b92e..3fb540f 100644
--- a/tools/peek/ndnpeek/ndnpeek.cpp
+++ b/tools/peek/ndnpeek/ndnpeek.cpp
@@ -64,7 +64,9 @@
   interest.setMustBeFresh(m_options.mustBeFresh);
   interest.setForwardingHint(m_options.forwardingHint);
   interest.setInterestLifetime(m_options.interestLifetime);
-  interest.setHopLimit(m_options.hopLimit);
+  if (m_options.hopLimit) {
+    interest.setHopLimit(*m_options.hopLimit);
+  }
   if (m_options.applicationParameters) {
     interest.setApplicationParameters(m_options.applicationParameters);
   }
@@ -76,6 +78,12 @@
   return interest;
 }
 
+static void
+writeToCout(span<const uint8_t> bytes)
+{
+  std::cout.write(reinterpret_cast<const char*>(bytes.data()), bytes.size());
+}
+
 void
 NdnPeek::onData(const Data& data)
 {
@@ -89,12 +97,10 @@
   }
 
   if (m_options.wantPayloadOnly) {
-    const Block& block = data.getContent();
-    std::cout.write(reinterpret_cast<const char*>(block.value()), block.value_size());
+    writeToCout(data.getContent().value_bytes());
   }
   else {
-    const Block& block = data.wireEncode();
-    std::cout.write(reinterpret_cast<const char*>(block.wire()), block.size());
+    writeToCout(data.wireEncode());
   }
 }
 
@@ -104,7 +110,7 @@
   m_result = Result::NACK;
   m_timeoutEvent.cancel();
 
-  lp::NackHeader header = nack.getHeader();
+  const auto& header = nack.getHeader();
   if (m_options.isVerbose) {
     std::cerr << "NACK: " << header.getReason() << "\nRTT: "
               << time::duration_cast<time::milliseconds>(time::steady_clock::now() - m_sendTime).count()
@@ -115,8 +121,7 @@
     std::cout << header.getReason() << std::endl;
   }
   else {
-    const Block& block = header.wireEncode();
-    std::cout.write(reinterpret_cast<const char*>(block.wire()), block.size());
+    writeToCout(header.wireEncode());
   }
 }
 
diff --git a/tools/peek/ndnpeek/ndnpeek.hpp b/tools/peek/ndnpeek/ndnpeek.hpp
index eba1b1f..f7f246b 100644
--- a/tools/peek/ndnpeek/ndnpeek.hpp
+++ b/tools/peek/ndnpeek/ndnpeek.hpp
@@ -48,13 +48,13 @@
   bool mustBeFresh = false;
   std::vector<Name> forwardingHint;
   time::milliseconds interestLifetime = DEFAULT_INTEREST_LIFETIME;
-  optional<uint8_t> hopLimit;
+  std::optional<uint8_t> hopLimit;
   shared_ptr<Buffer> applicationParameters;
 
   // program behavior options
   bool isVerbose = false;
   bool wantPayloadOnly = false;
-  optional<time::milliseconds> timeout;
+  std::optional<time::milliseconds> timeout;
 };
 
 class NdnPeek : noncopyable
diff --git a/tools/peek/ndnpoke/ndnpoke.hpp b/tools/peek/ndnpoke/ndnpoke.hpp
index 16a3795..a3cd393 100644
--- a/tools/peek/ndnpoke/ndnpoke.hpp
+++ b/tools/peek/ndnpoke/ndnpoke.hpp
@@ -49,7 +49,7 @@
   // program behavior options
   bool isVerbose = false;
   bool wantUnsolicited = false;
-  optional<time::milliseconds> timeout;
+  std::optional<time::milliseconds> timeout;
 };
 
 class NdnPoke : noncopyable
diff --git a/wscript b/wscript
index 92b710c..0bfb7f6 100644
--- a/wscript
+++ b/wscript
@@ -27,8 +27,9 @@
 
     conf.env.WITH_TESTS = conf.options.with_tests
 
-    conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], uselib_store='NDN_CXX',
-                   pkg_config_path=os.environ.get('PKG_CONFIG_PATH', '%s/pkgconfig' % conf.env.LIBDIR))
+    pkg_config_path = os.environ.get('PKG_CONFIG_PATH', f'{conf.env.LIBDIR}/pkgconfig')
+    conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.0', '--cflags', '--libs'],
+                   uselib_store='NDN_CXX', pkg_config_path=pkg_config_path)
 
     boost_libs = ['system', 'program_options', 'filesystem']
     if conf.env.WITH_TESTS: