Refactor and modernize namespace declarations
Move all unit tests to namespace nfd::tests
Delete unused header core/algorithm.hpp
Change-Id: I5591f0c5f3bb5db67f8b45fae95471f8a555ca68
diff --git a/tools/ndn-autoconfig/dns-srv.cpp b/tools/ndn-autoconfig/dns-srv.cpp
index 574ef17..bc0b3a6 100644
--- a/tools/ndn-autoconfig/dns-srv.cpp
+++ b/tools/ndn-autoconfig/dns-srv.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,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -34,13 +34,14 @@
#include <arpa/nameser_compat.h>
#endif
+#include <ndn-cxx/util/backports.hpp>
+#include <ndn-cxx/util/exception.hpp>
+
#include <iostream>
#include <boost/endian/conversion.hpp>
-namespace ndn {
-namespace tools {
-namespace autoconfig {
+namespace ndn::autoconfig {
using namespace std::string_literals;
@@ -165,6 +166,4 @@
return parseSrvRr(queryAnswer, answerSize);
}
-} // namespace autoconfig
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::autoconfig
diff --git a/tools/ndn-autoconfig/dns-srv.hpp b/tools/ndn-autoconfig/dns-srv.hpp
index 41563e9..8d156b1 100644
--- a/tools/ndn-autoconfig/dns-srv.hpp
+++ b/tools/ndn-autoconfig/dns-srv.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-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,11 +26,10 @@
#ifndef NFD_TOOLS_NDN_AUTOCONFIG_DNS_SRV_HPP
#define NFD_TOOLS_NDN_AUTOCONFIG_DNS_SRV_HPP
-#include "core/common.hpp"
+#include <stdexcept>
+#include <string>
-namespace ndn {
-namespace tools {
-namespace autoconfig {
+namespace ndn::autoconfig {
/** \file
* \brief provide synchronous DNS SRV record querying
@@ -39,14 +38,9 @@
class DnsSrvError : public std::runtime_error
{
public:
- explicit
- DnsSrvError(const std::string& what)
- : std::runtime_error(what)
- {
- }
+ using std::runtime_error::runtime_error;
};
-
/** \brief Send DNS SRV request for \p fqdn
* \param fqdn a fully qualified domain name
* \return FaceUri of the hub from the requested SRV record
@@ -62,8 +56,6 @@
std::string
querySrvRrSearch();
-} // namespace autoconfig
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::autoconfig
#endif // NFD_TOOLS_NDN_AUTOCONFIG_DNS_SRV_HPP
diff --git a/tools/ndn-autoconfig/guess-from-identity-name.cpp b/tools/ndn-autoconfig/guess-from-identity-name.cpp
index 9c50c20..16cf743 100644
--- a/tools/ndn-autoconfig/guess-from-identity-name.cpp
+++ b/tools/ndn-autoconfig/guess-from-identity-name.cpp
@@ -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-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -31,9 +31,7 @@
#include <sstream>
-namespace ndn {
-namespace tools {
-namespace autoconfig {
+namespace ndn::autoconfig {
GuessFromIdentityName::GuessFromIdentityName(KeyChain& keyChain)
: m_keyChain(keyChain)
@@ -62,6 +60,4 @@
}
}
-} // namespace autoconfig
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::autoconfig
diff --git a/tools/ndn-autoconfig/guess-from-identity-name.hpp b/tools/ndn-autoconfig/guess-from-identity-name.hpp
index 9da9093..2901a55 100644
--- a/tools/ndn-autoconfig/guess-from-identity-name.hpp
+++ b/tools/ndn-autoconfig/guess-from-identity-name.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-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -29,9 +29,7 @@
#include "stage.hpp"
#include <ndn-cxx/security/key-chain.hpp>
-namespace ndn {
-namespace tools {
-namespace autoconfig {
+namespace ndn::autoconfig {
/**
* @brief Guessing home router based on the default identity name
@@ -75,8 +73,6 @@
KeyChain& m_keyChain;
};
-} // namespace autoconfig
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::autoconfig
#endif // NFD_TOOLS_NDN_AUTOCONFIG_GUESS_FROM_IDENTITY_NAME_HPP
diff --git a/tools/ndn-autoconfig/guess-from-search-domains.cpp b/tools/ndn-autoconfig/guess-from-search-domains.cpp
index 2f92cc3..8b32867 100644
--- a/tools/ndn-autoconfig/guess-from-search-domains.cpp
+++ b/tools/ndn-autoconfig/guess-from-search-domains.cpp
@@ -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-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,9 +26,7 @@
#include "guess-from-search-domains.hpp"
#include "dns-srv.hpp"
-namespace ndn {
-namespace tools {
-namespace autoconfig {
+namespace ndn::autoconfig {
void
GuessFromSearchDomains::doStart()
@@ -42,6 +40,4 @@
}
}
-} // namespace autoconfig
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::autoconfig
diff --git a/tools/ndn-autoconfig/guess-from-search-domains.hpp b/tools/ndn-autoconfig/guess-from-search-domains.hpp
index 9bd6521..fd02b80 100644
--- a/tools/ndn-autoconfig/guess-from-search-domains.hpp
+++ b/tools/ndn-autoconfig/guess-from-search-domains.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-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,9 +28,7 @@
#include "stage.hpp"
-namespace ndn {
-namespace tools {
-namespace autoconfig {
+namespace ndn::autoconfig {
/**
* @brief Guessing home router based on DNS query with default suffix
@@ -61,8 +59,6 @@
doStart() override;
};
-} // namespace autoconfig
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::autoconfig
#endif // NFD_TOOLS_NDN_AUTOCONFIG_GUESS_FROM_SEARCH_DOMAINS_HPP
diff --git a/tools/ndn-autoconfig/main.cpp b/tools/ndn-autoconfig/main.cpp
index afedc38..2f8e561 100644
--- a/tools/ndn-autoconfig/main.cpp
+++ b/tools/ndn-autoconfig/main.cpp
@@ -38,11 +38,7 @@
#include <ndn-cxx/util/scheduler.hpp>
#include <ndn-cxx/util/time.hpp>
-// ndn-autoconfig is an NDN tool not an NFD tool, so it uses ndn::tools::autoconfig namespace.
-// It lives in NFD repository because nfd-start can automatically start ndn-autoconfig in daemon mode.
-namespace ndn {
-namespace tools {
-namespace autoconfig {
+namespace ndn::autoconfig {
namespace po = boost::program_options;
@@ -184,12 +180,10 @@
return exitCode;
}
-} // namespace autoconfig
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::autoconfig
int
main(int argc, char** argv)
{
- return ndn::tools::autoconfig::main(argc, argv);
+ return ndn::autoconfig::main(argc, argv);
}
diff --git a/tools/ndn-autoconfig/multicast-discovery.cpp b/tools/ndn-autoconfig/multicast-discovery.cpp
index a9fbc88..550ed7f 100644
--- a/tools/ndn-autoconfig/multicast-discovery.cpp
+++ b/tools/ndn-autoconfig/multicast-discovery.cpp
@@ -29,9 +29,7 @@
#include <ndn-cxx/encoding/tlv-nfd.hpp>
-namespace ndn {
-namespace tools {
-namespace autoconfig {
+namespace ndn::autoconfig {
using nfd::ControlParameters;
@@ -153,6 +151,4 @@
});
}
-} // namespace autoconfig
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::autoconfig
diff --git a/tools/ndn-autoconfig/multicast-discovery.hpp b/tools/ndn-autoconfig/multicast-discovery.hpp
index a1d5884..b2a63ed 100644
--- a/tools/ndn-autoconfig/multicast-discovery.hpp
+++ b/tools/ndn-autoconfig/multicast-discovery.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-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -31,9 +31,7 @@
#include <ndn-cxx/mgmt/nfd/controller.hpp>
#include <ndn-cxx/mgmt/nfd/face-status.hpp>
-namespace ndn {
-namespace tools {
-namespace autoconfig {
+namespace ndn::autoconfig {
/** \brief multicast discovery stage
*
@@ -87,8 +85,6 @@
int m_nRegFailure = 0;
};
-} // namespace autoconfig
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::autoconfig
#endif // NFD_TOOLS_NDN_AUTOCONFIG_MULTICAST_DISCOVERY_HPP
diff --git a/tools/ndn-autoconfig/ndn-fch-discovery.cpp b/tools/ndn-autoconfig/ndn-fch-discovery.cpp
index 879ea8e..c6df1b7 100644
--- a/tools/ndn-autoconfig/ndn-fch-discovery.cpp
+++ b/tools/ndn-autoconfig/ndn-fch-discovery.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,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -31,9 +31,7 @@
#include <regex>
#include <sstream>
-namespace ndn {
-namespace tools {
-namespace autoconfig {
+namespace ndn::autoconfig {
/**
* A partial and specialized copy of ndn::FaceUri implementation
@@ -210,6 +208,4 @@
}
}
-} // namespace autoconfig
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::autoconfig
diff --git a/tools/ndn-autoconfig/ndn-fch-discovery.hpp b/tools/ndn-autoconfig/ndn-fch-discovery.hpp
index 000568d..64d3899 100644
--- a/tools/ndn-autoconfig/ndn-fch-discovery.hpp
+++ b/tools/ndn-autoconfig/ndn-fch-discovery.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-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,9 +28,7 @@
#include "stage.hpp"
-namespace ndn {
-namespace tools {
-namespace autoconfig {
+namespace ndn::autoconfig {
/**
* @brief Discovery NDN hub using NDN-FCH protocol
@@ -61,8 +59,6 @@
std::string m_url;
};
-} // namespace autoconfig
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::autoconfig
#endif // NFD_TOOLS_NDN_AUTOCONFIG_NDN_FCH_DISCOVERY_HPP
diff --git a/tools/ndn-autoconfig/procedure.cpp b/tools/ndn-autoconfig/procedure.cpp
index cda39ad..f7295d3 100644
--- a/tools/ndn-autoconfig/procedure.cpp
+++ b/tools/ndn-autoconfig/procedure.cpp
@@ -29,9 +29,7 @@
#include "multicast-discovery.hpp"
#include "ndn-fch-discovery.hpp"
-namespace ndn {
-namespace tools {
-namespace autoconfig {
+namespace ndn::autoconfig {
using nfd::ControlParameters;
using nfd::ControlResponse;
@@ -138,6 +136,4 @@
});
}
-} // namespace autoconfig
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::autoconfig
diff --git a/tools/ndn-autoconfig/procedure.hpp b/tools/ndn-autoconfig/procedure.hpp
index 7c52658..c5dc0bb 100644
--- a/tools/ndn-autoconfig/procedure.hpp
+++ b/tools/ndn-autoconfig/procedure.hpp
@@ -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,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,13 +28,13 @@
#include "stage.hpp"
+#include "core/common.hpp"
+
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/mgmt/nfd/controller.hpp>
#include <ndn-cxx/security/key-chain.hpp>
-namespace ndn {
-namespace tools {
-namespace autoconfig {
+namespace ndn::autoconfig {
struct Options
{
@@ -89,8 +89,6 @@
nfd::Controller m_controller;
};
-} // namespace autoconfig
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::autoconfig
#endif // NFD_TOOLS_NDN_AUTOCONFIG_PROCEDURE_HPP
diff --git a/tools/ndn-autoconfig/stage.cpp b/tools/ndn-autoconfig/stage.cpp
index 0569b24..6bfaff0 100644
--- a/tools/ndn-autoconfig/stage.cpp
+++ b/tools/ndn-autoconfig/stage.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,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -25,9 +25,7 @@
#include "stage.hpp"
-namespace ndn {
-namespace tools {
-namespace autoconfig {
+namespace ndn::autoconfig {
void
Stage::start()
@@ -69,6 +67,4 @@
m_isInProgress = false;
}
-} // namespace autoconfig
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::autoconfig
diff --git a/tools/ndn-autoconfig/stage.hpp b/tools/ndn-autoconfig/stage.hpp
index f7f358e..d11309b 100644
--- a/tools/ndn-autoconfig/stage.hpp
+++ b/tools/ndn-autoconfig/stage.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-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,16 +26,12 @@
#ifndef NFD_TOOLS_NDN_AUTOCONFIG_STAGE_HPP
#define NFD_TOOLS_NDN_AUTOCONFIG_STAGE_HPP
-#include "core/common.hpp"
-
#include <ndn-cxx/net/face-uri.hpp>
#include <ndn-cxx/util/signal.hpp>
#include <iostream>
-namespace ndn {
-namespace tools {
-namespace autoconfig {
+namespace ndn::autoconfig {
/** \brief a discovery stage
*/
@@ -45,14 +41,11 @@
class Error : public std::runtime_error
{
public:
- explicit
- Error(const std::string& what)
- : std::runtime_error(what)
- {
- }
+ using std::runtime_error::runtime_error;
};
- virtual ~Stage() = default;
+ virtual
+ ~Stage() = default;
/** \brief get stage name
* \return stage name as a phrase, typically starting with lower case
@@ -99,8 +92,6 @@
bool m_isInProgress = false;
};
-} // namespace autoconfig
-} // namespace tools
-} // namespace ndn
+} // namespace ndn::autoconfig
#endif // NFD_TOOLS_NDN_AUTOCONFIG_STAGE_HPP