This class provides a parser for command line arguments in unix style. More...
#include <filmstro_optionsParser.h>
Classes | |
class | Option |
Public Types | |
enum | OptionType { OptString = 0, OptFile, OptInteger, OptDouble, OptBoolean } |
Public Member Functions | |
OptionsParser::Option * | addOption (juce::String optId, juce::String optArg, const OptionType, const bool req=false) |
Create an option to be used in the parser. More... | |
juce::String | getHelpText () const |
Returns a help text for all options. More... | |
bool | parseArguments (const juce::StringArray &arguments, const bool failOnUnknownOption=true) |
Read arguments and set them into the options. More... | |
juce::String | getErrorMessage () const |
if parseArguments failed, this will contain a helpful text about bad arguments More... | |
bool | isOptionSet (juce::StringRef optId) const |
After parseArguments check if a certain option was set by the user. More... | |
juce::String | getOptString (juce::StringRef optId) const |
Return a text value set by argument. More... | |
juce::File | getOptFile (juce::StringRef optId) const |
Return a file set via option. More... | |
int | getOptInt (juce::StringRef optId) const |
Return an integer value set by argument. More... | |
double | getOptDouble (juce::StringRef optId) const |
Return a float value set by argument. More... | |
bool | getOptBoolean (juce::StringRef optId) const |
Return a boolean value set by a flag. More... | |
Option * | getOption (juce::StringRef optId) |
Returns a pointer to a option instance. More... | |
const Option * | getOption (juce::StringRef optId) const |
Public Attributes | |
juce::String | header |
This will be printed before the help text. More... | |
juce::String | footer |
This will be printed after the help text. More... | |
This class provides a parser for command line arguments in unix style.
You can add options with long arguments prefixed by "--" or short arguments using "-". It will create a help text and error messages automatically. An example would look like that:
OptionsParser::Option * OptionsParser::addOption | ( | juce::String | optId, |
juce::String | optArg, | ||
const OptionType | type, | ||
const bool | req = false |
||
) |
Create an option to be used in the parser.
juce::String OptionsParser::getErrorMessage | ( | ) | const |
if parseArguments failed, this will contain a helpful text about bad arguments
juce::String OptionsParser::getHelpText | ( | ) | const |
Returns a help text for all options.
bool OptionsParser::getOptBoolean | ( | juce::StringRef | optId | ) | const |
Return a boolean value set by a flag.
double OptionsParser::getOptDouble | ( | juce::StringRef | optId | ) | const |
Return a float value set by argument.
juce::File OptionsParser::getOptFile | ( | juce::StringRef | optId | ) | const |
Return a file set via option.
It will also create paths relative to the executable
int OptionsParser::getOptInt | ( | juce::StringRef | optId | ) | const |
Return an integer value set by argument.
OptionsParser::Option * OptionsParser::getOption | ( | juce::StringRef | optId | ) |
Returns a pointer to a option instance.
const OptionsParser::Option * OptionsParser::getOption | ( | juce::StringRef | optId | ) | const |
juce::String OptionsParser::getOptString | ( | juce::StringRef | optId | ) | const |
Return a text value set by argument.
bool OptionsParser::isOptionSet | ( | juce::StringRef | optId | ) | const |
After parseArguments check if a certain option was set by the user.
bool OptionsParser::parseArguments | ( | const juce::StringArray & | arguments, |
const bool | failOnUnknownOption = true |
||
) |
Read arguments and set them into the options.
Returns true, if all requirements are met.
juce::String OptionsParser::footer |
This will be printed after the help text.
juce::String OptionsParser::header |
This will be printed before the help text.