OpenShot Audio Library | OpenShotAudio: juce::ArgumentList Struct Reference

OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
Classes | Public Member Functions | Public Attributes | List of all members
juce::ArgumentList Struct Reference

`#include <juce_ConsoleApplication.h>`

## Classes
struct | Argument

## Public Member Functions
| ArgumentList (String executable, StringArray arguments)
| ArgumentList (int argc, char *argv[])
| ArgumentList (const String &executable, const String &arguments)
| ArgumentList (const ArgumentList &)=default
ArgumentList & | operator= (const ArgumentList &)=default
int | size () const
Argument | operator[] (int index) const
void | checkMinNumArguments (int expectedMinNumberOfArgs) const
bool | containsOption (StringRef option) const
bool | removeOptionIfFound (StringRef option)
int | indexOfOption (StringRef option) const
void | failIfOptionIsMissing (StringRef option) const
String | getValueForOption (StringRef option) const
String | removeValueForOption (StringRef option)
File | getFileForOption (StringRef option) const
File | getFileForOptionAndRemove (StringRef option)
File | getExistingFileForOption (StringRef option) const
File | getExistingFileForOptionAndRemove (StringRef option)
File | getExistingFolderForOption (StringRef option) const
File | getExistingFolderForOptionAndRemove (StringRef option)

## Public Attributes
String | executableName
Array< Argument > | arguments

## Detailed Description

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.

See also
  ConsoleApplication

Definition at line 38 of file juce_ConsoleApplication.h.

## Constructor & Destructor Documentation

## ◆ ArgumentList() [1/3]

juce::ArgumentList::ArgumentList | ( | String | executable,
|  | StringArray | arguments )

Creates an argument list for a given executable.

Definition at line 137 of file juce_ConsoleApplication.cpp.

## ◆ ArgumentList() [2/3]

juce::ArgumentList::ArgumentList | ( | int | argc,
|  | char * | argv[] )

Parses a standard argv/argc pair to create an argument list.

Definition at line 147 of file juce_ConsoleApplication.cpp.

## ◆ ArgumentList() [3/3]

juce::ArgumentList::ArgumentList | ( | const String & | executable,
|  | const String & | arguments )

Tokenises a string containing all the arguments to create an argument list.

Definition at line 152 of file juce_ConsoleApplication.cpp.

## Member Function Documentation

## ◆ checkMinNumArguments()

void juce::ArgumentList::checkMinNumArguments | ( | int | expectedMinNumberOfArgs | ) | const

Throws an error unless there are at least the given number of arguments.

Definition at line 160 of file juce_ConsoleApplication.cpp.

## ◆ containsOption()

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"

See also
  removeOptionIfFound

Definition at line 177 of file juce_ConsoleApplication.cpp.

## ◆ failIfOptionIsMissing()

void juce::ArgumentList::failIfOptionIsMissing | ( | StringRef | option | ) | const

Throws an error unless the given option is found in the argument list.

Definition at line 192 of file juce_ConsoleApplication.cpp.

## ◆ getExistingFileForOption()

File juce::ArgumentList::getExistingFileForOption | ( | StringRef | option | ) | const

Looks for a file argument using getFileForOption() and fails with a suitable error if the file doesn't exist.

Definition at line 269 of file juce_ConsoleApplication.cpp.

## ◆ getExistingFileForOptionAndRemove()

File juce::ArgumentList::getExistingFileForOptionAndRemove | ( | StringRef | option | ) |

Looks for a file argument using getFileForOption() and fails with a suitable error if the file doesn't exist. This works like getExistingFileForOption() but also removes the option argument (and any value arguments) from the list if they are found.

Definition at line 274 of file juce_ConsoleApplication.cpp.

## ◆ getExistingFolderForOption()

File juce::ArgumentList::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.

Definition at line 279 of file juce_ConsoleApplication.cpp.

## ◆ getExistingFolderForOptionAndRemove()

File juce::ArgumentList::getExistingFolderForOptionAndRemove | ( | StringRef | option | ) |

Looks for a filename argument using getFileForOption() and fails with a suitable error if the file isn't a folder that exists. This works like getExistingFolderForOption() but also removes the option argument (and any value arguments) from the list if they are found.

Definition at line 284 of file juce_ConsoleApplication.cpp.

## ◆ getFileForOption()

File juce::ArgumentList::getFileForOption | ( | StringRef | option | ) | const

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 259 of file juce_ConsoleApplication.cpp.

Referenced by getExistingFileForOption(), and getExistingFolderForOption().

## ◆ getFileForOptionAndRemove()

File juce::ArgumentList::getFileForOptionAndRemove | ( | StringRef | option | ) |

Looks for the value of argument using getValueForOption() and tries to parse that value as a file. This works like getFileForOption() but also removes the option argument (and any value arguments) from the list if they are found.

Definition at line 264 of file juce_ConsoleApplication.cpp.

Referenced by getExistingFileForOptionAndRemove(), and getExistingFolderForOptionAndRemove().

## ◆ getValueForOption()

String juce::ArgumentList::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). 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 198 of file juce_ConsoleApplication.cpp.

Referenced by getFileForOption().

## ◆ indexOfOption()

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 166 of file juce_ConsoleApplication.cpp.

Referenced by containsOption(), failIfOptionIsMissing(), juce::ConsoleApplication::findCommand(), and removeOptionIfFound().

## ◆ operator[]()

ArgumentList::Argument juce::ArgumentList::operator[] | ( | int | index | ) | const

Returns one of the arguments

Definition at line 158 of file juce_ConsoleApplication.cpp.

## ◆ removeOptionIfFound()

bool juce::ArgumentList::removeOptionIfFound | ( | StringRef | option | ) |

Returns true if the given string matches one of the arguments, and also removes the argument from the list if found. The option can also be a list of different versions separated by pipes, e.g. "--help|-h"

See also
  containsOption

Definition at line 182 of file juce_ConsoleApplication.cpp.

## ◆ removeValueForOption()

String juce::ArgumentList::removeValueForOption | ( | StringRef | option | ) |

Looks for a given argument and returns either its assigned value (for long options) or the string that follows it (for short options). This works like getValueForOption() but also removes the option argument (and any value arguments) from the list if they are found.

Definition at line 224 of file juce_ConsoleApplication.cpp.

Referenced by getFileForOptionAndRemove().

## ◆ size()

int juce::ArgumentList::size | ( |  | ) | const

Returns the number of arguments in the list.

Definition at line 157 of file juce_ConsoleApplication.cpp.

Referenced by checkMinNumArguments(), and size().

## Member Data Documentation

## ◆ arguments

Array<Argument> juce::ArgumentList::arguments

The list of arguments (not including the name of the executable that was invoked).

Definition at line 203 of file juce_ConsoleApplication.h.

Referenced by ArgumentList(), getValueForOption(), indexOfOption(), operator[](), removeOptionIfFound(), removeValueForOption(), and size().

## ◆ executableName

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 200 of file juce_ConsoleApplication.h.

The documentation for this struct was generated from the following files:

- juce_ConsoleApplication.h
- juce_ConsoleApplication.cpp