bmv2
Designing your own switch target with bmv2
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Types | Public Member Functions | List of all members
bm::TargetParserBasic Class Reference
Inheritance diagram for bm::TargetParserBasic:
Inheritance graph
[legend]

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
 

Detailed Description

A basic target-specific command-line options parser, which should be enough for many targets.

Member Enumeration Documentation

◆ ReturnCode

Return codes for this class.

Enumerator
SUCCESS 

successful operation

DUPLICATE_OPTION 

option was already added to the parser

INVALID_OPTION_NAME 

option name not recognized (did not call add)

OPTION_NOT_PROVIDED 

the option was not provided by the user

INVALID_OPTION_TYPE 

type mismatch, you used the wrong get method

Constructor & Destructor Documentation

◆ TargetParserBasic()

bm::TargetParserBasic::TargetParserBasic ( )

Constructor.

Member Function Documentation

◆ add_flag_option()

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.

◆ add_int_option()

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.

◆ add_string_option()

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.

◆ add_uint_option()

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.

◆ get_flag_option()

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.

◆ get_int_option()

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().

◆ get_string_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().

◆ get_uint_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().

◆ help_msg()

void bm::TargetParserBasic::help_msg ( std::ostream *  outstream) const
overridevirtual

◆ parse()

int bm::TargetParserBasic::parse ( const std::vector< std::string > &  more_options,
std::ostream *  errstream 
)
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.


The documentation for this class was generated from the following file: