Documentation for OpenFLUID
2.2.0
|
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, bool UseCustomOrder=false) | |
const std::vector< std::string > & | extraArgs () const |
const std::vector< std::string > & | thirdPartyArgs () 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) |
Protected Member Functions | |
int | getLargestCommandLength () |
int | getLargestOptionLength () |
std::string | getCustomIndent (int CommandLength, int LargestCommandLength, std::string minimalSpace=" ") |
CommandLineOption | getHelpOption () |
void | displayFormattedData (std::ostream &OutStm, std::string Title, std::string HelpText, int LargestTextLength) |
void | displayOptions (std::ostream &OutStm, CommandLineOption HelpOption, int LargestTextLength) |
std::string | getArgsDisplay () |
void | displayUsageMessage (std::ostream &OutStm) |
Protected Attributes | |
std::string | m_ProgramName |
std::string | m_HelpText |
std::map< std::string, CommandLineCommand > | m_Commands |
std::vector< CommandLineCommand > | m_CommandsOrdered |
std::string | m_ActiveCommand |
const std::string | m_AvailableCommandsText |
|
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 |
[in] | UseCustomOrder | Enables custom order in the display |
|
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 |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inline |
Returns the extra arguments given to the command
|
inline |
Returns the active command name
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inline |
Returns the help text of the parser
|
inlineprotected |
|
inlineprotected |
|
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)
|
inline |
Returns the third party arguments given to the command, mainly used to pass arguments to a third party program
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |