mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 15:20:02 +02:00
removed unsued functions in CmdParser
This commit is contained in:
parent
adaf56ca2e
commit
ca35613b66
@ -10,20 +10,6 @@
|
|||||||
|
|
||||||
namespace sls {
|
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[]) {
|
void CmdParser::Parse(int argc, const char *const argv[]) {
|
||||||
Reset();
|
Reset();
|
||||||
executable_ = argv[0]; // first arg is calling binary
|
executable_ = argv[0]; // first arg is calling binary
|
||||||
@ -108,28 +94,10 @@ void CmdParser::DecodeIdAndPosition(std::string pre){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<const char *> CmdParser::argv() const {
|
|
||||||
std::vector<const char *> 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() {
|
void CmdParser::Reset() {
|
||||||
multi_id_ = 0;
|
multi_id_ = 0;
|
||||||
detector_id_ = -1;
|
detector_id_ = -1;
|
||||||
|
receiver_id_ = -1;
|
||||||
help_ = false;
|
help_ = false;
|
||||||
command_.clear();
|
command_.clear();
|
||||||
executable_.clear();
|
executable_.clear();
|
||||||
|
@ -23,7 +23,6 @@ class CmdParser {
|
|||||||
public:
|
public:
|
||||||
void Parse(int argc, const char *const argv[]);
|
void Parse(int argc, const char *const argv[]);
|
||||||
void Parse(std::string s);
|
void Parse(std::string s);
|
||||||
void Print();
|
|
||||||
|
|
||||||
int multi_id() const noexcept { return multi_id_; };
|
int multi_id() const noexcept { return multi_id_; };
|
||||||
int detector_id() const noexcept { return detector_id_; };
|
int detector_id() const noexcept { return detector_id_; };
|
||||||
@ -37,8 +36,6 @@ class CmdParser {
|
|||||||
const std::vector<std::string> &arguments() const noexcept {
|
const std::vector<std::string> &arguments() const noexcept {
|
||||||
return arguments_;
|
return arguments_;
|
||||||
};
|
};
|
||||||
std::vector<const char *> argv() const;
|
|
||||||
std::string cli_line() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DecodeIdAndPosition(std::string pre);
|
void DecodeIdAndPosition(std::string pre);
|
||||||
|
@ -18,8 +18,8 @@ SCENARIO("Construction", "[support]") {
|
|||||||
REQUIRE(p.multi_id() == 0);
|
REQUIRE(p.multi_id() == 0);
|
||||||
REQUIRE(p.command().empty());
|
REQUIRE(p.command().empty());
|
||||||
REQUIRE(p.arguments().empty());
|
REQUIRE(p.arguments().empty());
|
||||||
REQUIRE(p.argv().empty());
|
// REQUIRE(p.argv().empty());
|
||||||
REQUIRE(p.argv().data() == nullptr);
|
// 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.multi_id() == 0);
|
||||||
REQUIRE(p.command().empty());
|
REQUIRE(p.command().empty());
|
||||||
REQUIRE(p.arguments().empty());
|
REQUIRE(p.arguments().empty());
|
||||||
REQUIRE(p.argv().empty());
|
// REQUIRE(p.argv().empty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WHEN("Parsing a string with a single command") {
|
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.detector_id() == -1);
|
||||||
REQUIRE(p.multi_id() == 0);
|
REQUIRE(p.multi_id() == 0);
|
||||||
REQUIRE(p.arguments().empty());
|
REQUIRE(p.arguments().empty());
|
||||||
REQUIRE(p.argv().size() == 1);
|
// REQUIRE(p.argv().size() == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WHEN("Parsing a string with command and value") {
|
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.multi_id() == 0);
|
||||||
REQUIRE(p.command() == res[i]);
|
REQUIRE(p.command() == res[i]);
|
||||||
REQUIRE(p.arguments().empty());
|
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.multi_id() == multi_id[i]);
|
||||||
REQUIRE(p.command() == res[i]);
|
REQUIRE(p.command() == res[i]);
|
||||||
REQUIRE(p.arguments().empty());
|
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.command() == "list");
|
||||||
REQUIRE(p.isHelp());
|
REQUIRE(p.isHelp());
|
||||||
REQUIRE(p.arguments().empty());
|
REQUIRE(p.arguments().empty());
|
||||||
REQUIRE(p.argv().size() == 1);
|
// REQUIRE(p.argv().size() == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WHEN("Parsing a string with -h at a different position") {
|
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"){
|
TEST_CASE("Allows space between mod id and command"){
|
||||||
CmdParser p;
|
CmdParser p;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user