Avoid deprecated ndn-cxx functions
Change-Id: I5d9ac045740267db783ff724c938b659b49c40ee
diff --git a/tools/chunks/putchunks/producer.cpp b/tools/chunks/putchunks/producer.cpp
index 0a39c3b..c353817 100644
--- a/tools/chunks/putchunks/producer.cpp
+++ b/tools/chunks/putchunks/producer.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -41,7 +41,7 @@
, m_keyChain(keyChain)
, m_options(opts)
{
- if (prefix.size() > 0 && prefix[-1].isVersion()) {
+ if (!prefix.empty() && prefix[-1].isVersion()) {
m_prefix = prefix.getPrefix(-1);
m_versionedPrefix = prefix;
}
@@ -115,7 +115,7 @@
void
Producer::processSegmentInterest(const Interest& interest)
{
- BOOST_ASSERT(m_store.size() > 0);
+ BOOST_ASSERT(!m_store.empty());
if (m_options.isVerbose)
std::cerr << "Interest: " << interest << "\n";
@@ -164,7 +164,7 @@
if (nCharsRead > 0) {
auto data = make_shared<Data>(Name(m_versionedPrefix).appendSegment(m_store.size()));
data->setFreshnessPeriod(m_options.freshnessPeriod);
- data->setContent(buffer.data(), static_cast<size_t>(nCharsRead));
+ data->setContent(make_span(buffer).first(nCharsRead));
m_store.push_back(data);
}
}
diff --git a/tools/dump/ndndump.cpp b/tools/dump/ndndump.cpp
index ed7fd93..cb1583f 100644
--- a/tools/dump/ndndump.cpp
+++ b/tools/dump/ndndump.cpp
@@ -207,8 +207,7 @@
shouldPrint = printPpp(out, payload, pkthdr->len);
break;
default:
- BOOST_ASSERT(false);
- return;
+ NDN_CXX_UNREACHABLE;
}
if (shouldPrint) {
@@ -220,9 +219,9 @@
}
void
-NdnDump::printTimestamp(std::ostream& os, const timeval& tv) const
+NdnDump::printTimestamp(std::ostream& os, const timeval& tv)
{
- /// \todo Add more timestamp formats (time since previous packet, time since first packet, ...)
+ // TODO: Add more timestamp formats (time since previous packet, time since first packet, ...)
os << tv.tv_sec
<< "."
<< std::setfill('0') << std::setw(6) << tv.tv_usec
@@ -520,7 +519,7 @@
bool isOk = false;
Block block;
- std::tie(isOk, block) = Block::fromBuffer(pkt, len);
+ std::tie(isOk, block) = Block::fromBuffer({pkt, len});
if (!isOk) {
// if packet is incomplete, we will not be able to process it
out << "NDN truncated packet, length " << len;
@@ -549,8 +548,7 @@
return true;
}
- bool isOk = false;
- std::tie(isOk, netPacket) = Block::fromBuffer(&*begin, std::distance(begin, end));
+ std::tie(isOk, netPacket) = Block::fromBuffer({begin, end});
if (!isOk) {
// if network packet is fragmented, we will not be able to process it
out << " fragment";
diff --git a/tools/dump/ndndump.hpp b/tools/dump/ndndump.hpp
index 58ba032..47a455a 100644
--- a/tools/dump/ndndump.hpp
+++ b/tools/dump/ndndump.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2011-2019, Regents of the University of California.
+ * Copyright (c) 2011-2022, Regents of the University of California.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -66,8 +66,8 @@
}
private:
- void
- printTimestamp(std::ostream& os, const timeval& tv) const;
+ static void
+ printTimestamp(std::ostream& os, const timeval& tv);
bool
dispatchByEtherType(OutputFormatter& out, const uint8_t* pkt, size_t len, uint16_t etherType) const;