OpenShot Library | libopenshot-audio 0.2.0
|
Holds a list of command-line arguments, and provides useful methods for searching and operating on them. More...
#include <juce_ConsoleApplication.h>
Classes | |
struct | Argument |
One of the arguments in an ArgumentList. More... | |
Public Member Functions | |
ArgumentList (String executable, StringArray arguments) | |
Creates an argument list for a given executable. | |
ArgumentList (int argc, char *argv[]) | |
Parses a standard argv/argc pair to create an argument list. | |
ArgumentList (const String &executable, const String &arguments) | |
Tokenises a string containing all the arguments to create an argument list. | |
ArgumentList (const ArgumentList &)=default | |
ArgumentList & | operator= (const ArgumentList &)=default |
int | size () const |
Returns the number of arguments in the list. | |
Argument | operator[] (int index) const |
Returns one of the arguments. | |
void | checkMinNumArguments (int expectedMinNumberOfArgs) const |
Throws an error unless there are at least the given number of arguments. | |
bool | containsOption (StringRef option) const |
Returns true if the given string matches one of the arguments. | |
int | indexOfOption (StringRef option) const |
Returns the index of the given string if it matches one of the arguments, or -1 if it doesn't. | |
void | failIfOptionIsMissing (StringRef option) const |
Throws an error unless the given option is found in the argument list. | |
String | getValueForOption (StringRef option) const |
Looks for a given argument and returns either its assigned value (for long options) or the string that follows it (for short options). | |
File | getFileForOption (StringRef option) const |
Looks for the value of argument using getValueForOption() and tries to parse that value as a file. | |
File | getExistingFileForOption (StringRef option) const |
Looks for a file argument using getFileForOption() and fails with a suitable error if the file doesn't exist. | |
File | getExistingFolderForOption (StringRef option) const |
Looks for a filename argument using getFileForOption() and fails with a suitable error if the file isn't a folder that exists. | |
Public Attributes | |
String | executableName |
The name or path of the executable that was invoked, as it was specified on the command-line. | |
Array< Argument > | arguments |
The list of arguments (not including the name of the executable that was invoked). | |
Holds a list of command-line arguments, and provides useful methods for searching and operating on them.
You can create an ArgumentList manually, or give it some argv/argc values from a main() function to parse.
Definition at line 40 of file juce_ConsoleApplication.h.
juce::ArgumentList::ArgumentList | ( | String | executable, |
StringArray | arguments | ||
) |
Creates an argument list for a given executable.
Definition at line 120 of file juce_ConsoleApplication.cpp.
References arguments, juce::StringArray::removeEmptyStrings(), and juce::StringArray::trim().
juce::ArgumentList::ArgumentList | ( | int | argc, |
char * | argv[] | ||
) |
Parses a standard argv/argc pair to create an argument list.
Definition at line 130 of file juce_ConsoleApplication.cpp.
Tokenises a string containing all the arguments to create an argument list.
Definition at line 135 of file juce_ConsoleApplication.cpp.
int juce::ArgumentList::size | ( | ) | const |
Returns the number of arguments in the list.
Definition at line 140 of file juce_ConsoleApplication.cpp.
References arguments.
Referenced by checkMinNumArguments().
ArgumentList::Argument juce::ArgumentList::operator[] | ( | int | index | ) | const |
Returns one of the arguments.
Definition at line 141 of file juce_ConsoleApplication.cpp.
References arguments.
void juce::ArgumentList::checkMinNumArguments | ( | int | expectedMinNumberOfArgs | ) | const |
Throws an error unless there are at least the given number of arguments.
Definition at line 143 of file juce_ConsoleApplication.cpp.
References juce::ConsoleApplication::fail(), and size().
bool juce::ArgumentList::containsOption | ( | StringRef | option | ) | const |
Returns true if the given string matches one of the arguments.
The option can also be a list of different versions separated by pipes, e.g. "--help|-h"
Definition at line 160 of file juce_ConsoleApplication.cpp.
References indexOfOption().
Referenced by failIfOptionIsMissing().
int juce::ArgumentList::indexOfOption | ( | StringRef | option | ) | const |
Returns the index of the given string if it matches one of the arguments, or -1 if it doesn't.
The option can also be a list of different versions separated by pipes, e.g. "--help|-h"
Definition at line 149 of file juce_ConsoleApplication.cpp.
References arguments.
Referenced by containsOption(), and juce::ConsoleApplication::findCommand().
void juce::ArgumentList::failIfOptionIsMissing | ( | StringRef | option | ) | const |
Throws an error unless the given option is found in the argument list.
Definition at line 165 of file juce_ConsoleApplication.cpp.
References containsOption(), and juce::ConsoleApplication::fail().
Referenced by getFileForOption().
Looks for a given argument and returns either its assigned value (for long options) or the string that follows it (for short options).
The option can also be a list of different versions separated by pipes, e.g. "--help|-h" If it finds a long option, it will look for an assignment with a '=' sign, e.g. "--file=foo.txt", and will return the string following the '='. If there's no '=', it will return an empty string. If it finds a short option, it will attempt to return the argument that follows it, unless it's another option. If the argument isn't found, this returns an empty string.
Definition at line 171 of file juce_ConsoleApplication.cpp.
References arguments.
Referenced by getFileForOption().
Looks for the value of argument using getValueForOption() and tries to parse that value as a file.
If the option isn't found, or if the value can't be parsed as a filename, it will throw an error.
Definition at line 197 of file juce_ConsoleApplication.cpp.
References juce::ConsoleApplication::fail(), failIfOptionIsMissing(), and getValueForOption().
Referenced by getExistingFileForOption(), and getExistingFolderForOption().
Looks for a file argument using getFileForOption() and fails with a suitable error if the file doesn't exist.
Definition at line 210 of file juce_ConsoleApplication.cpp.
References getFileForOption().
Looks for a filename argument using getFileForOption() and fails with a suitable error if the file isn't a folder that exists.
Definition at line 217 of file juce_ConsoleApplication.cpp.
References getFileForOption().
String juce::ArgumentList::executableName |
The name or path of the executable that was invoked, as it was specified on the command-line.
Definition at line 167 of file juce_ConsoleApplication.h.
Referenced by juce::ConsoleApplication::printCommandList().
The list of arguments (not including the name of the executable that was invoked).
Definition at line 170 of file juce_ConsoleApplication.h.
Referenced by ArgumentList(), getValueForOption(), indexOfOption(), operator[](), and size().