Refactor and modernize namespace declarations

 * Completely remove inline namespace v2
 * Flatten some unnecessarily deep namespace nesting
 * Move DummyClientFace, Segmenter, SegmentFetcher to namespace ndn
 * Move all unit tests to namespace ndn::tests

Change-Id: I8bcfcf9fd669936a3277d2d5d505f765b4b05742
diff --git a/tools/ndnsec/accumulator.hpp b/tools/ndnsec/accumulator.hpp
index a696000..eec3e09 100644
--- a/tools/ndnsec/accumulator.hpp
+++ b/tools/ndnsec/accumulator.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -24,8 +24,7 @@
 
 #include <boost/program_options/value_semantic.hpp>
 
-namespace ndn {
-namespace ndnsec {
+namespace ndn::ndnsec {
 
 /**
  * @brief An accumulating option value to handle multiple incrementing options.
@@ -154,7 +153,6 @@
   return new AccumulatorType<T>(store);
 }
 
-} // namespace ndnsec
-} // namespace ndn
+} // namespace ndn::ndnsec
 
 #endif // NDN_CXX_TOOLS_NDNSEC_ACCUMULATOR_HPP
diff --git a/tools/ndnsec/cert-dump.cpp b/tools/ndnsec/cert-dump.cpp
index b5ac12f..8237f5d 100644
--- a/tools/ndnsec/cert-dump.cpp
+++ b/tools/ndnsec/cert-dump.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -27,8 +27,7 @@
 #include <boost/date_time/posix_time/posix_time_duration.hpp>
 #endif // BOOST_VERSION < 106700
 
-namespace ndn {
-namespace ndnsec {
+namespace ndn::ndnsec {
 
 int
 ndnsec_cert_dump(int argc, char** argv)
@@ -142,5 +141,4 @@
   return 0;
 }
 
-} // namespace ndnsec
-} // namespace ndn
+} // namespace ndn::ndnsec
diff --git a/tools/ndnsec/cert-gen.cpp b/tools/ndnsec/cert-gen.cpp
index c151471..c382119 100644
--- a/tools/ndnsec/cert-gen.cpp
+++ b/tools/ndnsec/cert-gen.cpp
@@ -27,8 +27,7 @@
 #include "ndn-cxx/security/transform/buffer-source.hpp"
 #include "ndn-cxx/security/transform/stream-sink.hpp"
 
-namespace ndn {
-namespace ndnsec {
+namespace ndn::ndnsec {
 
 int
 ndnsec_cert_gen(int argc, char** argv)
@@ -157,5 +156,4 @@
   return 0;
 }
 
-} // namespace ndnsec
-} // namespace ndn
+} // namespace ndn::ndnsec
diff --git a/tools/ndnsec/cert-install.cpp b/tools/ndnsec/cert-install.cpp
index 9a13e33..345ee24 100644
--- a/tools/ndnsec/cert-install.cpp
+++ b/tools/ndnsec/cert-install.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -27,8 +27,7 @@
 #include "ndn-cxx/security/transform/stream-sink.hpp"
 #include "ndn-cxx/security/transform/stream-source.hpp"
 
-namespace ndn {
-namespace ndnsec {
+namespace ndn::ndnsec {
 
 int
 ndnsec_cert_install(int argc, char** argv)
@@ -120,5 +119,4 @@
   return 0;
 }
 
-} // namespace ndnsec
-} // namespace ndn
+} // namespace ndn::ndnsec
diff --git a/tools/ndnsec/delete.cpp b/tools/ndnsec/delete.cpp
index 2159bb3..25de41c 100644
--- a/tools/ndnsec/delete.cpp
+++ b/tools/ndnsec/delete.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -22,8 +22,7 @@
 #include "ndnsec.hpp"
 #include "util.hpp"
 
-namespace ndn {
-namespace ndnsec {
+namespace ndn::ndnsec {
 
 int
 ndnsec_delete(int argc, char** argv)
@@ -112,5 +111,4 @@
   return 0;
 }
 
-} // namespace ndnsec
-} // namespace ndn
+} // namespace ndn::ndnsec
diff --git a/tools/ndnsec/export.cpp b/tools/ndnsec/export.cpp
index 4ce0ebc..5641e08 100644
--- a/tools/ndnsec/export.cpp
+++ b/tools/ndnsec/export.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -26,8 +26,7 @@
 
 #include <openssl/crypto.h>
 
-namespace ndn {
-namespace ndnsec {
+namespace ndn::ndnsec {
 
 int
 ndnsec_export(int argc, char** argv)
@@ -131,5 +130,4 @@
   return 0;
 }
 
-} // namespace ndnsec
-} // namespace ndn
+} // namespace ndn::ndnsec
diff --git a/tools/ndnsec/get-default.cpp b/tools/ndnsec/get-default.cpp
index 37f7425..8dba1bf 100644
--- a/tools/ndnsec/get-default.cpp
+++ b/tools/ndnsec/get-default.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -22,8 +22,7 @@
 #include "ndnsec.hpp"
 #include "util.hpp"
 
-namespace ndn {
-namespace ndnsec {
+namespace ndn::ndnsec {
 
 int
 ndnsec_get_default(int argc, char** argv)
@@ -127,5 +126,4 @@
   }
 }
 
-} // namespace ndnsec
-} // namespace ndn
+} // namespace ndn::ndnsec
diff --git a/tools/ndnsec/import.cpp b/tools/ndnsec/import.cpp
index c25b0c7..9e0c830 100644
--- a/tools/ndnsec/import.cpp
+++ b/tools/ndnsec/import.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -26,8 +26,7 @@
 
 #include <openssl/crypto.h>
 
-namespace ndn {
-namespace ndnsec {
+namespace ndn::ndnsec {
 
 int
 ndnsec_import(int argc, char** argv)
@@ -92,5 +91,4 @@
   return 0;
 }
 
-} // namespace ndnsec
-} // namespace ndn
+} // namespace ndn::ndnsec
diff --git a/tools/ndnsec/key-gen.cpp b/tools/ndnsec/key-gen.cpp
index ac85fe8..a045cd6 100644
--- a/tools/ndnsec/key-gen.cpp
+++ b/tools/ndnsec/key-gen.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -22,8 +22,7 @@
 #include "ndnsec.hpp"
 #include "util.hpp"
 
-namespace ndn {
-namespace ndnsec {
+namespace ndn::ndnsec {
 
 int
 ndnsec_key_gen(int argc, char** argv)
@@ -158,5 +157,4 @@
   return 0;
 }
 
-} // namespace ndnsec
-} // namespace ndn
+} // namespace ndn::ndnsec
diff --git a/tools/ndnsec/list.cpp b/tools/ndnsec/list.cpp
index 502d909..3b02b80 100644
--- a/tools/ndnsec/list.cpp
+++ b/tools/ndnsec/list.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -25,8 +25,7 @@
 
 #include "ndn-cxx/util/indented-stream.hpp"
 
-namespace ndn {
-namespace ndnsec {
+namespace ndn::ndnsec {
 namespace {
 
 // https://en.wikipedia.org/wiki/Box_Drawing
@@ -247,5 +246,4 @@
   return 0;
 }
 
-} // namespace ndnsec
-} // namespace ndn
+} // namespace ndn::ndnsec
diff --git a/tools/ndnsec/main.cpp b/tools/ndnsec/main.cpp
index 436388f..7609345 100644
--- a/tools/ndnsec/main.cpp
+++ b/tools/ndnsec/main.cpp
@@ -31,7 +31,7 @@
 
 NDN_LOG_INIT(ndnsec);
 
-const char NDNSEC_HELP_TEXT[] = R"STR(Usage: ndnsec COMMAND [OPTION]...
+constexpr std::string_view NDNSEC_HELP_TEXT = R"STR(Usage: ndnsec COMMAND [OPTION]...
 
 Available commands:
   help           Print this help text
@@ -49,7 +49,8 @@
   import         Import an identity from a SafeBag
   unlock-tpm     Unlock the TPM
 
-Try 'ndnsec COMMAND --help' for more information on each command.)STR";
+Try 'ndnsec COMMAND --help' for more information on a command.
+)STR";
 
 int
 main(int argc, char* argv[])
@@ -66,7 +67,7 @@
     argv++;
   }
   else {
-    std::cerr << NDNSEC_HELP_TEXT << std::endl;
+    std::cerr << NDNSEC_HELP_TEXT;
     return 2;
   }
 
@@ -74,7 +75,7 @@
 
   try {
     using namespace ndn::ndnsec;
-    if (command == "help")              { std::cout << NDNSEC_HELP_TEXT << std::endl; }
+    if (command == "help")              { std::cout << NDNSEC_HELP_TEXT; }
     else if (command == "version")      { std::cout << NDN_CXX_VERSION_BUILD_STRING << std::endl; }
     else if (command == "list")         { return ndnsec_list(argc, argv); }
     else if (command == "get-default")  { return ndnsec_get_default(argc, argv); }
@@ -89,9 +90,7 @@
     else if (command == "import")       { return ndnsec_import(argc, argv); }
     else if (command == "unlock-tpm")   { return ndnsec_unlock_tpm(argc, argv); }
     else {
-      std::cerr << "ERROR: Unknown command '" << command << "'\n"
-                << "\n"
-                << NDNSEC_HELP_TEXT << std::endl;
+      std::cerr << "ERROR: Unknown command '" << command << "'\n\n" << NDNSEC_HELP_TEXT;
       return 2;
     }
   }
diff --git a/tools/ndnsec/ndnsec.hpp b/tools/ndnsec/ndnsec.hpp
index bb773ea..49c4de8 100644
--- a/tools/ndnsec/ndnsec.hpp
+++ b/tools/ndnsec/ndnsec.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -22,8 +22,7 @@
 #ifndef NDN_CXX_TOOLS_NDNSEC_NDNSEC_HPP
 #define NDN_CXX_TOOLS_NDNSEC_NDNSEC_HPP
 
-namespace ndn {
-namespace ndnsec {
+namespace ndn::ndnsec {
 
 // TODO: convert to tool registry (maybe)
 
@@ -63,7 +62,6 @@
 int
 ndnsec_unlock_tpm(int argc, char** argv);
 
-} // namespace ndnsec
-} // namespace ndn
+} // namespace ndn::ndnsec
 
 #endif // NDN_CXX_TOOLS_NDNSEC_NDNSEC_HPP
diff --git a/tools/ndnsec/set-default.cpp b/tools/ndnsec/set-default.cpp
index 128ae19..b0ebf09 100644
--- a/tools/ndnsec/set-default.cpp
+++ b/tools/ndnsec/set-default.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -22,8 +22,7 @@
 #include "ndnsec.hpp"
 #include "util.hpp"
 
-namespace ndn {
-namespace ndnsec {
+namespace ndn::ndnsec {
 
 int
 ndnsec_set_default(int argc, char** argv)
@@ -95,5 +94,4 @@
   return 0;
 }
 
-} // namespace ndnsec
-} // namespace ndn
+} // namespace ndn::ndnsec
diff --git a/tools/ndnsec/sign-req.cpp b/tools/ndnsec/sign-req.cpp
index e202bc5..ca53819 100644
--- a/tools/ndnsec/sign-req.cpp
+++ b/tools/ndnsec/sign-req.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -24,8 +24,7 @@
 
 #include "ndn-cxx/security/signing-helpers.hpp"
 
-namespace ndn {
-namespace ndnsec {
+namespace ndn::ndnsec {
 
 int
 ndnsec_sign_req(int argc, char** argv)
@@ -93,5 +92,4 @@
   return 0;
 }
 
-} // namespace ndnsec
-} // namespace ndn
+} // namespace ndn::ndnsec
diff --git a/tools/ndnsec/unlock-tpm.cpp b/tools/ndnsec/unlock-tpm.cpp
index 1baaa55..97cd702 100644
--- a/tools/ndnsec/unlock-tpm.cpp
+++ b/tools/ndnsec/unlock-tpm.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -28,8 +28,7 @@
 #include <cstring>
 #include <unistd.h>
 
-namespace ndn {
-namespace ndnsec {
+namespace ndn::ndnsec {
 
 int
 ndnsec_unlock_tpm(int argc, char** argv)
@@ -86,5 +85,4 @@
 #endif // NDN_CXX_HAVE_GETPASS
 }
 
-} // namespace ndnsec
-} // namespace ndn
+} // namespace ndn::ndnsec
diff --git a/tools/ndnsec/util.cpp b/tools/ndnsec/util.cpp
index ae407db..a85b9e3 100644
--- a/tools/ndnsec/util.cpp
+++ b/tools/ndnsec/util.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -25,8 +25,7 @@
 
 #include <unistd.h>
 
-namespace ndn {
-namespace ndnsec {
+namespace ndn::ndnsec {
 
 bool
 getPassword(std::string& password, const std::string& prompt, bool shouldConfirm)
@@ -89,5 +88,4 @@
   NDN_CXX_UNREACHABLE;
 }
 
-} // namespace ndnsec
-} // namespace ndn
+} // namespace ndn::ndnsec
diff --git a/tools/ndnsec/util.hpp b/tools/ndnsec/util.hpp
index 913198c..7a244d5 100644
--- a/tools/ndnsec/util.hpp
+++ b/tools/ndnsec/util.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -31,8 +31,7 @@
 #include <boost/program_options/parsers.hpp>
 #include <boost/program_options/variables_map.hpp>
 
-namespace ndn {
-namespace ndnsec {
+namespace ndn::ndnsec {
 
 /**
  * @brief Get certificate of given name from PIB.
@@ -77,7 +76,6 @@
 bool
 getPassword(std::string& password, const std::string& prompt, bool shouldConfirm = true);
 
-} // namespace ndnsec
-} // namespace ndn
+} // namespace ndn::ndnsec
 
 #endif // NDN_CXX_TOOLS_NDNSEC_UTIL_HPP