Manual for OpenFLUID 2.1.11 |
Class for management of command line arguments.
This class allows to manage the command line arguments as commands, options and extra arguments.
The example below is for a command line program with two commands ('run' and 'search') and associated options
#include <utils/CommandLineParser.hpp>
Public Member Functions | |
CommandLineParser () | |
CommandLineParser (const std::string &ProgramName, const std::string &HelpText) | |
const std::vector< std::string > & | extraArgs () const |
std::string | getHelpText () const |
std::string | getProgramName () const |
std::string | getParsingMessage () const |
std::string | getActiveCommand () const |
const CommandLineCommand & | command (const std::string &Name) const |
void | addCommand (const CommandLineCommand &Command) |
void | addOption (const CommandLineOption &Option) |
bool | parse (std::list< std::string > ArgValues) |
bool | parse (int ArgC, char **ArgV) |
void | reset () |
bool | isHelpAsked () |
void | printHelp (std::ostream &OutStm) |
void | printState (std::ostream &OutStm) |
|
inline |
|
inline |
Instanciates a command line parser with the given parameters
[in] | ProgramName | The name of the programn |
[in] | HelpText | The help text associated to the option |
|
inline |
Adds a command to the parser
[in] | Command | The command to add |
|
inline |
Adds a global option to the parser
[in] | Option | The option to add |
|
inline |
Returns the command corresponding to the given name
[in] | Name | the name of the command |
|
inline |
Returns the extra arguments given to the command
|
inline |
Returns the active command name
|
inline |
Returns the help text of the parser
|
inline |
Returns the message given by the parsing process in case of error(s)
|
inline |
Returns the program name
|
inline |
Tests if the help is asked
|
inline |
Parses arguments from the standard parameters (int argc,char** argv)
given through the main function
[in] | ArgC | The number of arguments |
[in] | ArgV | The array of arguments |
|
inline |
Parses a list of string arguments
[in] | ArgValues | The lists of arguments to parse |
|
inline |
Prints the help text
[in] | OutStm | The stream where the help text is printed (e.g. std::cout) |
|
inline |
Prints the state of the parser
[in] | OutStm | The stream where the help text is printed (e.g. std::cout) |
|
inline |
Resets the parser to default (no active command, no extra arguments, no option activated)