![]() |
PUMA Library Reference Manual
|
#include <Puma/OptsParser.h>
Inheritance diagram for Puma::OptsParser:The options parser searches command line parameters for options and handles their option arguments, if applicable.
Classes | |
| struct | Option |
| Type for specifying an array of options recognized by the Option Parser. More... | |
Public Types | |
| enum | { NOARG = -4 , ERR = -3 , NOOPTION = -2 , UNKNOWN = -1 , FINISH = 0 } |
| Return codes for OptsParser::getOption() and OptsParser::getArgument(). More... | |
| enum | ArgType { AT_NONE = 0 , AT_MANDATORY = 1 , AT_OPTIONAL = 2 } |
| Type of argument associated to an option. More... | |
Public Member Functions | |
| OptsParser (int argc, char **argv, const Option *opts) | |
| Constructor. | |
| OptsParser (const std::string &line, const Option *opts) | |
| Constructor. | |
| int | getRawOption () |
| Get next parameter without modification. | |
| int | getOption () |
| Get next option. | |
| int | getResult () const |
| Get result of last processed parameter. | |
| const std::string & | getArgument () |
| Get option argument of last processed parameter. | |
| const std::string & | getUnstrippedArgument () const |
| Get option argument of last processed parameter without stripping. | |
| const std::string & | getOptionName () const |
| Get option name of last processed parameter. | |
| int | getCurrentArgNum () const |
| Get position of current argument. | |
| int | getNextArgNum () const |
| Get position of next argument. | |
Additional Inherited Members | |
Static Public Member Functions inherited from Puma::SimpleParser | |
| static std::string | strip (const std::string &str) |
| Remove enclosing double-quotes from a string. | |
| static int | tokenize (const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ") |
| Splits a given string into tokens recognized by the given delimiters. | |
| anonymous enum |
Return codes for OptsParser::getOption() and OptsParser::getArgument().
| Enumerator | |
|---|---|
| NOARG | Option has no argument. |
| ERR | Error when parsing option. |
| NOOPTION | Command line parameter is not an option. |
| UNKNOWN | Parameter is an unknown option. |
| FINISH | All options are handled. |
| Puma::OptsParser::OptsParser | ( | int | argc, |
| char ** | argv, | ||
| const Option * | opts ) |
Constructor.
| argc | Number of parameters to be analyzed. |
| argv | Parameters to be analyzed. |
| opts | Pointer to array of options which shall be recognized by the options parser. |
| Puma::OptsParser::OptsParser | ( | const std::string & | line, |
| const Option * | opts ) |
Constructor.
| line | Reference to string with parameters to analyze. The parameters are extracted from the string by splitting it up into tokens at:
|
| opts | Pointer to array of options which shall be recognized by the options parser |
| const std::string & Puma::OptsParser::getArgument | ( | ) |
Get option argument of last processed parameter.
This function returns the argument of the option processed during OptsParser::getOption. If the option does not provide any argument the string will be empty. If OptsParser::getOption or respectively OptsParser::getResult returns with OptsParser::NOOPTION this function (OptsParser::getArgument) returns the last processed parameter, which is no option, of course.
| int Puma::OptsParser::getCurrentArgNum | ( | ) | const |
Get position of current argument.
| int Puma::OptsParser::getNextArgNum | ( | ) | const |
Get position of next argument.
| int Puma::OptsParser::getOption | ( | ) |
Get next option.
This function processes the next parameter passed to the constructor OptsParser::OptsParser(). That is, search for options and eventually process option and option argument.
| const std::string & Puma::OptsParser::getOptionName | ( | ) | const |
Get option name of last processed parameter.
If the last processed parameter did not contain an option the string returned by this function is empty.
| int Puma::OptsParser::getRawOption | ( | ) |
Get next parameter without modification.
No option parsing is done.
| int Puma::OptsParser::getResult | ( | ) | const |
Get result of last processed parameter.
The number returned by this function is identical to the number returned by the last call of OptsParser::getOption.
| const std::string & Puma::OptsParser::getUnstrippedArgument | ( | ) | const |
Get option argument of last processed parameter without stripping.
This function returns the argument of the option processed during OptsParser::getOption. If the option does not provide any argument the string will be empty. If OptsParser::getOption or respectively OptsParser::getResult returns with OptsParser::NOOPTION this function (OptsParser::getArgument) returns the last processed parameter, which is no option, of course.