Replace remaining uses of BOOST_THROW_EXCEPTION with NDN_THROW
Change-Id: I0c149acbe5607d928cdf9e8d73813d5e74ca45d0
diff --git a/src/route/name-prefix-table.cpp b/src/route/name-prefix-table.cpp
index 55f0c54..91e6210 100644
--- a/src/route/name-prefix-table.cpp
+++ b/src/route/name-prefix-table.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, The University of Memphis,
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -94,11 +94,12 @@
// Either we have to make a new NPT entry or there already was one.
if (nameItr == m_table.end()) {
NLSR_LOG_DEBUG("Adding origin: " << rtpePtr->getDestination()
- << " to a new name prefix: " << name);
- npte = make_shared<NamePrefixTableEntry>(name);
+ << " to a new name prefix: " << name);
+ npte = std::make_shared<NamePrefixTableEntry>(name);
npte->addRoutingTableEntry(rtpePtr);
npte->generateNhlfromRteList();
m_table.push_back(npte);
+
// If this entry has next hops, we need to inform the FIB
if (npte->getNexthopList().size() > 0) {
NLSR_LOG_TRACE("Updating FIB with next hops for " << npte->getNamePrefix());
@@ -131,6 +132,7 @@
m_fib.remove(name);
}
}
+
// Add the reference to this NPT to the RTPE.
rtpePtr->namePrefixTableEntries.emplace(
std::make_pair(npte->getNamePrefix(), std::weak_ptr<NamePrefixTableEntry>(npte)));
diff --git a/src/route/nexthop.cpp b/src/route/nexthop.cpp
index 11399aa..bdb0bde 100644
--- a/src/route/nexthop.cpp
+++ b/src/route/nexthop.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, The University of Memphis,
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -69,25 +69,28 @@
m_wire = wire;
if (m_wire.type() != ndn::tlv::nlsr::NextHop) {
- std::stringstream error;
- error << "Expected NextHop Block, but Block is of a different type: #"
- << m_wire.type();
- BOOST_THROW_EXCEPTION(Error(error.str()));
+ NDN_THROW(Error("NextHop", m_wire.type()));
}
m_wire.parse();
- ndn::Block::element_const_iterator val = m_wire.elements_begin();
+ auto val = m_wire.elements_begin();
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::Uri) {
- m_connectingFaceUri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
+ m_connectingFaceUri = ndn::encoding::readString(*val);
++val;
}
else {
- BOOST_THROW_EXCEPTION(Error("Missing required Uri field"));
+ NDN_THROW(Error("Missing required Uri field"));
}
- m_routeCost = ndn::encoding::readDouble(*val);
+ if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::CostDouble) {
+ m_routeCost = ndn::encoding::readDouble(*val);
+ ++val;
+ }
+ else {
+ NDN_THROW(Error("Missing required CostDouble field"));
+ }
}
bool
diff --git a/src/route/nexthop.hpp b/src/route/nexthop.hpp
index 7f91cfe..4443a9e 100644
--- a/src/route/nexthop.hpp
+++ b/src/route/nexthop.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, The University of Memphis,
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -27,9 +27,8 @@
#include <ndn-cxx/encoding/encoding-buffer.hpp>
#include <ndn-cxx/encoding/tlv.hpp>
-#include <iostream>
#include <cmath>
-#include <boost/cstdint.hpp>
+#include <ostream>
namespace nlsr {
diff --git a/src/route/routing-table-calculator.hpp b/src/route/routing-table-calculator.hpp
index 9c0c6b5..b497c06 100644
--- a/src/route/routing-table-calculator.hpp
+++ b/src/route/routing-table-calculator.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, The University of Memphis,
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -28,9 +28,6 @@
#include "conf-parameter.hpp"
#include <list>
-#include <boost/cstdint.hpp>
-
-#include <ndn-cxx/name.hpp>
namespace nlsr {
diff --git a/src/route/routing-table-entry.cpp b/src/route/routing-table-entry.cpp
index 7320d91..950240e 100644
--- a/src/route/routing-table-entry.cpp
+++ b/src/route/routing-table-entry.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, The University of Memphis,
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -70,14 +70,10 @@
m_wire = wire;
if (m_wire.type() != ndn::tlv::nlsr::RoutingTableEntry) {
- std::stringstream error;
- error << "Expected RoutingTable Block, but Block is of a different type: #"
- << m_wire.type();
- BOOST_THROW_EXCEPTION(Error(error.str()));
+ NDN_THROW(Error("RoutingTableEntry", m_wire.type()));
}
m_wire.parse();
-
auto val = m_wire.elements_begin();
if (val != m_wire.elements_end() && val->type() == ndn::tlv::Name) {
@@ -85,7 +81,7 @@
++val;
}
else {
- BOOST_THROW_EXCEPTION(Error("Missing required destination field"));
+ NDN_THROW(Error("Missing required Name field"));
}
for (; val != m_wire.elements_end(); ++val) {
@@ -93,10 +89,7 @@
m_nexthopList.addNextHop(NextHop(*val));
}
else {
- std::stringstream error;
- error << "Expected NextHop Block, but Block is of a different type: #"
- << m_wire.type();
- BOOST_THROW_EXCEPTION(Error(error.str()));
+ NDN_THROW(Error("NextHop", val->type()));
}
}
}
@@ -104,10 +97,8 @@
std::ostream&
operator<<(std::ostream& os, const RoutingTableEntry& rte)
{
- os << " Destination: " << rte.getDestination() << "\n"
- << rte.getNexthopList() << "\n";
-
- return os;
+ return os << " Destination: " << rte.getDestination() << "\n"
+ << rte.getNexthopList() << "\n";
}
} // namespace nlsr
diff --git a/src/route/routing-table.cpp b/src/route/routing-table.cpp
index 74d3c11..b600882 100644
--- a/src/route/routing-table.cpp
+++ b/src/route/routing-table.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, The University of Memphis,
+ * Copyright (c) 2014-2021, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -273,14 +273,10 @@
m_wire = wire;
if (m_wire.type() != ndn::tlv::nlsr::RoutingTable) {
- std::stringstream error;
- error << "Expected RoutingTableStatus Block, but Block is of a different type: #"
- << m_wire.type();
- BOOST_THROW_EXCEPTION(Error(error.str()));
+ NDN_THROW(Error("RoutingTable", m_wire.type()));
}
m_wire.parse();
-
auto val = m_wire.elements_begin();
std::set<ndn::Name> destinations;
@@ -297,10 +293,7 @@
}
if (val != m_wire.elements_end()) {
- std::stringstream error;
- error << "Expected the end of elements, but Block is of a different type: #"
- << val->type();
- BOOST_THROW_EXCEPTION(Error(error.str()));
+ NDN_THROW(Error("Unrecognized TLV of type " + ndn::to_string(val->type()) + " in RoutingTable"));
}
}