Avoid using deprecated ndn-cxx functions
Change-Id: I51e0abcb7454e31efbcc779a17d2c490802108ec
diff --git a/src/clients/response.cpp b/src/clients/response.cpp
index 5f223d3..3da172b 100644
--- a/src/clients/response.cpp
+++ b/src/clients/response.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2020, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -26,7 +26,7 @@
Response::Response()
: m_contentType(NDNS_BLOB)
, m_freshnessPeriod(DEFAULT_RR_FRESHNESS_PERIOD)
- , m_appContent(makeBinaryBlock(ndn::tlv::Content, reinterpret_cast<const uint8_t*>(0), 0))
+ , m_appContent(makeEmptyBlock(ndn::tlv::Content))
{
}
@@ -35,12 +35,12 @@
, m_queryType(queryType)
, m_contentType(NDNS_BLOB)
, m_freshnessPeriod(DEFAULT_RR_FRESHNESS_PERIOD)
- , m_appContent(makeBinaryBlock(ndn::tlv::Content, reinterpret_cast<const uint8_t*>(0), 0))
+ , m_appContent(makeEmptyBlock(ndn::tlv::Content))
{
}
template<encoding::Tag T>
-inline size_t
+size_t
Response::wireEncode(EncodingImpl<T>& block) const
{
if (m_contentType == NDNS_BLOB || m_contentType == NDNS_KEY) {
@@ -52,8 +52,7 @@
// Block*
size_t totalLength = 0;
- for (std::vector<Block>::const_reverse_iterator iter = m_rrs.rbegin();
- iter != m_rrs.rend(); ++iter) {
+ for (auto iter = m_rrs.rbegin(); iter != m_rrs.rend(); ++iter) {
totalLength += block.prependBlock(*iter);
}
@@ -176,7 +175,7 @@
bool
Response::removeRr(const Block& rr)
{
- for (std::vector<Block>::iterator iter = m_rrs.begin(); iter != m_rrs.end(); ++iter) {
+ for (auto iter = m_rrs.begin(); iter != m_rrs.end(); ++iter) {
if (*iter == rr) {
m_rrs.erase(iter);
return true;
@@ -207,14 +206,13 @@
getRrType() == other.getRrType() && getVersion() == other.getVersion() &&
getContentType() == other.getContentType());
- if (tmp == false)
- return tmp;
+ if (!tmp)
+ return false;
- if (m_contentType == NDNS_BLOB || m_contentType == NDNS_KEY) {
- return tmp && (getAppContent() == other.getAppContent());
- }
+ if (m_contentType == NDNS_BLOB || m_contentType == NDNS_KEY)
+ return getAppContent() == other.getAppContent();
else
- return tmp && getRrs() == other.getRrs();
+ return getRrs() == other.getRrs();
}
std::ostream&
@@ -229,15 +227,16 @@
<< " NdnsContentType=" << response.getContentType();
if (response.getContentType() == NDNS_BLOB
|| response.getContentType() == NDNS_KEY) {
- if (response.getAppContent().empty())
- os << " appContent=NULL";
- else
+ if (response.getAppContent().isValid())
os << " appContentSize=" << response.getAppContent().size();
+ else
+ os << " appContent=NULL";
}
else {
os << " rrs.size=" << response.getRrs().size();
}
return os;
}
+
} // namespace ndns
} // namespace ndn
diff --git a/src/mgmt/management-tool.cpp b/src/mgmt/management-tool.cpp
index 3832561..3119840 100644
--- a/src/mgmt/management-tool.cpp
+++ b/src/mgmt/management-tool.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2020, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -447,7 +447,7 @@
os << "; rrset=" << rrset.getLabel().toUri()
<< " type=" << rrset.getType().toUri()
<< " version=" << rrset.getVersion().toUri()
- << " signed-by=" << data.getSignature().getKeyLocator().getName().toUri()
+ << " signed-by=" << data.getKeyLocator()->getName().toUri()
<< std::endl;
}
@@ -494,7 +494,7 @@
os.width();
os << "; content-type=" << re.getContentType()
<< " version=" << rrset.getVersion().toUri()
- << " signed-by=" << data.getSignature().getKeyLocator().getName().toUri();
+ << " signed-by=" << data.getKeyLocator()->getName().toUri();
os << std::endl;
if (printRaw && (re.getContentType() == NDNS_BLOB
diff --git a/src/util/util.cpp b/src/util/util.cpp
index 7d350a5..8466733 100644
--- a/src/util/util.cpp
+++ b/src/util/util.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California.
+ * Copyright (c) 2014-2020, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -64,8 +64,11 @@
bufferSource(block.wire(), block.size()) >> base64Encode() >> streamSink(os);
}
else {
- os << "Name: " << data.getName().toUri() << std::endl;
- os << "KeyLocator: " << data.getSignature().getKeyLocator().getName().toUri() << std::endl;
+ os << "Name: " << data.getName() << std::endl;
+ auto kl = data.getKeyLocator();
+ if (kl) {
+ os << "KeyLocator: " << kl->getName() << std::endl;
+ }
bufferSource(block.wire(), block.size()) >> base64Encode() >> streamSink(os);
os << std::endl;
}