#include <ArgumentParser.h>
Command line parser
This object parses arguments from a command line or from an input stream.
Static Public Attributes | |
static std::vector< std::string > | extra = std::vector<std::string>() |
Public Member Functions | |
ArgumentParser (int argc, char **argv) | |
constructor | |
~ArgumentParser () | |
void | addArgument (std::shared_ptr< cxxopts::Value > s, const std::string name, const std::string help) |
addArgument More... | |
void | addArgument (std::shared_ptr< cxxopts::Value > s, const std::string name, const std::string help, std::function< void(const ArgumentParser *, const std::string &)> callback) |
addArgument More... | |
void | addArgument (const std::string name, const std::string help) |
addArgument More... | |
void | showHelp () |
simply display the help (You need to add -h –help options in your main and call this function by yourself More... | |
void | parse () |
this is the main function. You have to call this function if you want to parse the arguments given to the constructor More... | |
void | showArgs () |
display args with values More... | |
template<typename T > | |
bool | getValueFromKey (const std::string &key, T &value) const |
get the value associated to the key (if this key exists or the type is correct) More... | |
const std::unordered_map< std::string, std::string > & | getMap () const |
std::vector< std::string > | getInputFileList () |
Static Public Member Functions | |
static const std::vector< std::string > | extra_args () |
return extra_args needed for python (arguments) More... | |
|
static |
last parsed extra arguments extra parameter needed for python (arguments)
sofa::gui::common::ArgumentParser::ArgumentParser | ( | int | argc, |
char ** | argv | ||
) |
constructor
argc | from command line |
argv | from command line |
sofa::gui::common::ArgumentParser::~ArgumentParser | ( | ) |
void sofa::gui::common::ArgumentParser::addArgument | ( | const std::string | name, |
const std::string | help | ||
) |
addArgument
@usage Can be call if you want to add parameters
name | argument name such as "help,h" after the comma it's a character use as short name |
help | describing the argument |
void sofa::gui::common::ArgumentParser::addArgument | ( | std::shared_ptr< cxxopts::Value > | s, |
const std::string | name, | ||
const std::string | help | ||
) |
addArgument
@usage Can be call if you want to add parameters
s | a sptr to a cxxopts::Value for examples |
name | argument name such as "help,h" after the comma it's a character use as short name |
help | describing the argument |
void sofa::gui::common::ArgumentParser::addArgument | ( | std::shared_ptr< cxxopts::Value > | s, |
const std::string | name, | ||
const std::string | help, | ||
std::function< void(const ArgumentParser *, const std::string &)> | callback | ||
) |
addArgument
@usage Can be call if you want to add parameters
s | a sptr to a cxxopts::Value for examples |
name | argument name such as "h,help" after the comma it's a character use as short name |
help | describing the argument |
callback | will be called when parsing is done and this arg has been modified |
|
inlinestatic |
return extra_args needed for python (arguments)
std::vector< std::string > sofa::gui::common::ArgumentParser::getInputFileList | ( | ) |
const std::unordered_map< std::string, std::string > & sofa::gui::common::ArgumentParser::getMap | ( | ) | const |
|
inline |
get the value associated to the key (if this key exists or the type is correct)
void sofa::gui::common::ArgumentParser::parse | ( | ) |
this is the main function. You have to call this function if you want to parse the arguments given to the constructor
void sofa::gui::common::ArgumentParser::showArgs | ( | ) |
display args with values
void sofa::gui::common::ArgumentParser::showHelp | ( | ) |
simply display the help (You need to add -h –help options in your main and call this function by yourself