33 for (
const auto& it : m_set_options)
35 if (it.first.find(flag) != it.first.end())
53 bool ProgramArguments::set_option(
const std::string& flag,
const std::set<std::string>& equivalent_flags,
const std::vector<std::string>& parameters)
55 std::set<std::string> option_flags = equivalent_flags;
56 option_flags.insert(flag);
59 auto it_matching_option = m_set_options.end();
62 std::set<const std::set<std::string>*> options_containing_flags;
64 for (
auto it = m_set_options.begin(); it != m_set_options.end(); ++it)
66 for (
const auto& f : option_flags)
68 if (it->first.find(f) != it->first.end())
70 options_containing_flags.insert(&(it->first));
71 it_matching_option = it;
77 if (options_containing_flags.size() > 1)
80 "Given flags ({}) are parts of {} different options.",
81 utils::join(
", ", std::vector<std::string>(option_flags.begin(), option_flags.end())),
82 options_containing_flags.size());
86 else if (options_containing_flags.size() == 1)
89 if (!std::includes(it_matching_option->first.begin(), it_matching_option->first.end(), option_flags.begin(), option_flags.end()))
92 "Some flags of ({}) are already set, but not all given flags are flags for that option.",
93 utils::join(
", ", std::vector<std::string>(option_flags.begin(), option_flags.end())));
99 if (it_matching_option != m_set_options.end())
101 it_matching_option->second = parameters;
105 m_set_options[option_flags] = parameters;
108 if (std::find(m_given_flags.begin(), m_given_flags.end(), flag) == m_given_flags.end())
110 m_given_flags.push_back(flag);
128 for (
const auto& it : m_set_options)
130 if (it.first.find(flag) != it.first.end())
136 log_error(
"core",
"The flag '{}' is not registered.", flag);
std::vector< std::string > get_set_options() const
std::string get_parameter(const std::string &flag) const
std::vector< std::string > get_parameters(const std::string &flag) const
void get_original_arguments(int *argc, const char ***argv)
bool is_option_set(const std::string &flag) const
void set_option(const std::string &flag, const std::string ¶meter)
#define log_error(channel,...)
CORE_API std::string join(const std::string &joiner, const Iterator &begin, const Iterator &end, const Transform &transform)