CBMC
|
#include <goto_cc_cmdline.h>
Classes | |
struct | argt |
Public Types | |
typedef std::list< argt > | parsed_argvt |
Public Types inherited from cmdlinet | |
typedef std::vector< std::string > | argst |
Public Member Functions | |
~goto_cc_cmdlinet () | |
virtual bool | parse (int argc, const char **argv)=0 |
std::size_t | get_optnr (const std::string &option) |
void | set (const std::string &opt, const char *value) override |
Set option option to value . More... | |
void | set (const std::string &opt, const std::string &value) override |
void | set (const std::string &opt, bool value=true) override |
Set option option to value , or true if the value is omitted. More... | |
bool | have_infile_arg () const |
virtual bool | parse (int argc, const char **argv, const char *optstring) |
Parses a commandline according to a specification given in optstring . More... | |
Public Member Functions inherited from cmdlinet | |
virtual bool | parse (int argc, const char **argv, const char *optstring) |
Parses a commandline according to a specification given in optstring . More... | |
std::string | get_value (char option) const |
std::string | get_value (const char *option) const |
std::optional< std::string > | value_opt (char option) const |
std::optional< std::string > | value_opt (const char *option) const |
const std::list< std::string > & | get_values (const std::string &option) const |
const std::list< std::string > & | get_values (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 single list of values. More... | |
virtual bool | isset (char option) const |
virtual bool | isset (const char *option) const |
virtual void | clear () |
bool | has_option (const std::string &option) const |
option_namest | option_names () const |
Pseudo-object that can be used to iterate over options in this cmdlinet (should not outlive this) More... | |
cmdlinet () | |
virtual | ~cmdlinet () |
std::vector< std::string > | get_argument_suggestions (const std::string &unknown_argument) |
Static Public Member Functions | |
static bool | in_list (const char *option, const char **list) |
Public Attributes | |
parsed_argvt | parsed_argv |
std::string | stdin_file |
Public Attributes inherited from cmdlinet | |
argst | args |
std::string | unknown_arg |
Protected Member Functions | |
void | add_arg (const std::string &arg) |
void | add_infile_arg (const std::string &arg) |
Protected Member Functions inherited from cmdlinet | |
void | parse_optstring (const char *optstring) |
Parses an optstring and writes the result to cmdlinet::options. More... | |
bool | parse_arguments (int argc, const char **argv) |
Parses a commandline according to a previously parsed optstring and writes the result to cmdlinet::options. More... | |
std::optional< std::size_t > | getoptnr (char option) const |
std::optional< std::size_t > | getoptnr (const std::string &option) const |
Additional Inherited Members | |
Protected Attributes inherited from cmdlinet | |
std::vector< optiont > | options |
Definition at line 19 of file goto_cc_cmdline.h.
typedef std::list<argt> goto_cc_cmdlinet::parsed_argvt |
Definition at line 63 of file goto_cc_cmdline.h.
goto_cc_cmdlinet::~goto_cc_cmdlinet | ( | ) |
Definition at line 25 of file goto_cc_cmdline.cpp.
|
inlineprotected |
Definition at line 71 of file goto_cc_cmdline.h.
|
protected |
Definition at line 102 of file goto_cc_cmdline.cpp.
std::size_t goto_cc_cmdlinet::get_optnr | ( | const std::string & | option | ) |
Definition at line 49 of file goto_cc_cmdline.cpp.
bool goto_cc_cmdlinet::have_infile_arg | ( | ) | const |
Definition at line 121 of file goto_cc_cmdline.cpp.
|
static |
Definition at line 38 of file goto_cc_cmdline.cpp.
|
pure virtual |
Implemented in ms_link_cmdlinet, ms_cl_cmdlinet, ld_cmdlinet, gcc_cmdlinet, bcc_cmdlinet, as_cmdlinet, as86_cmdlinet, and armcc_cmdlinet.
bool cmdlinet::parse |
Parses a commandline according to a specification given in optstring
.
argc | How many arguments there are. |
argv | An array of C strings. The 0th element is assumed to be the name of the command as it was invoked (e.g. /usr/bin/cmake) and is ignored. It is further assumed the array holds argc+1 elements with the C string at index argc being a terminating null pointer. This argument is parsed based on optstring . |
optstring | A specification of allowed command line options. This is a C string container any number of single characters other than '(', ')' or ':' signifying a "short" option consisting of just that character, or names consisting of any characters other than ')' surrounded by a matching pair of '(' and ')' signifying a "long" option with the name being the string between '(' and ')', both of which can be optionally followed by a single ':' indicating that the option takes a argument, if not present it does not. arguments must be in the next array element in argv , except for short options whose argument may also be concatenated directly on them. |
Option names in argv
must start with either '-' or "--", no distinction between long and short options is made here, although it is customary to use only one '-' for short options and "--" for long options.
All options are optional, if some are required it is up to the user to check that they are present.
Examples:
argc = 4 argv = {"name", "-V", "--name", "CProver", nullptr}
opstring = "V(version)(name):"
here the argument to "name" would be "CProver", and "V" is a short option passed without arguments.
argc = 3 argv = {"other-name", "-fFilename", "--trace", nullptr}
optstring = "f:(trace)(some-other-option):G"
here the argument to option "f" would be "Filename", "trace" is a long option with no argument, and "some-other-option" and "G" are both allowed options that don’t appear on the commandline (with and without argument respectively).
Definition at line 74 of file cmdline.cpp.
|
inlineoverridevirtual |
Set option option
to value
, or true
if the value is omitted.
Reimplemented from cmdlinet.
Definition at line 45 of file goto_cc_cmdline.h.
|
inlineoverridevirtual |
Set option option
to value
.
Reimplemented from cmdlinet.
Definition at line 33 of file goto_cc_cmdline.h.
|
inlineoverridevirtual |
Reimplemented from cmdlinet.
Definition at line 38 of file goto_cc_cmdline.h.
parsed_argvt goto_cc_cmdlinet::parsed_argv |
Definition at line 64 of file goto_cc_cmdline.h.
std::string goto_cc_cmdlinet::stdin_file |
Definition at line 68 of file goto_cc_cmdline.h.