name: deprecate append() overload with confusing semantics
Refs: #5186
Change-Id: Ib334076ef89dc389b56953302a94104f79b717a7
diff --git a/ndn-cxx/mgmt/nfd/control-command.cpp b/ndn-cxx/mgmt/nfd/control-command.cpp
index 691e872..df3c95b 100644
--- a/ndn-cxx/mgmt/nfd/control-command.cpp
+++ b/ndn-cxx/mgmt/nfd/control-command.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2020 Regents of the University of California.
+ * Copyright (c) 2013-2021 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -60,10 +60,11 @@
{
this->validateRequest(parameters);
- Name name = commandPrefix;
- name.append(m_module).append(m_verb);
- name.append(parameters.wireEncode());
- return name;
+ const auto& paramBlock = parameters.wireEncode();
+ return Name(commandPrefix)
+ .append(m_module)
+ .append(m_verb)
+ .append(paramBlock.begin(), paramBlock.end());
}
ControlCommand::FieldValidator::FieldValidator()
@@ -75,7 +76,7 @@
void
ControlCommand::FieldValidator::validate(const ControlParameters& parameters) const
{
- const std::vector<bool>& presentFields = parameters.getPresentFields();
+ const auto& presentFields = parameters.getPresentFields();
for (size_t i = 0; i < CONTROL_PARAMETER_UBOUND; ++i) {
bool isPresent = presentFields[i];
diff --git a/ndn-cxx/mgmt/nfd/status-dataset.cpp b/ndn-cxx/mgmt/nfd/status-dataset.cpp
index 3d2a3d3..1c550af 100644
--- a/ndn-cxx/mgmt/nfd/status-dataset.cpp
+++ b/ndn-cxx/mgmt/nfd/status-dataset.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2019 Regents of the University of California.
+ * Copyright (c) 2013-2021 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -42,7 +42,7 @@
}
void
-StatusDataset::addParameters(Name& name) const
+StatusDataset::addParameters(Name&) const
{
}
@@ -113,7 +113,8 @@
void
FaceQueryDataset::addParameters(Name& name) const
{
- name.append(m_filter.wireEncode());
+ const auto& filterBlock = m_filter.wireEncode();
+ name.append(filterBlock.begin(), filterBlock.end());
}
ChannelDataset::ChannelDataset()
diff --git a/ndn-cxx/name.hpp b/ndn-cxx/name.hpp
index a061d65..49a86f9 100644
--- a/ndn-cxx/name.hpp
+++ b/ndn-cxx/name.hpp
@@ -355,7 +355,9 @@
* @param value a TLV element. If its TLV-TYPE is tlv::GenericNameComponent, it is
* appended as is. Otherwise, it is nested into a GenericNameComponent.
* @return a reference to this name, to allow chaining.
+ * @deprecated
*/
+ [[deprecated]]
Name&
append(Block value)
{
diff --git a/ndn-cxx/security/key-chain.cpp b/ndn-cxx/security/key-chain.cpp
index 0328d0f..9c98c64 100644
--- a/ndn-cxx/security/key-chain.cpp
+++ b/ndn-cxx/security/key-chain.cpp
@@ -474,13 +474,17 @@
}
else {
Name signedName = interest.getName();
+
// We encode in Data format because this is the format used prior to Packet Specification v0.3
- signedName.append(sigInfo.wireEncode(SignatureInfo::Type::Data)); // SignatureInfo
+ const auto& sigInfoBlock = sigInfo.wireEncode(SignatureInfo::Type::Data);
+ signedName.append(sigInfoBlock.begin(), sigInfoBlock.end()); // SignatureInfo
+
Block sigValue(tlv::SignatureValue,
sign({{signedName.wireEncode().value(), signedName.wireEncode().value_size()}},
keyName, params.getDigestAlgorithm()));
sigValue.encode();
- signedName.append(std::move(sigValue)); // SignatureValue
+ signedName.append(sigValue.begin(), sigValue.end()); // SignatureValue
+
interest.setName(signedName);
}
}
diff --git a/tests/unit/mgmt/nfd/status-dataset.t.cpp b/tests/unit/mgmt/nfd/status-dataset.t.cpp
index 44fca44..21fb288 100644
--- a/tests/unit/mgmt/nfd/status-dataset.t.cpp
+++ b/tests/unit/mgmt/nfd/status-dataset.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2020 Regents of the University of California.
+ * Copyright (c) 2013-2021 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -113,7 +113,7 @@
CommandOptions options;
options.setTimeout(3000_ms);
controller.fetch<FaceDataset>(
- [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
+ [] (auto&&) { BOOST_FAIL("fetchDataset should not succeed"); },
datasetFailCallback,
options);
this->advanceClocks(500_ms);
@@ -128,7 +128,7 @@
BOOST_AUTO_TEST_CASE(DataHasNoSegment)
{
controller.fetch<FaceDataset>(
- [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
+ [] (auto&&) { BOOST_FAIL("fetchDataset should not succeed"); },
datasetFailCallback);
this->advanceClocks(500_ms);
@@ -146,7 +146,7 @@
this->setValidationResult(false);
controller.fetch<FaceDataset>(
- [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
+ [] (auto&&) { BOOST_FAIL("fetchDataset should not succeed"); },
datasetFailCallback);
this->advanceClocks(500_ms);
@@ -162,7 +162,7 @@
BOOST_AUTO_TEST_CASE(Nack)
{
controller.fetch<FaceDataset>(
- [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
+ [] (auto&&) { BOOST_FAIL("fetchDataset should not succeed"); },
datasetFailCallback);
this->advanceClocks(500_ms);
@@ -177,7 +177,7 @@
BOOST_AUTO_TEST_CASE(ParseError1)
{
controller.fetch<FaceDataset>(
- [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
+ [] (auto&&) { BOOST_FAIL("fetchDataset should not succeed"); },
datasetFailCallback);
this->advanceClocks(500_ms);
@@ -192,7 +192,7 @@
BOOST_AUTO_TEST_CASE(ParseError2)
{
controller.fetch<FaceDataset>(
- [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
+ [] (auto&&) { BOOST_FAIL("fetchDataset should not succeed"); },
datasetFailCallback);
this->advanceClocks(500_ms);
@@ -232,7 +232,7 @@
CommandOptions options;
options.setTimeout(3000_ms);
controller.fetch<FaceDataset>(
- [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
+ [] (auto&&) { BOOST_FAIL("fetchDataset should not succeed"); },
nullptr,
options);
BOOST_CHECK_NO_THROW(this->advanceClocks(500_ms, 7));
@@ -301,7 +301,7 @@
this->advanceClocks(500_ms);
Name prefix("/localhost/nfd/faces/query");
- prefix.append(filter.wireEncode());
+ prefix.append(filter.wireEncode().begin(), filter.wireEncode().end());
FaceStatus payload;
payload.setFaceId(8795);
this->sendDataset(prefix, payload);
@@ -330,7 +330,7 @@
this->advanceClocks(500_ms);
Name prefix("/localhost/nfd/faces/query");
- prefix.append(filter.wireEncode());
+ prefix.append(filter.wireEncode().begin(), filter.wireEncode().end());
FaceStatus payload;
payload.setFaceId(14022);
this->sendDataset(prefix, payload);