Replace all uses of BOOST_THROW_EXCEPTION with NDN_THROW
Refs: #4834
Change-Id: I6c536cd321fba62d397bf8520f51d2dbba73d908
diff --git a/src/clients/iterative-query-controller.cpp b/src/clients/iterative-query-controller.cpp
index b40ba9b..ccb9451 100644
--- a/src/clients/iterative-query-controller.cpp
+++ b/src/clients/iterative-query-controller.cpp
@@ -19,7 +19,8 @@
#include "iterative-query-controller.hpp"
#include "logger.hpp"
-#include <iostream>
+
+#include <sstream>
namespace ndn {
namespace ndns {
@@ -113,7 +114,7 @@
oss << "In onDataValidated, absence of record can not be infered from DoE.";
oss << " Last query:" << m_lastLabelType << " ";
oss << *this;
- BOOST_THROW_EXCEPTION(std::runtime_error(oss.str()));
+ NDN_THROW(std::runtime_error(oss.str()));
}
}
else if (contentType == NDNS_LINK) {
@@ -255,8 +256,7 @@
std::ostringstream oss;
oss << *this;
NDNS_LOG_WARN("unexpected state: " << oss.str());
- BOOST_THROW_EXCEPTION(std::runtime_error("call makeLatestInterest() unexpected: "
- + oss.str()));
+ NDN_THROW(std::runtime_error("call makeLatestInterest() unexpected: " + oss.str()));
}
m_lastLabelType = Name(query.getRrLabel()).append(query.getRrType());
diff --git a/src/clients/iterative-query-controller.hpp b/src/clients/iterative-query-controller.hpp
index cee2976..48c0871 100644
--- a/src/clients/iterative-query-controller.hpp
+++ b/src/clients/iterative-query-controller.hpp
@@ -21,17 +21,12 @@
#define NDNS_CLIENTS_ITERATIVE_QUERY_CONTROLLER_HPP
#include "ndns-enum.hpp"
-#include "common.hpp"
-#include "query.hpp"
#include "query-controller.hpp"
#include "response.hpp"
#include "validator/validator.hpp"
-#include <ndn-cxx/data.hpp>
-#include <ndn-cxx/interest.hpp>
-#include <ndn-cxx/link.hpp>
-#include <ndn-cxx/name.hpp>
#include <ndn-cxx/ims/in-memory-storage.hpp>
+#include <ndn-cxx/link.hpp>
namespace ndn {
namespace ndns {
@@ -63,15 +58,15 @@
Face& face, security::Validator* validator = nullptr,
ndn::InMemoryStorage* cache = nullptr);
- virtual void
- start();
+ void
+ start() override;
/**
* @brief return false if the current status is not QUEYR_STEP_QUERY_NS
* or QUERY_STEP_QUERY_RR
*/
- virtual bool
- hasEnded();
+ bool
+ hasEnded() override;
NDNS_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
void
@@ -110,7 +105,7 @@
public:
void
- setStartComponentIndex(size_t finished)
+ setStartComponentIndex(size_t finished) override
{
m_nFinishedComps = finished;
}
diff --git a/src/clients/query-controller.cpp b/src/clients/query-controller.cpp
index 9cd3559..81914ba 100644
--- a/src/clients/query-controller.cpp
+++ b/src/clients/query-controller.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014, 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.
@@ -18,8 +18,6 @@
*/
#include "query-controller.hpp"
-#include "logger.hpp"
-#include <iostream>
namespace ndn {
namespace ndns {
@@ -46,5 +44,6 @@
return os;
}
+
} // namespace ndns
} // namespace ndn
diff --git a/src/clients/query-controller.hpp b/src/clients/query-controller.hpp
index 8a84645..a78b5df 100644
--- a/src/clients/query-controller.hpp
+++ b/src/clients/query-controller.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-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.
@@ -20,15 +20,14 @@
#ifndef NDNS_CLIENTS_QUERY_CONTROLLER_HPP
#define NDNS_CLIENTS_QUERY_CONTROLLER_HPP
+#include "common.hpp"
#include "query.hpp"
#include "response.hpp"
#include <ndn-cxx/data.hpp>
#include <ndn-cxx/interest.hpp>
-#include <ndn-cxx/name.hpp>
#include <ndn-cxx/face.hpp>
-
namespace ndn {
namespace ndns {
@@ -48,7 +47,7 @@
* @brief a Query Controller interface
*
*/
-class QueryController : noncopyable
+class QueryController : boost::noncopyable
{
public:
QueryController(const Name& dstLabel, const name::Component& rrType,
diff --git a/src/clients/query.hpp b/src/clients/query.hpp
index 6f8222b..bd7ff25 100644
--- a/src/clients/query.hpp
+++ b/src/clients/query.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, 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.
@@ -36,7 +36,7 @@
*
* <zone> [<NDNS>|<NDNS-R>] <rrLabel> <rrType>
*/
-class Query : noncopyable
+class Query : boost::noncopyable
{
public:
Query();
diff --git a/src/clients/response.cpp b/src/clients/response.cpp
index 3da172b..b183b1d 100644
--- a/src/clients/response.cpp
+++ b/src/clients/response.cpp
@@ -97,7 +97,7 @@
{
wire.parse();
if (wire.elements().size() != 2) {
- BOOST_THROW_EXCEPTION(Error("Unexpected number of components while decoding DOE record"));
+ NDN_THROW(Error("Unexpected number of elements while decoding DOE record"));
}
return std::make_pair(Name(wire.elements().front()), Name(wire.elements().back()));
}
diff --git a/src/common.hpp b/src/common.hpp
index 92f9dec..ef77270 100644
--- a/src/common.hpp
+++ b/src/common.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-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.
@@ -35,10 +35,8 @@
#endif
#include <ndn-cxx/name.hpp>
+#include <ndn-cxx/util/exception.hpp>
-#include <functional>
-#include <map>
#include <boost/noncopyable.hpp>
-#include <boost/property_tree/ptree.hpp>
#endif // NDNS_COMMON_HPP
diff --git a/src/daemon/config-file.cpp b/src/daemon/config-file.cpp
index a03937f..636a69e 100644
--- a/src/daemon/config-file.cpp
+++ b/src/daemon/config-file.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,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -43,8 +43,8 @@
const ConfigSection& section,
bool isDryRun)
{
- BOOST_THROW_EXCEPTION(Error("Error processing configuration file " + filename +
- ": no module subscribed for section \"" + sectionName + "\""));
+ NDN_THROW(Error("Error processing configuration file " + filename +
+ ": no module subscribed for section \"" + sectionName + "\""));
}
void
@@ -69,8 +69,8 @@
return false;
}
- BOOST_THROW_EXCEPTION(Error("Invalid value \"" + value + "\" for option \"" +
- key + "\" in \"" + sectionName + "\" section"));
+ NDN_THROW(Error("Invalid value \"" + value + "\" for option \"" +
+ key + "\" in \"" + sectionName + "\" section"));
}
void
@@ -85,7 +85,7 @@
{
std::ifstream inputFile(filename);
if (!inputFile.good() || !inputFile.is_open()) {
- BOOST_THROW_EXCEPTION(Error("Failed to read configuration file " + filename));
+ NDN_THROW(Error("Failed to read configuration file " + filename));
}
parse(inputFile, isDryRun, filename);
inputFile.close();
@@ -105,8 +105,8 @@
boost::property_tree::read_info(input, m_global);
}
catch (const boost::property_tree::info_parser_error& error) {
- BOOST_THROW_EXCEPTION(Error("Failed to parse configuration file " + filename +
- ": " + error.message() + " on line " + to_string(error.line())));
+ NDN_THROW_NESTED(Error("Failed to parse configuration file " + filename +
+ ": " + error.message() + " on line " + to_string(error.line())));
}
process(isDryRun, filename);
diff --git a/src/daemon/config-file.hpp b/src/daemon/config-file.hpp
index a177bfa..b17dfe6 100644
--- a/src/daemon/config-file.hpp
+++ b/src/daemon/config-file.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-2020, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,6 +28,8 @@
#include "common.hpp"
+#include <boost/property_tree/ptree.hpp>
+
namespace ndn {
namespace ndns {
@@ -54,17 +56,13 @@
/** \brief configuration file parsing utility
*/
-class ConfigFile : noncopyable
+class ConfigFile : boost::noncopyable
{
public:
class Error : public std::runtime_error
{
public:
- explicit
- Error(const std::string& what)
- : std::runtime_error(what)
- {
- }
+ using std::runtime_error::runtime_error;
};
explicit
@@ -115,8 +113,8 @@
if (value) {
return *value;
}
- BOOST_THROW_EXCEPTION(Error("Invalid value \"" + node.get_value<std::string>() +
- "\" for option \"" + key + "\" in \"" + sectionName + "\" section"));
+ NDN_THROW(Error("Invalid value \"" + node.get_value<std::string>() +
+ "\" for option \"" + key + "\" in \"" + sectionName + "\" section"));
}
template <typename T>
diff --git a/src/daemon/db-mgr.cpp b/src/daemon/db-mgr.cpp
index da40d58..49dcfa9 100644
--- a/src/daemon/db-mgr.cpp
+++ b/src/daemon/db-mgr.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.
@@ -85,7 +85,7 @@
if (res != SQLITE_OK) {
NDNS_LOG_FATAL("Cannot open the db file: " << m_dbFile);
- BOOST_THROW_EXCEPTION(ConnectError("Cannot open the db file: " + m_dbFile));
+ NDN_THROW(ConnectError("Cannot open the db file: " + m_dbFile));
}
// ignore any errors from DB creation (command will fail for the existing database, which is ok)
@@ -116,7 +116,7 @@
// sqlite3_step cannot execute multiple SQL statements
int rc = sqlite3_exec(m_conn, sql, nullptr, nullptr, nullptr);
if (rc != SQLITE_OK) {
- BOOST_THROW_EXCEPTION(ExecuteError(sql));
+ NDN_THROW(ExecuteError(sql));
}
NDNS_LOG_INFO("clear all the data in the database: " << m_dbFile);
@@ -142,7 +142,7 @@
name::Component component;
std::tie(hasDecodingSucceeded, component) = Block::fromBuffer(buffer, nBytesLeft);
if (!hasDecodingSucceeded) {
- BOOST_THROW_EXCEPTION(Error("Error while decoding name from the database"));
+ NDN_THROW(Error("Error while decoding name from the database"));
}
name.append(component);
buffer += component.size();
@@ -166,7 +166,7 @@
const char* sql = "INSERT INTO zones (name, ttl) VALUES (?, ?)";
int rc = sqlite3_prepare_v2(m_conn, sql, -1, &stmt, nullptr);
if (rc != SQLITE_OK) {
- BOOST_THROW_EXCEPTION(PrepareError(sql));
+ NDN_THROW(PrepareError(sql));
}
saveName(zone.getName(), stmt, 1);
@@ -175,7 +175,7 @@
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE) {
sqlite3_finalize(stmt);
- BOOST_THROW_EXCEPTION(ExecuteError(sql));
+ NDN_THROW(ExecuteError(sql));
}
zone.setId(sqlite3_last_insert_rowid(m_conn));
@@ -188,18 +188,18 @@
const Block& value)
{
if (zone.getId() == 0) {
- BOOST_THROW_EXCEPTION(Error("zone has not been initialized"));
+ NDN_THROW(Error("zone has not been initialized"));
}
if (key.length() > 10) {
- BOOST_THROW_EXCEPTION(Error("key length should not exceed 10"));
+ NDN_THROW(Error("key length should not exceed 10"));
}
sqlite3_stmt* stmt;
const char* sql = "INSERT OR REPLACE INTO zone_info (zone_id, key, value) VALUES (?, ?, ?)";
int rc = sqlite3_prepare_v2(m_conn, sql, -1, &stmt, nullptr);
if (rc != SQLITE_OK) {
- BOOST_THROW_EXCEPTION(PrepareError(sql));
+ NDN_THROW(PrepareError(sql));
}
sqlite3_bind_int(stmt, 1, zone.getId());
@@ -209,7 +209,7 @@
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE) {
sqlite3_finalize(stmt);
- BOOST_THROW_EXCEPTION(ExecuteError(sql));
+ NDN_THROW(ExecuteError(sql));
}
sqlite3_finalize(stmt);
@@ -226,14 +226,14 @@
}
if (zone.getId() == 0) {
- BOOST_THROW_EXCEPTION(Error("zone has not been initialized"));
+ NDN_THROW(Error("zone has not been initialized"));
}
sqlite3_stmt* stmt;
const char* sql = "SELECT key, value FROM zone_info WHERE zone_id=?";
int rc = sqlite3_prepare_v2(m_conn, sql, -1, &stmt, nullptr);
if (rc != SQLITE_OK) {
- BOOST_THROW_EXCEPTION(PrepareError(sql));
+ NDN_THROW(PrepareError(sql));
}
sqlite3_bind_int(stmt, 1, zone.getId());
@@ -255,7 +255,7 @@
const char* sql = "SELECT id, ttl FROM zones WHERE name=?";
int rc = sqlite3_prepare_v2(m_conn, sql, -1, &stmt, nullptr);
if (rc != SQLITE_OK) {
- BOOST_THROW_EXCEPTION(PrepareError(sql));
+ NDN_THROW(PrepareError(sql));
}
saveName(zone.getName(), stmt, 1);
@@ -280,7 +280,7 @@
const char* sql = "SELECT id, name, ttl FROM zones";
int rc = sqlite3_prepare_v2(m_conn, sql, -1, &stmt, nullptr);
if (rc != SQLITE_OK) {
- BOOST_THROW_EXCEPTION(PrepareError(sql));
+ NDN_THROW(PrepareError(sql));
}
std::vector<Zone> vec;
@@ -307,7 +307,7 @@
const char* sql = "DELETE FROM zones where id=?";
int rc = sqlite3_prepare_v2(m_conn, sql, -1, &stmt, nullptr);
if (rc != SQLITE_OK) {
- BOOST_THROW_EXCEPTION(PrepareError(sql));
+ NDN_THROW(PrepareError(sql));
}
sqlite3_bind_int64(stmt, 1, zone.getId());
@@ -315,7 +315,7 @@
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE) {
sqlite3_finalize(stmt);
- BOOST_THROW_EXCEPTION(ExecuteError(sql));
+ NDN_THROW(ExecuteError(sql));
}
sqlite3_finalize(stmt);
@@ -334,7 +334,7 @@
return;
if (rrset.getZone() == nullptr) {
- BOOST_THROW_EXCEPTION(RrsetError("Rrset has not been assigned to a zone"));
+ NDN_THROW(RrsetError("Rrset has not been assigned to a zone"));
}
if (rrset.getZone()->getId() == 0) {
@@ -348,7 +348,7 @@
sqlite3_stmt* stmt;
int rc = sqlite3_prepare_v2(m_conn, sql, -1, &stmt, nullptr);
if (rc != SQLITE_OK) {
- BOOST_THROW_EXCEPTION(PrepareError(sql));
+ NDN_THROW(PrepareError(sql));
}
sqlite3_bind_int64(stmt, 1, rrset.getZone()->getId());
@@ -362,7 +362,7 @@
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE) {
sqlite3_finalize(stmt);
- BOOST_THROW_EXCEPTION(ExecuteError(sql));
+ NDN_THROW(ExecuteError(sql));
}
rrset.setId(sqlite3_last_insert_rowid(m_conn));
@@ -373,7 +373,7 @@
DbMgr::find(Rrset& rrset)
{
if (rrset.getZone() == nullptr) {
- BOOST_THROW_EXCEPTION(RrsetError("Rrset has not been assigned to a zone"));
+ NDN_THROW(RrsetError("Rrset has not been assigned to a zone"));
}
if (rrset.getZone()->getId() == 0) {
@@ -389,7 +389,7 @@
" WHERE zone_id=? and label=? and type=?";
int rc = sqlite3_prepare_v2(m_conn, sql, -1, &stmt, nullptr);
if (rc != SQLITE_OK) {
- BOOST_THROW_EXCEPTION(PrepareError(sql));
+ NDN_THROW(PrepareError(sql));
}
sqlite3_bind_int64(stmt, 1, rrset.getZone()->getId());
@@ -417,7 +417,7 @@
DbMgr::findLowerBound(Rrset& rrset)
{
if (rrset.getZone() == nullptr) {
- BOOST_THROW_EXCEPTION(RrsetError("Rrset has not been assigned to a zone"));
+ NDN_THROW(RrsetError("Rrset has not been assigned to a zone"));
}
if (rrset.getZone()->getId() == 0) {
@@ -433,7 +433,7 @@
" WHERE zone_id=? and label<? and type=? ORDER BY label DESC";
int rc = sqlite3_prepare_v2(m_conn, sql, -1, &stmt, nullptr);
if (rc != SQLITE_OK) {
- BOOST_THROW_EXCEPTION(PrepareError(sql));
+ NDN_THROW(PrepareError(sql));
}
sqlite3_bind_int64(stmt, 1, rrset.getZone()->getId());
@@ -464,7 +464,7 @@
find(zone);
if (zone.getId() == 0)
- BOOST_THROW_EXCEPTION(RrsetError("Attempting to find all the rrsets with a zone does not in the database"));
+ NDN_THROW(RrsetError("Attempting to find all the rrsets with a zone does not in the database"));
std::vector<Rrset> vec;
sqlite3_stmt* stmt;
@@ -473,7 +473,7 @@
int rc = sqlite3_prepare_v2(m_conn, sql, -1, &stmt, nullptr);
if (rc != SQLITE_OK) {
- BOOST_THROW_EXCEPTION(PrepareError(sql));
+ NDN_THROW(PrepareError(sql));
}
sqlite3_bind_int64(stmt, 1, zone.getId());
@@ -503,13 +503,13 @@
find(zone);
if (zone.getId() == 0)
- BOOST_THROW_EXCEPTION(RrsetError("Attempting to find all the rrsets with a zone does not in the database"));
+ NDN_THROW(RrsetError("Attempting to find all the rrsets with a zone does not in the database"));
sqlite3_stmt* stmt;
const char* sql = "DELETE FROM rrsets WHERE zone_id = ? AND type = ?";
int rc = sqlite3_prepare_v2(m_conn, sql, -1, &stmt, nullptr);
if (rc != SQLITE_OK) {
- BOOST_THROW_EXCEPTION(PrepareError(sql));
+ NDN_THROW(PrepareError(sql));
}
sqlite3_bind_int64(stmt, 1, zone.getId());
@@ -518,7 +518,7 @@
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE) {
sqlite3_finalize(stmt);
- BOOST_THROW_EXCEPTION(ExecuteError(sql));
+ NDN_THROW(ExecuteError(sql));
}
sqlite3_finalize(stmt);
}
@@ -527,13 +527,13 @@
DbMgr::remove(Rrset& rrset)
{
if (rrset.getId() == 0)
- BOOST_THROW_EXCEPTION(RrsetError("Attempting to remove Rrset that has no assigned id"));
+ NDN_THROW(RrsetError("Attempting to remove Rrset that has no assigned id"));
sqlite3_stmt* stmt;
const char* sql = "DELETE FROM rrsets WHERE id=?";
int rc = sqlite3_prepare_v2(m_conn, sql, -1, &stmt, nullptr);
if (rc != SQLITE_OK) {
- BOOST_THROW_EXCEPTION(PrepareError(sql));
+ NDN_THROW(PrepareError(sql));
}
sqlite3_bind_int64(stmt, 1, rrset.getId());
@@ -541,7 +541,7 @@
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE) {
sqlite3_finalize(stmt);
- BOOST_THROW_EXCEPTION(ExecuteError(sql));
+ NDN_THROW(ExecuteError(sql));
}
sqlite3_finalize(stmt);
@@ -553,18 +553,18 @@
DbMgr::update(Rrset& rrset)
{
if (rrset.getId() == 0) {
- BOOST_THROW_EXCEPTION(RrsetError("Attempting to replace Rrset that has no assigned id"));
+ NDN_THROW(RrsetError("Attempting to replace Rrset that has no assigned id"));
}
if (rrset.getZone() == nullptr) {
- BOOST_THROW_EXCEPTION(RrsetError("Rrset has not been assigned to a zone"));
+ NDN_THROW(RrsetError("Rrset has not been assigned to a zone"));
}
sqlite3_stmt* stmt;
const char* sql = "UPDATE rrsets SET ttl=?, version=?, data=? WHERE id=?";
int rc = sqlite3_prepare_v2(m_conn, sql, -1, &stmt, nullptr);
if (rc != SQLITE_OK) {
- BOOST_THROW_EXCEPTION(PrepareError(sql));
+ NDN_THROW(PrepareError(sql));
}
sqlite3_bind_int64(stmt, 1, rrset.getTtl().count());
diff --git a/src/daemon/db-mgr.hpp b/src/daemon/db-mgr.hpp
index a41380a..81ae5ad 100644
--- a/src/daemon/db-mgr.hpp
+++ b/src/daemon/db-mgr.hpp
@@ -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.
@@ -20,7 +20,7 @@
#ifndef NDNS_DAEMON_DB_MGR_HPP
#define NDNS_DAEMON_DB_MGR_HPP
-#include "config.hpp"
+#include "common.hpp"
#include "rrset.hpp"
#include "zone.hpp"
@@ -46,7 +46,7 @@
*
* @note Method names follow MongoDB convention: insert/remove/find/update
*/
-class DbMgr : noncopyable
+class DbMgr : boost::noncopyable
{
public:
/**
diff --git a/src/daemon/name-server.cpp b/src/daemon/name-server.cpp
index c1d3bfa..4e40b17 100644
--- a/src/daemon/name-server.cpp
+++ b/src/daemon/name-server.cpp
@@ -44,7 +44,7 @@
if (m_zone.getId() == 0) {
NDNS_LOG_FATAL("m_zone does not exist: " << zoneName);
- BOOST_THROW_EXCEPTION(Error("Zone " + zoneName.toUri() + " does not exist in the database"));
+ NDN_THROW(Error("Zone " + zoneName.toUri() + " does not exist in the database"));
}
m_ndnsPrefix.append(ndns::label::NDNS_ITERATIVE_QUERY);
@@ -101,7 +101,7 @@
doe.setType(label::DOE_RR_TYPE);
if (!m_dbMgr.findLowerBound(doe)) {
NDNS_LOG_FATAL("fail to find DoE record of zone:" + m_zone.getName().toUri());
- BOOST_THROW_EXCEPTION(std::runtime_error("fail to find DoE record of zone:" + m_zone.getName().toUri()));
+ NDN_THROW(std::runtime_error("fail to find DoE record of zone:" + m_zone.getName().toUri()));
}
answer->setContent(doe.getData());
@@ -133,9 +133,9 @@
}
m_validator.validate(*data,
bind(&NameServer::doUpdate, this, interest.shared_from_this(), data),
- [] (const Data& data, const security::ValidationError& msg) {
+ [] (const Data&, const security::ValidationError&) {
NDNS_LOG_WARN("Ignoring update that did not pass the verification. "
- << "Check the root certificate");
+ "Check the root certificate");
});
}
}
@@ -144,8 +144,8 @@
NameServer::onRegisterFailed(const ndn::Name& prefix, const std::string& reason)
{
NDNS_LOG_FATAL("fail to register prefix=" << prefix << ". Due to: " << reason);
- BOOST_THROW_EXCEPTION(Error("zone " + m_zone.getName().toUri() + " register prefix: " +
- prefix.toUri() + " fails. due to: " + reason));
+ NDN_THROW(Error("zone " + m_zone.getName().toUri() + " register prefix: " +
+ prefix.toUri() + " fails. due to: " + reason));
}
void
diff --git a/src/daemon/name-server.hpp b/src/daemon/name-server.hpp
index fd820e5..8a84f42 100644
--- a/src/daemon/name-server.hpp
+++ b/src/daemon/name-server.hpp
@@ -26,14 +26,12 @@
#include "ndns-label.hpp"
#include "ndns-tlv.hpp"
#include "validator/validator.hpp"
-#include "common.hpp"
#include <ndn-cxx/security/key-chain.hpp>
#include <ndn-cxx/face.hpp>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
-#include <boost/noncopyable.hpp>
#include <sstream>
#include <stdexcept>
@@ -46,7 +44,7 @@
*
* The authoritative name server handles NDNS query and update.
*/
-class NameServer : noncopyable
+class NameServer : boost::noncopyable
{
DEFINE_ERROR(Error, std::runtime_error);
diff --git a/src/daemon/rrset-factory.cpp b/src/daemon/rrset-factory.cpp
index 029e3b0..d0938a1 100644
--- a/src/daemon/rrset-factory.cpp
+++ b/src/daemon/rrset-factory.cpp
@@ -52,7 +52,7 @@
Name zoneIdentityName = Name(m_zone.getName()).append(label::NDNS_ITERATIVE_QUERY);
if (m_dskCertName != DEFAULT_CERT &&
!matchCertificate(m_dskCertName, zoneIdentityName)) {
- BOOST_THROW_EXCEPTION(Error("Cannot verify certificate"));
+ NDN_THROW(Error("Cannot verify certificate"));
}
}
@@ -67,7 +67,7 @@
DbMgr dbMgr(m_dbFile);
const Name& zoneName = m_zone.getName();
if (!dbMgr.find(m_zone)) {
- BOOST_THROW_EXCEPTION(Error(zoneName.toUri() + " is not presented in the NDNS db"));
+ NDN_THROW(Error(zoneName.toUri() + " is not presented in the NDNS db"));
}
}
@@ -120,7 +120,7 @@
const ndn::DelegationList& delegations)
{
if (!m_checked) {
- BOOST_THROW_EXCEPTION(Error("You have to call checkZoneKey before call generate functions"));
+ NDN_THROW(Error("You have to call checkZoneKey before call generate functions"));
}
if (ttl == DEFAULT_RR_TTL)
@@ -147,7 +147,7 @@
const std::vector<std::string>& strings)
{
if (!m_checked) {
- BOOST_THROW_EXCEPTION(Error("You have to call checkZoneKey before call generate functions"));
+ NDN_THROW(Error("You have to call checkZoneKey before call generate functions"));
}
if (ttl == DEFAULT_RR_TTL)
@@ -181,7 +181,7 @@
const ndn::security::Certificate& cert)
{
if (!m_checked) {
- BOOST_THROW_EXCEPTION(Error("You have to call checkZoneKey before call generate functions"));
+ NDN_THROW(Error("You have to call checkZoneKey before call generate functions"));
}
if (ttl == DEFAULT_RR_TTL)
@@ -207,7 +207,7 @@
time::seconds ttl)
{
if (!m_checked) {
- BOOST_THROW_EXCEPTION(Error("You have to call checkZoneKey before call generate functions"));
+ NDN_THROW(Error("You have to call checkZoneKey before call generate functions"));
}
if (ttl == DEFAULT_RR_TTL)
@@ -234,7 +234,7 @@
const Name& upperLabel)
{
if (!m_checked) {
- BOOST_THROW_EXCEPTION(Error("You have to call checkZoneKey before call generate functions"));
+ NDN_THROW(Error("You have to call checkZoneKey before call generate functions"));
}
if (ttl == DEFAULT_RR_TTL)
diff --git a/src/daemon/rrset-factory.hpp b/src/daemon/rrset-factory.hpp
index 1773fe0..bab99ca 100644
--- a/src/daemon/rrset-factory.hpp
+++ b/src/daemon/rrset-factory.hpp
@@ -20,7 +20,6 @@
#ifndef NDNS_DAEMON_RRSET_FACTORY_HPP
#define NDNS_DAEMON_RRSET_FACTORY_HPP
-#include "common.hpp"
#include "rrset.hpp"
#include "logger.hpp"
#include "daemon/db-mgr.hpp"
@@ -29,9 +28,7 @@
#include <ndn-cxx/link.hpp>
#include <ndn-cxx/security/key-chain.hpp>
-#include <vector>
-#include <string>
-#include <boost/filesystem.hpp>
+#include <boost/filesystem/path.hpp>
namespace ndn {
namespace ndns {
@@ -44,10 +41,7 @@
class Error : public std::runtime_error
{
public:
- explicit
- Error(const std::string& what) : std::runtime_error(what)
- {
- }
+ using std::runtime_error::runtime_error;
};
public:
@@ -138,4 +132,3 @@
} // namespace ndn
#endif // NDNS_DAEMON_RRSET_FACTORY_HPP
-
diff --git a/src/daemon/rrset.cpp b/src/daemon/rrset.cpp
index 75c4d81..5c95a8f 100644
--- a/src/daemon/rrset.cpp
+++ b/src/daemon/rrset.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.
@@ -62,7 +62,7 @@
{
if (getZone() != other.getZone() ||
(getZone() != nullptr && *getZone() != *other.getZone())) {
- BOOST_THROW_EXCEPTION(std::runtime_error("Cannot compare Rrset that belong to different zones"));
+ NDN_THROW(std::runtime_error("Cannot compare Rrset that belong to different zones"));
}
bool isLess = getLabel() < other.getLabel();
diff --git a/src/daemon/zone.hpp b/src/daemon/zone.hpp
index e3a15d4..854523a 100644
--- a/src/daemon/zone.hpp
+++ b/src/daemon/zone.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014, 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.
@@ -20,9 +20,7 @@
#ifndef NDNS_DAEMON_ZONE_HPP
#define NDNS_DAEMON_ZONE_HPP
-#include <ndn-cxx/name.hpp>
-
-#include <iostream>
+#include "common.hpp"
namespace ndn {
namespace ndns {
@@ -32,8 +30,8 @@
* @see http://en.wikipedia.org/wiki/DNS_zone
* @see http://irl.cs.ucla.edu/data/files/theses/afanasyev-thesis.pdf
*
- * The class is copyable, since it may be assigned to another Zone instance
- * when resolving Response or Query from database
+ * This class is copyable, since it may be assigned to another Zone instance
+ * when resolving Response or Query from database
*/
class Zone
{
diff --git a/src/mgmt/management-tool.cpp b/src/mgmt/management-tool.cpp
index 9f363dc..6d34997 100644
--- a/src/mgmt/management-tool.cpp
+++ b/src/mgmt/management-tool.cpp
@@ -23,8 +23,8 @@
#include "ndns-tlv.hpp"
#include "util/cert-helper.hpp"
-#include <string>
#include <iomanip>
+#include <iostream>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
@@ -72,31 +72,31 @@
//check preconditions
Zone zone(zoneName, cacheTtl);
if (m_dbMgr.find(zone)) {
- BOOST_THROW_EXCEPTION(Error(zoneName.toUri() + " is already presented in the NDNS db"));
+ NDN_THROW(Error(zoneName.toUri() + " is already present in the NDNS db"));
}
if (!isRoot && parentZoneName.equals(zoneName)) {
- BOOST_THROW_EXCEPTION(Error("Parent zone name can not be the zone itself"));
+ NDN_THROW(Error("Parent zone name can not be the zone itself"));
}
if (!isRoot && !parentZoneName.isPrefixOf(zoneName)) {
- BOOST_THROW_EXCEPTION(Error(parentZoneName.toUri() + " is not a prefix of " + zoneName.toUri()));
+ NDN_THROW(Error(parentZoneName.toUri() + " is not a prefix of " + zoneName.toUri()));
}
// if dsk is provided, there is no need to check ksk
if (dskCertName != DEFAULT_CERT) {
if (!matchCertificate(dskCertName, zoneIdentityName)) {
- BOOST_THROW_EXCEPTION(Error("Cannot verify DSK certificate"));
+ NDN_THROW(Error("Cannot verify DSK certificate"));
}
}
else if (kskCertName != DEFAULT_CERT) {
if (!matchCertificate(kskCertName, zoneIdentityName)) {
- BOOST_THROW_EXCEPTION(Error("Cannot verify KSK certificate"));
+ NDN_THROW(Error("Cannot verify KSK certificate"));
}
}
if (dkeyCertName == DEFAULT_CERT && isRoot) {
- BOOST_THROW_EXCEPTION(Error("Cannot generate dkey for root zone"));
+ NDN_THROW(Error("Cannot generate dkey for root zone"));
}
// Generate a parentZone's identity to generate a D-Key.
@@ -196,7 +196,7 @@
//check pre-conditions
Zone zone(zoneName);
if (!m_dbMgr.find(zone)) {
- BOOST_THROW_EXCEPTION(Error(zoneName.toUri() + " is not presented in the NDNS db"));
+ NDN_THROW(Error(zoneName.toUri() + " is not present in the NDNS db"));
}
//first remove all rrsets of this zone from local ndns database
@@ -216,7 +216,7 @@
security::Certificate cert;
shared_ptr<Regex> regex = make_shared<Regex>("(<>*)<NDNS>(<>+)<CERT><>");
if (!regex->match(certName)) {
- BOOST_THROW_EXCEPTION(Error("Certificate name is illegal"));
+ NDN_THROW(Error("Certificate name is illegal"));
return;
}
@@ -232,7 +232,7 @@
cert = security::Certificate(rrset.getData());
}
else {
- BOOST_THROW_EXCEPTION(Error("Cannot find the cert: " + certName.toUri()));
+ NDN_THROW(Error("Cannot find the cert: " + certName.toUri()));
}
if (outFile == DEFAULT_IO) {
@@ -260,7 +260,7 @@
if (m_dbMgr.find(prefixNsRr)) {
Data data(prefixNsRr.getData());
if (data.getContentType() == NDNS_LINK) {
- BOOST_THROW_EXCEPTION(Error("Cannot override " + boost::lexical_cast<std::string>(prefixNsRr) + " (NDNS_LINK)"));
+ NDN_THROW(Error("Cannot override " + boost::lexical_cast<std::string>(prefixNsRr) + " (NDNS_LINK)"));
}
}
}
@@ -270,7 +270,7 @@
Rrset rrsetCopy = rrset;
if (m_dbMgr.find(rrsetCopy)) {
if (Data(rrsetCopy.getData()).getContentType() == NDNS_AUTH) {
- BOOST_THROW_EXCEPTION(Error("Cannot override " + boost::lexical_cast<std::string>(rrsetCopy) + " (NDNS_AUTH)"));
+ NDN_THROW(Error("Cannot override " + boost::lexical_cast<std::string>(rrsetCopy) + " (NDNS_AUTH)"));
}
}
}
@@ -305,7 +305,7 @@
rrsetCopy.setType(label::NS_RR_TYPE);
if (m_dbMgr.find(rrsetCopy)) {
if (Data(rrsetCopy.getData()).getContentType() == NDNS_AUTH) {
- BOOST_THROW_EXCEPTION(Error("Can not add this Rrset: it overrides a NDNS_AUTH record"));
+ NDN_THROW(Error("Can not add this Rrset: it overrides a NDNS_AUTH record"));
}
}
@@ -327,7 +327,7 @@
Zone zone(zoneName);
Name zoneIdentityName = Name(zoneName).append(label::NDNS_ITERATIVE_QUERY);
if (!m_dbMgr.find(zone)) {
- BOOST_THROW_EXCEPTION(Error(zoneName.toUri() + " is not presented in the NDNS db"));
+ NDN_THROW(Error(zoneName.toUri() + " is not present in the NDNS db"));
}
Name dskName;
@@ -338,14 +338,14 @@
}
else {
if (!matchCertificate(dskCertName, zoneIdentityName)) {
- BOOST_THROW_EXCEPTION(Error("Cannot verify certificate"));
+ NDN_THROW(Error("Cannot verify certificate"));
}
}
if (inFile != DEFAULT_IO) {
boost::filesystem::path dir = boost::filesystem::path(inFile);
if (!boost::filesystem::exists(dir) || boost::filesystem::is_directory(dir)) {
- BOOST_THROW_EXCEPTION(Error("Data: " + inFile + " does not exist"));
+ NDN_THROW(Error("Data: " + inFile + " does not exist"));
}
}
@@ -357,7 +357,7 @@
data = ndn::io::load<ndn::Data>(inFile, encoding);
if (data == nullptr) {
- BOOST_THROW_EXCEPTION(Error("input does not contain a valid Data packet"));
+ NDN_THROW(Error("input does not contain a valid Data packet"));
}
if (needResign) {
@@ -402,7 +402,7 @@
{
Zone zone(zoneName);
if (!m_dbMgr.find(zone)) {
- BOOST_THROW_EXCEPTION(Error("Zone " + zoneName.toUri() + " is not found in the database"));
+ NDN_THROW(Error("Zone " + zoneName.toUri() + " is not found in the database"));
}
//first output the zone name
@@ -593,8 +593,8 @@
rrsetKey.setData(cert.wireEncode());
if (m_dbMgr.find(rrsetKey)) {
- BOOST_THROW_EXCEPTION(Error("CERT with label=" + label.toUri() +
- " is already presented in local NDNS databse"));
+ NDN_THROW(Error("CERT with label=" + label.toUri() +
+ " is already present in local NDNS database"));
}
m_dbMgr.insert(rrsetKey);
@@ -606,8 +606,8 @@
ManagementTool::addZone(Zone& zone)
{
if (m_dbMgr.find(zone)) {
- BOOST_THROW_EXCEPTION(Error("Zone with Name=" + zone.getName().toUri() +
- " is already presented in local NDNS databse"));
+ NDN_THROW(Error("Zone with Name=" + zone.getName().toUri() +
+ " is already present in local NDNS database"));
}
NDNS_LOG_INFO("Add zone with Name: " << zone.getName().toUri());
m_dbMgr.insert(zone);
@@ -644,12 +644,10 @@
if (m_dbMgr.find(originalRrset)) {
// update only if rrset has a newer version
if (originalRrset.getVersion() == rrset.getVersion()) {
- BOOST_THROW_EXCEPTION(Error("Duplicate: "
- + boost::lexical_cast<std::string>(originalRrset)));
+ NDN_THROW(Error("Duplicate: " + boost::lexical_cast<std::string>(originalRrset)));
}
else if (originalRrset.getVersion() > rrset.getVersion()) {
- BOOST_THROW_EXCEPTION(Error("Newer version exists: "
- + boost::lexical_cast<std::string>(originalRrset)));
+ NDN_THROW(Error("Newer version exists: " + boost::lexical_cast<std::string>(originalRrset)));
}
m_dbMgr.remove(originalRrset);
@@ -661,7 +659,7 @@
{
// check zone existence
if (!m_dbMgr.find(zone)) {
- BOOST_THROW_EXCEPTION(Error(zone.getName().toUri() + " is not presented in the NDNS db"));
+ NDN_THROW(Error(zone.getName().toUri() + " is not present in the NDNS db"));
}
// remove all the Doe records
diff --git a/src/mgmt/management-tool.hpp b/src/mgmt/management-tool.hpp
index 5b9b51e..ba00458 100644
--- a/src/mgmt/management-tool.hpp
+++ b/src/mgmt/management-tool.hpp
@@ -20,7 +20,6 @@
#ifndef NDNS_MGMT_MANAGEMENT_TOOL_HPP
#define NDNS_MGMT_MANAGEMENT_TOOL_HPP
-#include "config.hpp"
#include "ndns-enum.hpp"
#include "clients/response.hpp"
#include "daemon/db-mgr.hpp"
@@ -49,7 +48,7 @@
* @brief provides management tools to the NDNS system, such as zone creation, zone delegation, DSK
* generation and root zone creation.
*/
-class ManagementTool : noncopyable
+class ManagementTool : boost::noncopyable
{
public:
/** @brief Represents an error might be thrown during runtime
@@ -57,10 +56,7 @@
class Error : public std::runtime_error
{
public:
- explicit
- Error(const std::string& what) : std::runtime_error(what)
- {
- }
+ using std::runtime_error::runtime_error;
};
/**
diff --git a/src/util/cert-helper.cpp b/src/util/cert-helper.cpp
index 164a34f..ae33e00 100644
--- a/src/util/cert-helper.cpp
+++ b/src/util/cert-helper.cpp
@@ -52,7 +52,7 @@
}
}
}
- BOOST_THROW_EXCEPTION(std::runtime_error(certName.toUri() + " does not exist"));
+ NDN_THROW(std::runtime_error(certName.toUri() + " does not exist"));
}
Name
@@ -64,7 +64,7 @@
return certName.getPrefix(i);
}
}
- BOOST_THROW_EXCEPTION(std::runtime_error(certName.toUri() + " is not a legal cert name"));
+ NDN_THROW(std::runtime_error(certName.toUri() + " is not a legal cert name"));
}
security::Certificate
diff --git a/src/validator/certificate-fetcher-ndns-appcert.cpp b/src/validator/certificate-fetcher-ndns-appcert.cpp
index 81f31c6..966f7de 100644
--- a/src/validator/certificate-fetcher-ndns-appcert.cpp
+++ b/src/validator/certificate-fetcher-ndns-appcert.cpp
@@ -45,21 +45,19 @@
const ValidationContinuation& continueValidation)
{
const Name& key = certRequest->interest.getName();
- auto query = make_shared<IterativeQueryController>(key,
- label::APPCERT_RR_TYPE,
- certRequest->interest.getInterestLifetime(),
- [=] (const Data& data, const Response& response) {
- onQuerySuccessCallback(data, certRequest, state, continueValidation);
- },
- [=] (uint32_t errCode, const std::string& errMsg) {
- onQueryFailCallback(errMsg, certRequest, state, continueValidation);
- },
- m_face,
- nullptr,
- m_nsCache);
+ auto query = std::make_shared<IterativeQueryController>(key, label::APPCERT_RR_TYPE,
+ certRequest->interest.getInterestLifetime(),
+ [=] (const Data& data, const Response&) {
+ onQuerySuccessCallback(data, certRequest, state, continueValidation);
+ },
+ [=] (uint32_t errCode, const std::string& errMsg) {
+ onQueryFailCallback(errMsg, certRequest, state, continueValidation);
+ },
+ m_face, nullptr, m_nsCache);
query->setStartComponentIndex(m_startComponentIndex);
query->start();
- state->setTag(make_shared<IterativeQueryTag>(query));
+
+ state->setTag(std::make_shared<IterativeQueryTag>(query));
}
void
diff --git a/src/validator/certificate-fetcher-ndns-cert.cpp b/src/validator/certificate-fetcher-ndns-cert.cpp
index b1979b5..34c0774 100644
--- a/src/validator/certificate-fetcher-ndns-cert.cpp
+++ b/src/validator/certificate-fetcher-ndns-cert.cpp
@@ -57,22 +57,19 @@
return;
}
- auto query = std::make_shared<IterativeQueryController>(domain,
- label::NS_RR_TYPE,
- certRequest->interest.getInterestLifetime(),
- [=] (const Data& data, const Response& response) {
- nsSuccessCallback(data, certRequest, state, continueValidation);
- },
- [=] (uint32_t errCode, const std::string& errMsg) {
- nsFailCallback(errMsg, certRequest, state, continueValidation);
- },
- m_face,
- nullptr,
- m_nsCache.get());
+ auto query = std::make_shared<IterativeQueryController>(domain, label::NS_RR_TYPE,
+ certRequest->interest.getInterestLifetime(),
+ [=] (const Data& data, const Response&) {
+ nsSuccessCallback(data, certRequest, state, continueValidation);
+ },
+ [=] (uint32_t errCode, const std::string& errMsg) {
+ nsFailCallback(errMsg, certRequest, state, continueValidation);
+ },
+ m_face, nullptr, m_nsCache.get());
query->setStartComponentIndex(m_startComponentIndex);
query->start();
- auto queryTag = make_shared<IterativeQueryTag>(query);
- state->setTag(queryTag);
+
+ state->setTag(std::make_shared<IterativeQueryTag>(query));
}
void
@@ -100,13 +97,13 @@
}
m_face.expressInterest(interest,
- [=] (const Interest& interest, const Data& data) {
+ [=] (const Interest&, const Data& data) {
dataCallback(data, certRequest, state, continueValidation);
},
- [=] (const Interest& interest, const lp::Nack& nack) {
+ [=] (const Interest&, const lp::Nack& nack) {
nackCallback(nack, certRequest, state, continueValidation);
},
- [=] (const Interest& interest) {
+ [=] (const Interest&) {
timeoutCallback(certRequest, state, continueValidation);
});
}
@@ -143,7 +140,7 @@
return key.getPrefix(i);
}
}
- BOOST_THROW_EXCEPTION(std::runtime_error(key.toUri() + " is not a legal NDNS certificate name"));
+ NDN_THROW(std::runtime_error(key.toUri() + " is not a legal NDNS certificate name"));
}
void
diff --git a/tests/unit/mgmt/management-tool.t.cpp b/tests/unit/mgmt/management-tool.t.cpp
index 2ac878a..054a8cf 100644
--- a/tests/unit/mgmt/management-tool.t.cpp
+++ b/tests/unit/mgmt/management-tool.t.cpp
@@ -18,6 +18,7 @@
*/
#include "mgmt/management-tool.hpp"
+
#include "daemon/rrset-factory.hpp"
#include "util/cert-helper.hpp"
#include "ndns-enum.hpp"
@@ -27,8 +28,6 @@
#include "boost-test.hpp"
#include "key-chain-fixture.hpp"
-#include <random>
-
#include <boost/algorithm/string/replace.hpp>
#include <boost/range/adaptors.hpp>
#if BOOST_VERSION >= 105900
@@ -39,8 +38,11 @@
#include <ndn-cxx/security/transform.hpp>
#include <ndn-cxx/util/io.hpp>
+#include <ndn-cxx/util/random.hpp>
#include <ndn-cxx/util/regex.hpp>
+#include <iostream>
+
namespace ndn {
namespace ndns {
namespace tests {
@@ -157,10 +159,6 @@
rootDkey = rootDkeyCert.getName();
}
- ~ManagementToolFixture()
- {
- }
-
std::vector<Certificate>
getCerts(const Name& zoneName)
{
@@ -181,7 +179,7 @@
rrset.setType(type);
if (!m_dbMgr.find(rrset))
- BOOST_THROW_EXCEPTION(Error("Record not found"));
+ NDN_THROW(Error("Record not found"));
else
return rrset;
}
@@ -206,7 +204,7 @@
}
}
}
- BOOST_THROW_EXCEPTION(Error("Certificate not found in keyChain"));
+ NDN_THROW(Error("Certificate not found in keyChain"));
return rtn;
}
@@ -295,28 +293,26 @@
// this unit test make sure that our label::isSmallerInLabelOrder
// is the same as the ordering of BLOB in SQLite
- std::random_device seed;
- std::mt19937 gen(seed());
-
- auto genRandomString = [&] (int length) -> std::string {
- std::string charset =
- "0123456789"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz";
+ auto genRandomString = [] (size_t length) {
+ static const std::string charset = "0123456789"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz";
std::uniform_int_distribution<size_t> dist(0, charset.size() - 1);
std::string str(length, 0);
- std::generate_n(str.begin(), length, [&] { return charset[dist(gen)];} );
+ std::generate_n(str.begin(), length,
+ [&] { return charset[dist(random::getRandomNumberEngine())]; });
return str;
};
- auto genRandomLabel = [&]() -> Name {
+ auto genRandomLabel = [&] {
std::uniform_int_distribution<size_t> numberOfLabelsDist(1, 5);
std::uniform_int_distribution<size_t> labelSizeDist(1, 10);
+
Name nm;
- size_t length = numberOfLabelsDist(gen);
+ size_t length = numberOfLabelsDist(random::getRandomNumberEngine());
for (size_t i = 0; i < length; i++) {
- nm.append(genRandomString(labelSizeDist(gen)));
+ nm.append(genRandomString(labelSizeDist(random::getRandomNumberEngine())));
}
return nm;
};
diff --git a/tools/ndns-add-rr.cpp b/tools/ndns-add-rr.cpp
index 605a355..40ccdb2 100644
--- a/tools/ndns-add-rr.cpp
+++ b/tools/ndns-add-rr.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.
@@ -23,12 +23,12 @@
#include "mgmt/management-tool.hpp"
#include "util/util.hpp"
-#include <boost/program_options.hpp>
-#include <boost/filesystem.hpp>
-#include <boost/algorithm/string.hpp>
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/split.hpp>
#include <boost/lexical_cast.hpp>
+#include <boost/program_options.hpp>
-#include <string>
+#include <iostream>
NDNS_LOG_INIT(AddRrTool);
diff --git a/tools/ndns-create-zone.cpp b/tools/ndns-create-zone.cpp
index e20b200..1238d4e 100644
--- a/tools/ndns-create-zone.cpp
+++ b/tools/ndns-create-zone.cpp
@@ -23,8 +23,8 @@
#include "util/util.hpp"
#include <boost/program_options.hpp>
-#include <boost/filesystem.hpp>
-#include <string>
+
+#include <iostream>
NDNS_LOG_INIT(NdnsCreateZone);
diff --git a/tools/ndns-daemon.cpp b/tools/ndns-daemon.cpp
index 2f71a45..d199e29 100644
--- a/tools/ndns-daemon.cpp
+++ b/tools/ndns-daemon.cpp
@@ -27,9 +27,10 @@
#include <ndn-cxx/security/key-chain.hpp>
#include <boost/asio/io_service.hpp>
-#include <boost/filesystem.hpp>
#include <boost/program_options.hpp>
+#include <iostream>
+
NDNS_LOG_INIT(NdnsDaemon);
namespace ndn {
@@ -40,7 +41,7 @@
* @note NdnsDaemon allows multiple name servers hosted by the same daemon, and they
* share same KeyChain, DbMgr, Validator and Face
*/
-class NdnsDaemon : noncopyable
+class NdnsDaemon : boost::noncopyable
{
public:
DEFINE_ERROR(Error, std::runtime_error);
@@ -59,7 +60,7 @@
processZonesSection(const ndn::ndns::ConfigSection& section)
{
if (section.begin() == section.end()) {
- BOOST_THROW_EXCEPTION(Error("zones section is empty"));
+ NDN_THROW(Error("zones section is empty"));
}
std::string dbFile = getDefaultDatabaseFile();
@@ -87,7 +88,7 @@
}
catch (const std::exception&) {
NDNS_LOG_ERROR("Required `name' attribute missing in `zone' section");
- BOOST_THROW_EXCEPTION(Error("Required `name' attribute missing in `zone' section"));
+ NDN_THROW(Error("Required `name' attribute missing in `zone' section"));
}
try {
cert = option.second.get<Name>("cert");
@@ -104,14 +105,14 @@
}
catch (const std::exception& e) {
NDNS_LOG_ERROR("Identity " << name << " does not have a default certificate: " << e.what());
- BOOST_THROW_EXCEPTION(Error("identity does not have default certificate"));
+ NDN_THROW(Error("identity does not have default certificate"));
}
}
else {
try {
CertHelper::getCertificate(m_keyChain, name, cert);
} catch (const std::exception&) {
- BOOST_THROW_EXCEPTION(Error("Certificate `" + cert.toUri() + "` does not exist in the KeyChain"));
+ NDN_THROW(Error("Certificate `" + cert.toUri() + "` does not exist in the KeyChain"));
}
}
NDNS_LOG_TRACE("name = " << name << " cert = " << cert);
diff --git a/tools/ndns-delete-zone.cpp b/tools/ndns-delete-zone.cpp
index 2cefccc..3e28840 100644
--- a/tools/ndns-delete-zone.cpp
+++ b/tools/ndns-delete-zone.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.
@@ -23,8 +23,8 @@
#include "util/util.hpp"
#include <boost/program_options.hpp>
-#include <boost/filesystem.hpp>
-#include <string>
+
+#include <iostream>
int
main(int argc, char* argv[])
diff --git a/tools/ndns-dig.cpp b/tools/ndns-dig.cpp
index 5cb6a40..88340d9 100644
--- a/tools/ndns-dig.cpp
+++ b/tools/ndns-dig.cpp
@@ -25,17 +25,14 @@
#include "validator/validator.hpp"
#include "util/util.hpp"
-#include <ndn-cxx/security/key-chain.hpp>
#include <ndn-cxx/face.hpp>
-#include <boost/program_options.hpp>
-#include <boost/asio.hpp>
-#include <boost/filesystem.hpp>
-#include <boost/noncopyable.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
-#include <iostream>
-#include <memory>
-#include <string>
+#include <boost/asio/io_service.hpp>
+#include <boost/program_options.hpp>
+
#include <fstream>
+#include <iostream>
NDNS_LOG_INIT(Dig);
diff --git a/tools/ndns-export-certificate.cpp b/tools/ndns-export-certificate.cpp
index f3d7b8e..d0cb958 100644
--- a/tools/ndns-export-certificate.cpp
+++ b/tools/ndns-export-certificate.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.
@@ -23,8 +23,8 @@
#include "util/util.hpp"
#include <boost/program_options.hpp>
-#include <boost/filesystem.hpp>
-#include <string>
+
+#include <iostream>
int
main(int argc, char* argv[])
diff --git a/tools/ndns-get-rr.cpp b/tools/ndns-get-rr.cpp
index dc40c37..8b8377b 100644
--- a/tools/ndns-get-rr.cpp
+++ b/tools/ndns-get-rr.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.
@@ -23,8 +23,8 @@
#include "util/util.hpp"
#include <boost/program_options.hpp>
-#include <boost/filesystem.hpp>
-#include <string>
+
+#include <iostream>
int
main(int argc, char* argv[])
diff --git a/tools/ndns-list-all-zones.cpp b/tools/ndns-list-all-zones.cpp
index 676815d..3801f35 100644
--- a/tools/ndns-list-all-zones.cpp
+++ b/tools/ndns-list-all-zones.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.
@@ -23,8 +23,7 @@
#include "util/util.hpp"
#include <boost/program_options.hpp>
-#include <boost/filesystem.hpp>
-#include <string>
+
#include <iostream>
int
diff --git a/tools/ndns-list-zone.cpp b/tools/ndns-list-zone.cpp
index 840997e..7e5ec89 100644
--- a/tools/ndns-list-zone.cpp
+++ b/tools/ndns-list-zone.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.
@@ -23,8 +23,7 @@
#include "util/util.hpp"
#include <boost/program_options.hpp>
-#include <boost/filesystem.hpp>
-#include <string>
+
#include <iostream>
int
diff --git a/tools/ndns-remove-rr.cpp b/tools/ndns-remove-rr.cpp
index dfb072c..8a7f05c 100644
--- a/tools/ndns-remove-rr.cpp
+++ b/tools/ndns-remove-rr.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.
@@ -23,8 +23,8 @@
#include "util/util.hpp"
#include <boost/program_options.hpp>
-#include <boost/filesystem.hpp>
-#include <string>
+
+#include <iostream>
int
main(int argc, char* argv[])
diff --git a/tools/ndns-update.cpp b/tools/ndns-update.cpp
index b810109..9c23a5b 100644
--- a/tools/ndns-update.cpp
+++ b/tools/ndns-update.cpp
@@ -35,12 +35,11 @@
#include <ndn-cxx/util/regex.hpp>
#include <ndn-cxx/encoding/block.hpp>
#include <ndn-cxx/encoding/block-helpers.hpp>
-#include <boost/noncopyable.hpp>
-#include <boost/program_options.hpp>
-#include <boost/asio.hpp>
-#include <boost/filesystem.hpp>
-#include <string>
+#include <boost/asio/io_service.hpp>
+#include <boost/program_options.hpp>
+
+#include <iostream>
#include <tuple>
namespace ndn {
@@ -48,7 +47,7 @@
NDNS_LOG_INIT(NdnsUpdate);
-class NdnsUpdate : noncopyable
+class NdnsUpdate : boost::noncopyable
{
public:
NdnsUpdate(const Name& zone, const shared_ptr<Data>& update, Face& face)