mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 00:07:13 +02:00
using new CmdLineParser
This commit is contained in:
@ -10,7 +10,9 @@ void CmdLineParser::Print()
|
||||
{
|
||||
std::cout << "\nCmdLineParser::Print()\n";
|
||||
std::cout << "\tmulti_id: " << multi_id_ << ", detector_id: " << detector_id_ << std::endl;
|
||||
std::cout << "\tcommand: " << command_ << std::endl;
|
||||
std::cout << "\texecutable: " << executable_ << '\n';
|
||||
std::cout << "\tcommand: " << command_ << '\n';
|
||||
std::cout << "\tn_arguments: " << n_arguments() << '\n';
|
||||
std::cout << "\targuments: ";
|
||||
for (size_t i = 0; i < arguments_.size(); ++i) {
|
||||
std::cout << arguments_[i] << " ";
|
||||
@ -22,12 +24,13 @@ void CmdLineParser::Parse(int argc, char* argv[])
|
||||
{
|
||||
//first element of argv is the command used to call the executable ->skipping
|
||||
//and if this is the only command skip all
|
||||
executable_ = argv[0];
|
||||
if (argc > 1) {
|
||||
//second element is cmd string that needs to be decoded
|
||||
DecodeIdAndPosition(argv[1]);
|
||||
//The rest of the arguments goes into a vector for later processing
|
||||
for (int i = 2; i < argc; ++i)
|
||||
arguments_.push_back(std::string(argv[i]));
|
||||
arguments_.emplace_back(std::string(argv[i]));
|
||||
}
|
||||
};
|
||||
|
||||
@ -65,3 +68,11 @@ void CmdLineParser::DecodeIdAndPosition(const char* c)
|
||||
command_ = c;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<char*> CmdLineParser::argv(){
|
||||
std::vector<char*> vec;
|
||||
vec.push_back(&command_.front());
|
||||
for (auto& arg: arguments_)
|
||||
vec.push_back(&arg.front());
|
||||
return vec;
|
||||
}
|
||||
|
Reference in New Issue
Block a user