From ca35613b66297dc77c893ea5c9eb60fca8d960c9 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Wed, 15 Sep 2021 08:44:48 +0200 Subject: [PATCH] removed unsued functions in CmdParser --- slsDetectorSoftware/src/CmdParser.cpp | 34 +------------------- slsDetectorSoftware/src/CmdParser.h | 3 -- slsDetectorSoftware/tests/test-CmdParser.cpp | 24 ++++---------- 3 files changed, 8 insertions(+), 53 deletions(-) diff --git a/slsDetectorSoftware/src/CmdParser.cpp b/slsDetectorSoftware/src/CmdParser.cpp index 3c59ebb26..84dbeffef 100644 --- a/slsDetectorSoftware/src/CmdParser.cpp +++ b/slsDetectorSoftware/src/CmdParser.cpp @@ -10,20 +10,6 @@ namespace sls { -void CmdParser::Print() { - std::cout << "\nCmdParser::Print()\n"; - std::cout << "\tmulti_id: " << multi_id_ - << ", detector_id: " << detector_id_ << std::endl; - std::cout << "\texecutable: " << executable_ << '\n'; - std::cout << "\tcommand: " << command_ << '\n'; - std::cout << "\tn_arguments: " << n_arguments() << '\n'; - std::cout << "\targuments: "; - for (const auto &argument : arguments_) { - std::cout << argument << " "; - } - std::cout << "\n\n"; -}; - void CmdParser::Parse(int argc, const char *const argv[]) { Reset(); executable_ = argv[0]; // first arg is calling binary @@ -108,28 +94,10 @@ void CmdParser::DecodeIdAndPosition(std::string pre){ } -std::vector CmdParser::argv() const { - std::vector vec; - if (!command_.empty()) { - vec.push_back(&command_.front()); - } - for (auto &arg : arguments_) { - vec.push_back(&arg.front()); - } - return vec; -} - -std::string CmdParser::cli_line() const { - std::ostringstream os; - os << command_; - for (const auto &arg : arguments_) - os << " " << arg; - return os.str(); -} - void CmdParser::Reset() { multi_id_ = 0; detector_id_ = -1; + receiver_id_ = -1; help_ = false; command_.clear(); executable_.clear(); diff --git a/slsDetectorSoftware/src/CmdParser.h b/slsDetectorSoftware/src/CmdParser.h index adf60974b..7e1bd970e 100644 --- a/slsDetectorSoftware/src/CmdParser.h +++ b/slsDetectorSoftware/src/CmdParser.h @@ -23,7 +23,6 @@ class CmdParser { public: void Parse(int argc, const char *const argv[]); void Parse(std::string s); - void Print(); int multi_id() const noexcept { return multi_id_; }; int detector_id() const noexcept { return detector_id_; }; @@ -37,8 +36,6 @@ class CmdParser { const std::vector &arguments() const noexcept { return arguments_; }; - std::vector argv() const; - std::string cli_line() const; private: void DecodeIdAndPosition(std::string pre); diff --git a/slsDetectorSoftware/tests/test-CmdParser.cpp b/slsDetectorSoftware/tests/test-CmdParser.cpp index 317c7157a..8c18401eb 100644 --- a/slsDetectorSoftware/tests/test-CmdParser.cpp +++ b/slsDetectorSoftware/tests/test-CmdParser.cpp @@ -18,8 +18,8 @@ SCENARIO("Construction", "[support]") { REQUIRE(p.multi_id() == 0); REQUIRE(p.command().empty()); REQUIRE(p.arguments().empty()); - REQUIRE(p.argv().empty()); - REQUIRE(p.argv().data() == nullptr); + // REQUIRE(p.argv().empty()); + // REQUIRE(p.argv().data() == nullptr); } } } @@ -35,7 +35,7 @@ SCENARIO("Parsing a string with the command line parser", "[support]") { REQUIRE(p.multi_id() == 0); REQUIRE(p.command().empty()); REQUIRE(p.arguments().empty()); - REQUIRE(p.argv().empty()); + // REQUIRE(p.argv().empty()); } } WHEN("Parsing a string with a single command") { @@ -46,7 +46,7 @@ SCENARIO("Parsing a string with the command line parser", "[support]") { REQUIRE(p.detector_id() == -1); REQUIRE(p.multi_id() == 0); REQUIRE(p.arguments().empty()); - REQUIRE(p.argv().size() == 1); + // REQUIRE(p.argv().size() == 1); } } WHEN("Parsing a string with command and value") { @@ -72,7 +72,7 @@ SCENARIO("Parsing a string with the command line parser", "[support]") { REQUIRE(p.multi_id() == 0); REQUIRE(p.command() == res[i]); REQUIRE(p.arguments().empty()); - REQUIRE(p.argv().size() == 1); + // REQUIRE(p.argv().size() == 1); } } } @@ -89,7 +89,7 @@ SCENARIO("Parsing a string with the command line parser", "[support]") { REQUIRE(p.multi_id() == multi_id[i]); REQUIRE(p.command() == res[i]); REQUIRE(p.arguments().empty()); - REQUIRE(p.argv().size() == 1); + // REQUIRE(p.argv().size() == 1); } } } @@ -121,7 +121,7 @@ SCENARIO("Parsing strings with -h or --help", "[support]") { REQUIRE(p.command() == "list"); REQUIRE(p.isHelp()); REQUIRE(p.arguments().empty()); - REQUIRE(p.argv().size() == 1); + // REQUIRE(p.argv().size() == 1); } } WHEN("Parsing a string with -h at a different position") { @@ -271,16 +271,6 @@ TEST_CASE("Double digit id", "[support]") { } -TEST_CASE("Build up argv", "[support]") { - CmdParser p; - REQUIRE(p.argv().empty()); - REQUIRE(p.argv().data() == nullptr); - - std::string s = "trimen 3000 4000\n"; - p.Parse(s); - REQUIRE(p.argv().data() != nullptr); - REQUIRE(p.argv().size() == 3); -} TEST_CASE("Allows space between mod id and command"){ CmdParser p;