Avoid deprecated ndn-cxx functions
Change-Id: Ic9fab00b75e9519315ee776dbc464794a9e56f1c
diff --git a/examples/data-producer.cpp b/examples/data-producer.cpp
index e401603..0e1da2c 100644
--- a/examples/data-producer.cpp
+++ b/examples/data-producer.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-2022, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -138,7 +138,7 @@
std::string name;
getline(insertStream, name);
- auto data = createData(ndn::Name(name));
+ auto data = createData(name);
m_face.put(*data);
m_scheduler.schedule(timeInterval, [this] { generateFromFile(); });
@@ -148,11 +148,10 @@
Publisher::createData(const ndn::Name& name)
{
static ndn::KeyChain keyChain;
- static std::vector<uint8_t> content(1500, '-');
+ static const std::vector<uint8_t> content(1500, '-');
- auto data = std::make_shared<ndn::Data>();
- data->setName(name);
- data->setContent(content.data(), content.size());
+ auto data = std::make_shared<ndn::Data>(name);
+ data->setContent(content);
keyChain.sign(*data);
return data;
}
@@ -203,7 +202,7 @@
generator.duration = milliseconds(boost::lexical_cast<uint64_t>(optarg));
}
catch (const boost::bad_lexical_cast&) {
- std::cerr << "-s option should be an integer" << std::endl;;
+ std::cerr << "-s option should be an integer" << std::endl;
return 1;
}
break;
@@ -212,7 +211,7 @@
generator.timeInterval = milliseconds(boost::lexical_cast<uint64_t>(optarg));
}
catch (const boost::bad_lexical_cast&) {
- std::cerr << "-t option should be an integer" << std::endl;;
+ std::cerr << "-t option should be an integer" << std::endl;
return 1;
}
break;
diff --git a/src/handles/tcp-bulk-insert-handle.cpp b/src/handles/tcp-bulk-insert-handle.cpp
index 9c3f680..dc4042d 100644
--- a/src/handles/tcp-bulk-insert-handle.cpp
+++ b/src/handles/tcp-bulk-insert-handle.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-2022, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -85,7 +85,7 @@
ip::tcp::resolver::iterator end;
if (endpoint == end)
- BOOST_THROW_EXCEPTION(Error("Cannot listen on " + host + " port " + port));
+ NDN_THROW(Error("Cannot listen on " + host + " port " + port));
m_localEndpoint = *endpoint;
NDN_LOG_DEBUG("Start listening on " << m_localEndpoint);
@@ -157,17 +157,17 @@
// do magic
+ auto bufferView = ndn::make_span(m_inputBuffer, m_inputBufferSize);
std::size_t offset = 0;
-
bool isOk = true;
- Block element;
- while (m_inputBufferSize - offset > 0) {
- std::tie(isOk, element) = Block::fromBuffer(m_inputBuffer + offset, m_inputBufferSize - offset);
+ while (offset < bufferView.size()) {
+ Block element;
+ std::tie(isOk, element) = Block::fromBuffer(bufferView.subspan(offset));
if (!isOk)
break;
offset += element.size();
- BOOST_ASSERT(offset <= m_inputBufferSize);
+ BOOST_ASSERT(offset <= bufferView.size());
if (element.type() == ndn::tlv::Data) {
try {
@@ -178,9 +178,9 @@
else
NDN_LOG_DEBUG("FAILED to inject " << data.getName());
}
- catch (const std::runtime_error&) {
+ catch (const std::runtime_error& e) {
/// \todo Catch specific error after determining what wireDecode() can throw
- NDN_LOG_ERROR("Error decoding received Data packet");
+ NDN_LOG_ERROR("Error decoding received Data packet: " << e.what());
}
}
}
diff --git a/tests/dataset-fixtures.hpp b/tests/dataset-fixtures.hpp
index 1a4e272..0d93347 100644
--- a/tests/dataset-fixtures.hpp
+++ b/tests/dataset-fixtures.hpp
@@ -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-2022, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -21,6 +21,7 @@
#define REPO_TESTS_DATASET_FIXTURES_HPP
#include "identity-management-fixture.hpp"
+
#include <vector>
#include <boost/mpl/vector.hpp>
@@ -33,11 +34,7 @@
class Error : public std::runtime_error
{
public:
- explicit
- Error(const std::string& what)
- : std::runtime_error(what)
- {
- }
+ using std::runtime_error::runtime_error;
};
using DataContainer = std::list<std::shared_ptr<ndn::Data>>;
@@ -56,11 +53,10 @@
if (map.count(name) > 0)
return map[name];
- static std::vector<uint8_t> content(1500, '-');
+ static const std::vector<uint8_t> content(1500, '-');
- std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>();
- data->setName(name);
- data->setContent(&content[0], content.size());
+ auto data = std::make_shared<ndn::Data>(name);
+ data->setContent(content);
m_keyChain.sign(*data);
map.insert(std::make_pair(name, data));
@@ -73,7 +69,7 @@
if (map.count(name) > 0)
return map[name];
else
- BOOST_THROW_EXCEPTION(Error("Data with name " + name.toUri() + " is not found"));
+ NDN_THROW(Error("Data with name " + name.toUri() + " is not found"));
}
private:
diff --git a/tests/integrated/test-basic-command-insert-delete.cpp b/tests/integrated/test-basic-command-insert-delete.cpp
index 03e9a54..5ed5b9b 100644
--- a/tests/integrated/test-basic-command-insert-delete.cpp
+++ b/tests/integrated/test-basic-command-insert-delete.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -32,7 +32,6 @@
#include <ndn-cxx/util/random.hpp>
#include <ndn-cxx/util/time.hpp>
-#include <boost/asio/io_service.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/test/unit_test.hpp>
@@ -44,7 +43,7 @@
// All the test cases in this test suite should be run at once.
BOOST_AUTO_TEST_SUITE(TestBasicCommandInsertDelete)
-const static uint8_t content[8] = {3, 1, 4, 1, 5, 9, 2, 6};
+const uint8_t CONTENT[] = {3, 1, 4, 1, 5, 9, 2, 6};
template<class Dataset>
class Fixture : public CommandFixture, public RepoStorageFixture, public Dataset
@@ -59,7 +58,7 @@
{
Name cmdPrefix("/repo/command");
repoFace.registerPrefix(cmdPrefix, nullptr,
- [] (const Name& cmdPrefix, const std::string& reason) {
+ [] (const Name&, const std::string& reason) {
BOOST_FAIL("Command prefix registration error: " << reason);
});
}
@@ -113,11 +112,12 @@
ndn::security::InterestSigner signer;
};
-template<class T> void
+template<class T>
+void
Fixture<T>::onInsertInterest(const Interest& interest)
{
Data data(Name(interest.getName()));
- data.setContent(content, sizeof(content));
+ data.setContent(CONTENT);
data.setFreshnessPeriod(0_ms);
keyChain.sign(data);
insertFace.put(data);
@@ -126,56 +126,62 @@
eventIt->second.cancel();
insertEvents.erase(eventIt);
}
- // schedule an event 50ms later to check whether insert is Ok
- scheduler.schedule(500_ms, std::bind(&Fixture<T>::checkInsertOk, this, interest));
+
+ // schedule an event to check whether insert is ok
+ scheduler.schedule(500_ms, [=] { this->checkInsertOk(interest); });
}
-template<class T> void
+template<class T>
+void
Fixture<T>::onRegisterFailed(const std::string& reason)
{
BOOST_ERROR("ERROR: Failed to register prefix in local hub's daemon" + reason);
}
-template<class T> void
+template<class T>
+void
Fixture<T>::delayedInterest()
{
BOOST_ERROR("Fetching interest does not come. It may be satisfied in CS or something is wrong");
}
-template<class T> void
-Fixture<T>::onInsertData(const Interest& interest, const Data& data)
+template<class T>
+void
+Fixture<T>::onInsertData(const Interest&, const Data& data)
{
RepoCommandResponse response;
response.wireDecode(data.getContent().blockFromValue());
- int statusCode = response.getCode();
- BOOST_CHECK_EQUAL(statusCode, 100);
+ BOOST_CHECK_EQUAL(response.getCode(), 100);
}
-template<class T> void
+template<class T>
+void
Fixture<T>::onDeleteData(const Interest& interest, const Data& data)
{
RepoCommandResponse response;
response.wireDecode(data.getContent().blockFromValue());
- int statusCode = response.getCode();
- BOOST_CHECK_EQUAL(statusCode, 200);
+ BOOST_CHECK_EQUAL(response.getCode(), 200);
- //schedlute an event to check whether delete is Ok.
- scheduler.schedule(100_ms, std::bind(&Fixture<T>::checkDeleteOk, this, interest));
+ // schedule an event to check whether delete is ok
+ scheduler.schedule(100_ms, [=] { this->checkDeleteOk(interest); });
}
-template<class T> void
-Fixture<T>::onInsertTimeout(const Interest& interest)
+template<class T>
+void
+Fixture<T>::onInsertTimeout(const Interest&)
{
BOOST_ERROR("Insert command timeout");
}
-template<class T> void
-Fixture<T>::onDeleteTimeout(const Interest& interest)
+template<class T>
+void
+Fixture<T>::onDeleteTimeout(const Interest&)
{
BOOST_ERROR("Delete command timeout");
}
-template<class T> void
+template<class T>
+void
Fixture<T>::sendInsertInterest(const Interest& insertInterest)
{
insertFace.expressInterest(insertInterest,
@@ -184,7 +190,8 @@
std::bind(&Fixture<T>::onInsertTimeout, this, _1));
}
-template<class T> void
+template<class T>
+void
Fixture<T>::sendDeleteInterest(const Interest& deleteInterest)
{
deleteFace.expressInterest(deleteInterest,
@@ -193,41 +200,43 @@
std::bind(&Fixture<T>::onDeleteTimeout, this, _1));
}
-template<class T> void
+template<class T>
+void
Fixture<T>::checkInsertOk(const Interest& interest)
{
- BOOST_TEST_MESSAGE(interest);
- std::shared_ptr<Data> data = handle->readData(interest);
- if (data) {
- int rc = memcmp(data->getContent().value(), content, sizeof(content));
- BOOST_CHECK_EQUAL(rc, 0);
- }
- else {
- BOOST_ERROR("Check Insert Failed");
+ BOOST_TEST_CONTEXT("Interest " << interest) {
+ auto data = handle->readData(interest);
+ if (data) {
+ BOOST_TEST(data->getContent().value_bytes() == CONTENT, boost::test_tools::per_element());
+ }
+ else {
+ BOOST_ERROR("Insert check failed");
+ }
}
}
-template<class T> void
+template<class T>
+void
Fixture<T>::checkDeleteOk(const Interest& interest)
{
- std::map<Name, Name>::iterator name = deleteNamePairs.find(interest.getName());
- BOOST_CHECK_MESSAGE(name != deleteNamePairs.end(), "Delete name not found: " << interest.getName());
- Interest dataInterest(name->second);
- std::shared_ptr<Data> data = handle->readData(dataInterest);
+ auto nameIt = deleteNamePairs.find(interest.getName());
+ BOOST_CHECK_MESSAGE(nameIt != deleteNamePairs.end(), "Delete name not found: " << interest.getName());
+ Interest dataInterest(nameIt->second);
+ auto data = handle->readData(dataInterest);
BOOST_CHECK(!data);
}
-template<class T> void
+template<class T>
+void
Fixture<T>::scheduleInsertEvent()
{
int timeCount = 1;
- for (typename T::DataContainer::iterator i = this->data.begin();
- i != this->data.end(); ++i) {
+ for (auto i = this->data.begin(); i != this->data.end(); ++i) {
Name insertCommandName("/repo/command/insert");
RepoCommandParameter insertParameter;
insertParameter.setName(Name((*i)->getName())
.appendNumber(ndn::random::generateWord64()));
- insertCommandName.append(insertParameter.wireEncode());
+ insertCommandName.append(tlv::GenericNameComponent, insertParameter.wireEncode());
Interest insertInterest = signer.makeCommandInterest(insertCommandName);
// schedule a job to express insertInterest every 50ms
scheduler.schedule(milliseconds(timeCount * 50 + 1000),
@@ -245,17 +254,17 @@
}
}
-template<class T> void
+template<class T>
+void
Fixture<T>::scheduleDeleteEvent()
{
int timeCount = 1;
- for (typename T::DataContainer::iterator i = this->data.begin();
- i != this->data.end(); ++i) {
+ for (auto i = this->data.begin(); i != this->data.end(); ++i) {
Name deleteCommandName("/repo/command/delete");
RepoCommandParameter deleteParameter;
deleteParameter.setProcessId(ndn::random::generateWord64());
deleteParameter.setName((*i)->getName());
- deleteCommandName.append(deleteParameter.wireEncode());
+ deleteCommandName.append(tlv::GenericNameComponent, deleteParameter.wireEncode());
Interest deleteInterest = signer.makeCommandInterest(deleteCommandName);
deleteNamePairs[deleteInterest.getName()] = (*i)->getName();
scheduler.schedule(milliseconds(4000 + timeCount * 50),
@@ -271,8 +280,8 @@
BOOST_FIXTURE_TEST_CASE_TEMPLATE(InsertDelete, T, Datasets, Fixture<T>)
{
// schedule events
- this->scheduler.schedule(0_s, std::bind(&Fixture<T>::scheduleInsertEvent, this));
- this->scheduler.schedule(10_s, std::bind(&Fixture<T>::scheduleDeleteEvent, this));
+ this->scheduler.schedule(0_s, [this] { this->scheduleInsertEvent(); });
+ this->scheduler.schedule(10_s, [this] { this->scheduleDeleteEvent(); });
this->repoFace.processEvents(30_s);
}
diff --git a/tests/integrated/test-basic-interest-read.cpp b/tests/integrated/test-basic-interest-read.cpp
index 81ace5b..ab3da01 100644
--- a/tests/integrated/test-basic-interest-read.cpp
+++ b/tests/integrated/test-basic-interest-read.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-2022, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -27,17 +27,14 @@
#include <boost/asio/io_service.hpp>
#include <boost/test/unit_test.hpp>
-#include <ndn-cxx/util/logger.hpp>
#include <ndn-cxx/util/time.hpp>
namespace repo {
namespace tests {
-NDN_LOG_INIT(repo.tests.read);
+BOOST_AUTO_TEST_SUITE(TestBasicInterestRead)
-BOOST_AUTO_TEST_SUITE(TestBasicInerestRead)
-
-const static uint8_t content[8] = {3, 1, 4, 1, 5, 9, 2, 6};
+const uint8_t CONTENT[] = {3, 1, 4, 1, 5, 9, 2, 6};
template<class Dataset>
class BasicInterestReadFixture : public RepoStorageFixture, public Dataset
@@ -65,17 +62,13 @@
scheduleReadEvent()
{
int timeCount = 1;
- for (typename Dataset::DataContainer::iterator i = this->data.begin();
- i != this->data.end(); ++i) {
- //First insert a data into database;
- (*i)->setContent(content, sizeof(content));
+ for (auto i = this->data.begin(); i != this->data.end(); ++i) {
+ // First insert a data into database
+ (*i)->setContent(CONTENT);
(*i)->setFreshnessPeriod(36000_ms);
keyChain.sign(**i);
- NDN_LOG_DEBUG(**i);
bool rc = handle->insertData(**i);
-
BOOST_CHECK_EQUAL(rc, true);
- NDN_LOG_DEBUG("Inserted Data " << (**i).getName());
Interest readInterest((*i)->getName());
readInterest.setMustBeFresh(true);
@@ -86,30 +79,26 @@
}
void
- onReadData(const ndn::Interest& interest, const ndn::Data& data)
+ onReadData(const ndn::Interest&, const ndn::Data& data) const
{
- int rc = memcmp(data.getContent().value(), content, sizeof(content));
- BOOST_CHECK_EQUAL(rc, 0);
+ BOOST_TEST(data.getContent().value_bytes() == CONTENT, boost::test_tools::per_element());
}
void
- onReadTimeout(const ndn::Interest& interest)
+ onReadTimeout(const ndn::Interest& interest) const
{
- NDN_LOG_DEBUG("Timed out " << interest.getName());
- BOOST_ERROR("Insert or read not successfull");
+ BOOST_ERROR("Read timeout " << interest.getName());
}
void
- onReadNack(const ndn::Interest& interest, const ndn::lp::Nack& nack)
+ onReadNack(const ndn::Interest& interest, const ndn::lp::Nack& nack) const
{
- NDN_LOG_DEBUG("Nacked " << interest.getName() << nack.getReason());
- BOOST_ERROR("Read nacked");
+ BOOST_ERROR("Read nack " << interest.getName() << " " << nack.getReason());
}
void
sendInterest(const ndn::Interest& interest)
{
- NDN_LOG_DEBUG("Sending Interest " << interest.getName());
readFace.expressInterest(interest,
std::bind(&BasicInterestReadFixture::onReadData, this, _1, _2),
std::bind(&BasicInterestReadFixture::onReadNack, this, _1, _2),
@@ -124,7 +113,6 @@
ndn::Face readFace;
};
-
using Datasets = boost::mpl::vector<BasicDataset,
FetchByPrefixDataset,
SamePrefixDataset<10>>;
@@ -132,7 +120,7 @@
BOOST_FIXTURE_TEST_CASE_TEMPLATE(Read, T, Datasets, BasicInterestReadFixture<T>)
{
this->startListen();
- this->scheduler.schedule(1_s, std::bind(&BasicInterestReadFixture<T>::scheduleReadEvent, this));
+ this->scheduler.schedule(1_s, [this] { this->scheduleReadEvent(); });
this->repoFace.processEvents(20_s);
}
diff --git a/tests/unit/read-handle.t.cpp b/tests/unit/read-handle.t.cpp
index 1e22b4e..60a2ee2 100644
--- a/tests/unit/read-handle.t.cpp
+++ b/tests/unit/read-handle.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -86,8 +86,8 @@
auto data1 = std::make_shared<Data>(Name{dataPrefix}.appendNumber(1));
auto data2 = std::make_shared<Data>(Name{dataPrefix}.appendNumber(2));
- data1->setContent(&content[0], content.size());
- data2->setContent(&content[0], content.size());
+ data1->setContent(content);
+ data2->setContent(content);
keyChain.createIdentity(identity);
keyChain.sign(*data1, ndn::security::SigningInfo(ndn::security::SigningInfo::SIGNER_TYPE_ID,
diff --git a/tests/unit/tcp-bulk-insert-handle.cpp b/tests/unit/tcp-bulk-insert-handle.cpp
index 48d1ae3..da90117 100644
--- a/tests/unit/tcp-bulk-insert-handle.cpp
+++ b/tests/unit/tcp-bulk-insert-handle.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-2022, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -101,8 +101,7 @@
// scatter-gather is limited to at most `min(64,IOV_MAX)` buffers to be transmitted
// in a single operation
for (auto i = this->data.begin(); i != this->data.end(); ++i) {
-
- socket.async_send(boost::asio::buffer((*i)->wireEncode().wire(), (*i)->wireEncode().size()),
+ socket.async_send(boost::asio::buffer((*i)->wireEncode()),
std::bind(&TcpBulkInsertFixture::onSendFinished, this, _1, false));
}
onSendFinished(error, true);
@@ -148,7 +147,6 @@
repo::TcpBulkInsertHandle bulkInserter;
};
-
BOOST_FIXTURE_TEST_CASE_TEMPLATE(BulkInsertAndRead, T, CommonDatasets, TcpBulkInsertFixture<T>)
{
BOOST_TEST_MESSAGE(T::getName());
diff --git a/tools/ndnputfile.cpp b/tools/ndnputfile.cpp
index 78d4b8a..bed681a 100644
--- a/tools/ndnputfile.cpp
+++ b/tools/ndnputfile.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -155,8 +155,7 @@
bool m_isFinished;
ndn::Name m_dataPrefix;
- using DataContainer = std::map<uint64_t, shared_ptr<ndn::Data>>;
- DataContainer m_data;
+ std::map<uint64_t, std::shared_ptr<ndn::Data>> m_data;
ndn::security::InterestSigner m_cmdSigner;
};
@@ -185,7 +184,7 @@
auto readSize = boost::iostreams::read(*insertStream,
reinterpret_cast<char*>(buffer), DEFAULT_BLOCK_SIZE);
if (readSize <= 0) {
- BOOST_THROW_EXCEPTION(Error("Error reading from the input stream"));
+ NDN_THROW(Error("Error reading from the input stream"));
}
auto data = make_shared<ndn::Data>(Name(m_dataPrefix).appendSegment(m_currentSegmentNo));
@@ -195,7 +194,7 @@
m_isFinished = true;
}
- data->setContent(buffer, readSize);
+ data->setContent(ndn::make_span(buffer, readSize));
data->setFreshnessPeriod(freshnessPeriod);
signData(*data);
@@ -251,13 +250,12 @@
}
void
-NdnPutFile::onInsertCommandResponse(const ndn::Interest& interest, const ndn::Data& data)
+NdnPutFile::onInsertCommandResponse(const ndn::Interest&, const ndn::Data& data)
{
RepoCommandResponse response(data.getContent().blockFromValue());
auto statusCode = response.getCode();
if (statusCode >= 400) {
- BOOST_THROW_EXCEPTION(Error("insert command failed with code " +
- boost::lexical_cast<std::string>(statusCode)));
+ NDN_THROW(Error("insert command failed with code " + std::to_string(statusCode)));
}
m_processId = response.getProcessId();
@@ -265,9 +263,9 @@
}
void
-NdnPutFile::onInsertCommandTimeout(const ndn::Interest& interest)
+NdnPutFile::onInsertCommandTimeout(const ndn::Interest&)
{
- BOOST_THROW_EXCEPTION(Error("command response timeout"));
+ NDN_THROW(Error("command response timeout"));
}
void
@@ -296,7 +294,7 @@
prepareNextData(segmentNo);
- DataContainer::iterator item = m_data.find(segmentNo);
+ auto item = m_data.find(segmentNo);
if (item == m_data.end()) {
if (isVerbose) {
std::cerr << "Requested segment [" << segmentNo << "] does not exist" << std::endl;
@@ -328,15 +326,15 @@
boost::iostreams::read(*insertStream, reinterpret_cast<char*>(buffer), DEFAULT_BLOCK_SIZE);
if (readSize <= 0) {
- BOOST_THROW_EXCEPTION(Error("Error reading from the input stream"));
+ NDN_THROW(Error("Error reading from the input stream"));
}
if (insertStream->peek() != std::istream::traits_type::eof()) {
- BOOST_THROW_EXCEPTION(Error("Input data does not fit into one Data packet"));
+ NDN_THROW(Error("Input data does not fit into one Data packet"));
}
auto data = make_shared<ndn::Data>(m_dataPrefix);
- data->setContent(buffer, readSize);
+ data->setContent(ndn::make_span(buffer, readSize));
data->setFreshnessPeriod(freshnessPeriod);
signData(*data);
m_face.put(*data);
@@ -347,7 +345,7 @@
void
NdnPutFile::onRegisterFailed(const ndn::Name& prefix, const std::string& reason)
{
- BOOST_THROW_EXCEPTION(Error("onRegisterFailed: " + reason));
+ NDN_THROW(Error("onRegisterFailed: " + reason));
}
void
@@ -382,13 +380,12 @@
}
void
-NdnPutFile::onCheckCommandResponse(const ndn::Interest& interest, const ndn::Data& data)
+NdnPutFile::onCheckCommandResponse(const ndn::Interest&, const ndn::Data& data)
{
RepoCommandResponse response(data.getContent().blockFromValue());
auto statusCode = response.getCode();
if (statusCode >= 400) {
- BOOST_THROW_EXCEPTION(Error("Insert check command failed with code: " +
- boost::lexical_cast<std::string>(statusCode)));
+ NDN_THROW(Error("Insert check command failed with code " + std::to_string(statusCode)));
}
if (m_isFinished) {
@@ -413,9 +410,9 @@
}
void
-NdnPutFile::onCheckCommandTimeout(const ndn::Interest& interest)
+NdnPutFile::onCheckCommandTimeout(const ndn::Interest&)
{
- BOOST_THROW_EXCEPTION(Error("check response timeout"));
+ NDN_THROW(Error("check response timeout"));
}
ndn::Interest
@@ -423,13 +420,12 @@
const RepoCommandParameter& commandParameter)
{
Name cmd = commandPrefix;
- cmd
- .append(command)
- .append(commandParameter.wireEncode());
- ndn::Interest interest;
+ cmd.append(command).append(tlv::GenericNameComponent, commandParameter.wireEncode());
- if (identityForCommand.empty())
+ ndn::Interest interest;
+ if (identityForCommand.empty()) {
interest = m_cmdSigner.makeCommandInterest(cmd);
+ }
else {
interest = m_cmdSigner.makeCommandInterest(cmd, ndn::signingByIdentity(identityForCommand));
}
@@ -493,7 +489,7 @@
ndnPutFile.freshnessPeriod = milliseconds(boost::lexical_cast<uint64_t>(optarg));
}
catch (const boost::bad_lexical_cast&) {
- std::cerr << "-x option should be an integer" << std::endl;;
+ std::cerr << "-x option should be an integer" << std::endl;
return 2;
}
break;
@@ -502,7 +498,7 @@
ndnPutFile.interestLifetime = milliseconds(boost::lexical_cast<uint64_t>(optarg));
}
catch (const boost::bad_lexical_cast&) {
- std::cerr << "-l option should be an integer" << std::endl;;
+ std::cerr << "-l option should be an integer" << std::endl;
return 2;
}
break;
@@ -512,7 +508,7 @@
ndnPutFile.timeout = milliseconds(boost::lexical_cast<uint64_t>(optarg));
}
catch (const boost::bad_lexical_cast&) {
- std::cerr << "-w option should be an integer" << std::endl;;
+ std::cerr << "-w option should be an integer" << std::endl;
return 2;
}
break;
diff --git a/wscript b/wscript
index 6e6974f..8108387 100644
--- a/wscript
+++ b/wscript
@@ -28,12 +28,13 @@
conf.env.WITH_TESTS = conf.options.with_tests
conf.env.WITH_TOOLS = conf.options.with_tools
- 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)
conf.check_sqlite3()
- boost_libs = ['system', 'program_options', 'iostreams', 'filesystem', 'thread', 'log']
+ boost_libs = ['system', 'program_options', 'filesystem', 'iostreams']
if conf.env.WITH_TESTS:
boost_libs.append('unit_test_framework')
conf.check_boost(lib=boost_libs, mt=True)