57 if(i.has_value() && !
options[*i].values.empty())
58 return options[*i].values.front();
72 "unknown command line option", option);
83 options[*i].values.push_back(value);
88 "unknown command line option", option);
113 if(i.has_value() && !
options[*i].values.empty())
114 return options[*i].values.front();
120 const std::string &option)
const
130std::list<std::string>
147 for(std::size_t i=0; i<
options.size(); i++)
151 return std::optional<std::size_t>();
156 for(std::size_t i=0; i<
options.size(); i++)
157 if(
options[i].optstring==option)
160 return std::optional<std::size_t>();
177 while(optstring[0] != 0)
182 optstring[0] !=
':',
"cmdlinet::parse: Invalid option string\n");
184 if(optstring[0] ==
'(')
188 option.
isset =
false;
191 for(optstring++; optstring[0] !=
')' && optstring[0] != 0; optstring++)
194 if(optstring[0] ==
')')
202 option.
isset =
false;
207 if(optstring[0] ==
':')
219std::vector<std::string>
224 std::size_t distance;
229 return distance < other.distance;
238 for(
const auto &option :
options)
242 const auto long_name =
"--" + option.optstring;
250 const auto short_name = std::string{
"-"} + option.optchar;
263 auto min = std::min_element(
267 "there is a minimum because it's not empty");
281 for(
int i = 1; i < argc; i++)
283 if(argv[i][0] !=
'-')
284 args.push_back(argv[i]);
287 std::optional<std::size_t>
optnr;
289 if(argv[i][1] != 0 && argv[i][2] == 0)
291 else if(argv[i][1] ==
'-')
299 if(!
optnr.has_value())
303 if(!
optnr.has_value())
318 if(argv[i][0] ==
'-' && argv[i][1] != 0)
333 : command_line(command_line), index(index)
343 goto_next_valid_index();
379 return index == other.
index;
386 return index != other.
index;
virtual void clear()
Reset the abstract state.
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
std::string get_value(char option) const
virtual bool isset(char option) const
std::list< std::string > get_comma_separated_values(const char *option) const
Collect all occurrences of option option and split their values on each comma, merging them into a si...
std::optional< std::size_t > getoptnr(char option) const
std::optional< std::string > value_opt(char option) const
bool parse_arguments(int argc, const char **argv)
Parses a commandline according to a previously parsed optstring and writes the result to cmdlinet::op...
std::vector< optiont > options
virtual void set(const std::string &option, bool value=true)
Set option option to value, or true if the value is omitted.
virtual bool parse(int argc, const char **argv, const char *optstring)
Parses a commandline according to a specification given in optstring.
std::vector< std::string > get_argument_suggestions(const std::string &unknown_argument)
void parse_optstring(const char *optstring)
Parses an optstring and writes the result to cmdlinet::options.
option_namest option_names() const
Pseudo-object that can be used to iterate over options in this cmdlinet (should not outlive this)
const std::list< std::string > & get_values(const std::string &option) const
Thrown when users pass incorrect command line arguments, for example passing no files to analysis or ...
static std::list< std::string > immutable_empty_list
bool operator<(const reaching_definitiont &a, const reaching_definitiont &b)
In order to use instances of this structure as keys in ordered containers, such as std::map,...
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
#define PRECONDITION(CONDITION)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
void split_string(const std::string &s, char delim, std::vector< std::string > &result, bool strip, bool remove_empty)
bool is_valid_index() const
const std::string & operator*()
const cmdlinet * command_line
bool operator==(const option_names_iteratort &other)
void goto_next_valid_index()
bool operator!=(const option_names_iteratort &other)
option_names_iteratort()=default
option_names_iteratort & operator++()
option_names_iteratort end()
option_names_iteratort begin()
option_namest(const cmdlinet &command_line)
const cmdlinet & command_line
Simple automaton that can detect whether a string can be transformed into another with a limited numb...