Parser of the command line that main() receives.
More...
#include <optionprocessor.h>
|
| | OptionProcessor ()=default |
| | Construct a processor without options.
|
| | ~OptionProcessor () |
| | Delete every option.
|
| void | AddBool (const char *pszName, int *pnTarget, int nValue) |
| | Add an option that stores a value when it is present.
|
| void | AddString (const char *pszName, String *pTarget) |
| | Add an option that reads the argument after it into a string.
|
| void | Process (int argc, char **argv) |
| | Apply the options of a command line.
|
| const std::list< std::unique_ptr< Option > > & | GetOptions () const |
| int | GetIndex () const |
| | ~OptionProcessor () |
| | Delete every option.
|
| void | AddBoolOption (const char *name, bool *value, bool setValue) |
| | Add an option that stores a fixed value in a flag.
|
| void | AddStringOption (const char *name, String *value) |
| | Add an option that stores the argument after it.
|
| void | Process (int argc, char **argv) |
| | Apply the options to the arguments that start with a dash, stopping at the first that does not.
|
|
| static char ** | ParseCommandLine (const char *commandLine, int *argc) |
| | Split a command line into arguments at spaces outside double quotes.
|
Parser of the command line that main() receives.
Set of command-line options applied to an argument vector.
The class is not polymorphic. The name comes from its messages.
The object is 0x10 bytes. The name comes from the message Process() prints for an unknown option.
◆ OptionProcessor()
| OptionProcessor::OptionProcessor |
( |
| ) |
|
|
default |
Construct a processor without options.
◆ ~OptionProcessor() [1/2]
| OptionProcessor::~OptionProcessor |
( |
| ) |
|
Delete every option.
- Ghidra address:
- NTSC-U/C: 0x0029d870
- Ghidra address:
- PAL: 0x002a7538
◆ ~OptionProcessor() [2/2]
| OptionProcessor::~OptionProcessor |
( |
| ) |
|
Delete every option.
- Ghidra address:
- 0x100131d0
◆ AddBool()
| void OptionProcessor::AddBool |
( |
const char * | pszName, |
|
|
int * | pnTarget, |
|
|
int | nValue ) |
Add an option that stores a value when it is present.
- Parameters
-
| pszName | The option's name, without the leading -. |
| pnTarget | Receives nValue when the option is present. |
| nValue | The value. |
- Ghidra address:
- NTSC-U/C: 0x0029d520
- Ghidra address:
- PAL: 0x002a71e8
◆ AddString()
| void OptionProcessor::AddString |
( |
const char * | pszName, |
|
|
String * | pTarget ) |
Add an option that reads the argument after it into a string.
- Parameters
-
| pszName | The option's name, without the leading -. |
| pTarget | Receives the argument. |
- Ghidra address:
- NTSC-U/C: 0x0029d5f0
- Ghidra address:
- PAL: 0x002a72b8
◆ Process() [1/2]
| void OptionProcessor::Process |
( |
int | argc, |
|
|
char ** | argv ) |
Apply the options of a command line.
Adds an -options option. When it is present, every option prints its usage line and the program exits.
- Parameters
-
| argc | The argument count. |
| argv | The arguments. |
- Ghidra address:
- NTSC-U/C: 0x0029d6b0
- Ghidra address:
- PAL: 0x002a7378
◆ GetOptions()
| const std::list< std::unique_ptr< Option > > & OptionProcessor::GetOptions |
( |
| ) |
const |
|
inline |
- Returns
- The options, in the order they were added.
◆ GetIndex()
| int OptionProcessor::GetIndex |
( |
| ) |
const |
|
inline |
- Returns
- The index of the next argument Process() reads.
◆ AddBoolOption()
| void OptionProcessor::AddBoolOption |
( |
const char * | name, |
|
|
bool * | value, |
|
|
bool | setValue ) |
Add an option that stores a fixed value in a flag.
- Parameters
-
| name | The option's name. |
| value | The flag. |
| setValue | The value stored when the option appears. |
- Ghidra address:
- 0x10012eb0
◆ AddStringOption()
| void OptionProcessor::AddStringOption |
( |
const char * | name, |
|
|
String * | value ) |
Add an option that stores the argument after it.
- Parameters
-
| name | The option's name. |
| value | The string. |
- Ghidra address:
- 0x10012f50
◆ Process() [2/2]
| void OptionProcessor::Process |
( |
int | argc, |
|
|
char ** | argv ) |
Apply the options to the arguments that start with a dash, stopping at the first that does not.
An unknown option prints a message and is skipped. The --options argument prints every option's usage and exits.
- Parameters
-
| argc | The number of arguments, the program name included. |
| argv | The arguments. |
- Ghidra address:
- 0x10012fe0
◆ ParseCommandLine()
| char ** OptionProcessor::ParseCommandLine |
( |
const char * | commandLine, |
|
|
int * | argc ) |
|
static |
Split a command line into arguments at spaces outside double quotes.
The vector and the copy of the command line share one allocation. Twenty arguments at most are kept.
- Parameters
-
| commandLine | The command line. |
| argc | Receives the number of arguments. |
- Returns
- The arguments.
- Ghidra address:
- 0x100130d0
The documentation for this class was generated from the following files: