bmv2
Designing your own switch target with bmv2
|
Public Types | |
enum | ReturnCode { ReturnCode::SUCCESS = 0, ReturnCode::DUPLICATE_OPTION, ReturnCode::INVALID_OPTION_NAME, ReturnCode::OPTION_NOT_PROVIDED, ReturnCode::INVALID_OPTION_TYPE } |
Return codes for this class. More... | |
Public Member Functions | |
TargetParserBasic () | |
Constructor. More... | |
int | parse (const std::vector< std::string > &more_options, std::ostream *errstream) override |
void | help_msg (std::ostream *outstream) const override |
See bm::TargetParserIface::help_msg. More... | |
ReturnCode | add_string_option (const std::string &name, const std::string &help_str) |
ReturnCode | add_int_option (const std::string &name, const std::string &help_str) |
ReturnCode | add_uint_option (const std::string &name, const std::string &help_str) |
ReturnCode | add_flag_option (const std::string &name, const std::string &help_str) |
ReturnCode | get_string_option (const std::string &name, std::string *v) const |
ReturnCode | get_int_option (const std::string &name, int *v) const |
ReturnCode | get_uint_option (const std::string &name, unsigned int *v) const |
ReturnCode | get_flag_option (const std::string &name, bool *v) const |
A basic target-specific command-line options parser, which should be enough for many targets.
|
strong |
Return codes for this class.
bm::TargetParserBasic::TargetParserBasic | ( | ) |
Constructor.
ReturnCode bm::TargetParserBasic::add_flag_option | ( | const std::string & | name, |
const std::string & | help_str | ||
) |
Add a command-line flag --<name>
, along with a help string that will be displayed by help_msg().You will need to call get_flag_option() to determine presence / absence of the flag.
ReturnCode bm::TargetParserBasic::add_int_option | ( | const std::string & | name, |
const std::string & | help_str | ||
) |
Add a command-line option --<name>
with a value of type int, along with a help string that will be displayed by help_msg(). You will need to call get_int_option() to retrieve the value.
ReturnCode bm::TargetParserBasic::add_string_option | ( | const std::string & | name, |
const std::string & | help_str | ||
) |
Add a command-line option --<name>
with a value of type string, along with a help string that will be displayed by help_msg(). You will need to call get_string_option() to retrieve the value.
ReturnCode bm::TargetParserBasic::add_uint_option | ( | const std::string & | name, |
const std::string & | help_str | ||
) |
Add a command-line option --<name>
with a value of type unsigned int, along with a help string that will be displayed by help_msg(). You will need to call get_uint_option() to retrieve the value.
ReturnCode bm::TargetParserBasic::get_flag_option | ( | const std::string & | name, |
bool * | v | ||
) | const |
Determine whether the command-line flag --<name>
was present / absent on the command line.
ReturnCode bm::TargetParserBasic::get_int_option | ( | const std::string & | name, |
int * | v | ||
) | const |
Retrieve the value of command-line option --<name>
. The option needs to have been previously registered with add_int_option().
ReturnCode bm::TargetParserBasic::get_string_option | ( | const std::string & | name, |
std::string * | v | ||
) | const |
Retrieve the value of command-line option --<name>
. The option needs to have been previously registered with add_string_option().
ReturnCode bm::TargetParserBasic::get_uint_option | ( | const std::string & | name, |
unsigned int * | v | ||
) | const |
Retrieve the value of command-line option --<name>
. The option needs to have been previously registered with add_uint_option().
|
overridevirtual |
See bm::TargetParserIface::help_msg.
Implements bm::TargetParserIface.
|
overridevirtual |
See bm::TargetParserIface::parse. Make sure all possible options have been registered using add_string_option(), add_int_option(), add_uint_option() or add_flag_option().
Implements bm::TargetParserIface.
Reimplemented in bm::TargetParserBasicWithDynModules.