Skip to content

Wrapper: add choices param #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion include/FluidCLIWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ under the European Union’s Horizon 2020 research and innovation programme
#include <chrono>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <regex>
#include <string>
#include <thread>
#include <utility>
#include <vector>

#include <bitset>
namespace fluid {
namespace client {

Expand Down Expand Up @@ -245,6 +246,7 @@ class CLIWrapper
}
bool testString(ConstString s, BufferT::type) { return s[0] != '-'; }
bool testString(ConstString s, InputBufferT::type) { return s[0] != '-'; }
bool testString(ConstString s, ChoicesT::type) { return s[0] != '-'; }

template <typename T>
ErrorType checkValues(index& i, index argc, const char* argv[], index nArgs,
Expand Down Expand Up @@ -319,6 +321,31 @@ class CLIWrapper

return paramDescriptor<N>().defaultValue;
}

auto fromString(ConstString s,ChoicesT::type)
{
// vector<std::string> choices;
std::istringstream c(s);
c >> std::ws;
std::string tmp;
size_t choices{0};
auto desc = paramDescriptor<N>();
while(std::getline(c,tmp,' '))
{
index idx = desc.lookup(tmp);

if( idx > -1)
{
choices = choices | 1 << idx;
continue;
}
std::cerr << "Warning: unrecognised option " << tmp << std::endl;
}

return ChoicesT::type(choices);

}

};

template <size_t N, typename T>
Expand Down