tools: rename nfd::tools::nfdc::OutputFormat to ReportFormat
refs #3749
Change-Id: I4984d056c26f9ecbda25103ad60dc50bb60a4dec
diff --git a/tools/nfdc/main.cpp b/tools/nfdc/main.cpp
index aa5d7db..74ef47d 100644
--- a/tools/nfdc/main.cpp
+++ b/tools/nfdc/main.cpp
@@ -95,7 +95,7 @@
}
if (strcmp(argv[1], "legacy-nfd-status") == 0) {
- return status_main(argc - 1, argv + 1);
+ return statusMain(argc - 1, argv + 1);
}
::optind = 2; //start reading options from 2nd argument i.e. Command
diff --git a/tools/nfdc/status-main.cpp b/tools/nfdc/status-main.cpp
index c0d41b0..e268e40 100644
--- a/tools/nfdc/status-main.cpp
+++ b/tools/nfdc/status-main.cpp
@@ -23,13 +23,8 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "status-main.hpp"
#include "core/version.hpp"
-#include <ndn-cxx/security/validator-null.hpp>
-
-#include <boost/program_options/options_description.hpp>
-#include <boost/program_options/variables_map.hpp>
-#include <boost/program_options/parsers.hpp>
-
#include "status-report.hpp"
#include "forwarder-general-module.hpp"
#include "channel-module.hpp"
@@ -38,19 +33,16 @@
#include "rib-module.hpp"
#include "strategy-choice-module.hpp"
+#include <ndn-cxx/security/validator-null.hpp>
+#include <boost/program_options.hpp>
+
namespace nfd {
namespace tools {
namespace nfdc {
-enum class OutputFormat
-{
- XML = 1,
- TEXT = 2
-};
-
struct Options
{
- OutputFormat output = OutputFormat::TEXT;
+ ReportFormat output = ReportFormat::TEXT;
bool wantForwarderGeneral = false;
bool wantChannels = false;
bool wantFaces = false;
@@ -109,9 +101,9 @@
}
if (vm.count("xml") > 0) {
- options.output = OutputFormat::XML;
+ options.output = ReportFormat::XML;
}
- if (options.output == OutputFormat::XML ||
+ if (options.output == ReportFormat::XML ||
(!options.wantForwarderGeneral && !options.wantChannels && !options.wantFaces &&
!options.wantFib && !options.wantRib && !options.wantStrategyChoice)) {
options.wantForwarderGeneral = options.wantChannels = options.wantFaces =
@@ -122,7 +114,7 @@
}
int
-status_main(int argc, char** argv)
+statusMain(int argc, char** argv)
{
int exitCode = -1;
Options options;
@@ -178,10 +170,10 @@
}
switch (options.output) {
- case OutputFormat::XML:
+ case ReportFormat::XML:
report.formatXml(std::cout);
break;
- case OutputFormat::TEXT:
+ case ReportFormat::TEXT:
report.formatText(std::cout);
break;
}
diff --git a/tools/nfdc/status-main.hpp b/tools/nfdc/status-main.hpp
index 79ccece..910e4ac 100644
--- a/tools/nfdc/status-main.hpp
+++ b/tools/nfdc/status-main.hpp
@@ -26,14 +26,12 @@
#ifndef NFD_TOOLS_NFDC_STATUS_MAIN_HPP
#define NFD_TOOLS_NFDC_STATUS_MAIN_HPP
-#include "module.hpp"
-
namespace nfd {
namespace tools {
namespace nfdc {
int
-status_main(int argc, char** argv);
+statusMain(int argc, char** argv);
} // namespace nfdc
} // namespace tools
diff --git a/tools/nfdc/status-report.cpp b/tools/nfdc/status-report.cpp
index c687147..ff3e8a6 100644
--- a/tools/nfdc/status-report.cpp
+++ b/tools/nfdc/status-report.cpp
@@ -30,6 +30,30 @@
namespace tools {
namespace nfdc {
+ReportFormat
+parseReportFormat(const std::string& s)
+{
+ if (s == "xml") {
+ return ReportFormat::XML;
+ }
+ if (s == "text") {
+ return ReportFormat::TEXT;
+ }
+ BOOST_THROW_EXCEPTION(std::invalid_argument("unrecognized ReportFormat"));
+}
+
+std::ostream&
+operator<<(std::ostream& os, ReportFormat fmt)
+{
+ switch (fmt) {
+ case ReportFormat::XML:
+ return os << "xml";
+ case ReportFormat::TEXT:
+ return os << "text";
+ }
+ return os << static_cast<int>(fmt);
+}
+
uint32_t
StatusReport::collect(Face& face, KeyChain& keyChain, Validator& validator, const CommandOptions& options)
{
diff --git a/tools/nfdc/status-report.hpp b/tools/nfdc/status-report.hpp
index dea9b9f..cfb31f4 100644
--- a/tools/nfdc/status-report.hpp
+++ b/tools/nfdc/status-report.hpp
@@ -36,6 +36,17 @@
using ndn::security::KeyChain;
using ndn::Validator;
+enum class ReportFormat {
+ XML = 1,
+ TEXT = 2
+};
+
+ReportFormat
+parseReportFormat(const std::string& s);
+
+std::ostream&
+operator<<(std::ostream& os, ReportFormat fmt);
+
/** \brief collects and prints NFD status report
*/
class StatusReport : noncopyable