Definition at line 99 of file optparse.hxx.
#include </home/stephan/code/root-2/main/src/optparse.hxx>
◆ EFlagOpt
| Enumerator |
|---|
| kFlagAllowMultiple | 1 << 0 | Flag is allowed to appear multiple times (default: it's an error to see the same flag twice).
|
| kFlagPrefixArg | 1 << 1 | Flag argument can appear right after this flag without a space or equal sign in between.
Note that marking any short flag with this disables flag grouping!
|
Definition at line 129 of file optparse.hxx.
◆ EFlagTreatment
| Enumerator |
|---|
| kDefault | Will result to kGrouped if you don't define any short flag longer than 1 character, otherwise kSimple.
|
| kSimple | -abc will always be treated as the single flag "-abc"
|
| kGrouped | -abc will be treated as "-a -b -c".
This is only valid for short flags. With this setting you cannot define short flags that are more than 1 character long nor ones that are marked with kFlagPrefixArg.
|
Definition at line 101 of file optparse.hxx.
◆ EFlagType
◆ RCmdLineOpts()
◆ AddFlag()
| void ROOT::RCmdLineOpts::AddFlag |
( |
std::initializer_list< std::string_view > | aliases, |
|
|
EFlagType | type = EFlagType::kSwitch, |
|
|
std::string_view | help = "", |
|
|
std::uint32_t | flagOpts = 0 ) |
|
inline |
Defines a new flag (either a switch or a flag with argument).
The flag may be referred to as any of the values inside aliases (e.g. { "-h", "--help" }). You must pass at least 1 string inside aliases. All strings inside aliases must start with - or -- and be at least 1 character long (aside the dashes). Flags starting with a single - are considered "short", regardless of their actual length. If all short flags are 1 character long, they may be collapsed into one and parsed as individual flags (meaning a string like "-fgk" will be parsed as "-f -g -k") and the final flag may have a following argument. This does NOT happen if any short flag is longer than 1 character, to avoid ambiguity.
- Parameters
-
| aliases | All the equivalent names of this flag |
| type | What kind of flag is this: with arguments or not |
| help | Help string for the flag |
| flagOpts | Bitmask of EFlagOpt for additional options |
Definition at line 208 of file optparse.hxx.
◆ GetArgs()
| const std::vector< std::string > & ROOT::RCmdLineOpts::GetArgs |
( |
| ) |
const |
|
inline |
Retrieves all positional arguments.
Definition at line 182 of file optparse.hxx.
◆ GetErrors()
| const std::vector< std::string > & ROOT::RCmdLineOpts::GetErrors |
( |
| ) |
const |
|
inline |
◆ GetExpectedFlag()
◆ GetFlags()
| const std::vector< RFlag > & ROOT::RCmdLineOpts::GetFlags |
( |
| ) |
const |
|
inline |
◆ GetFlagValue()
| std::string_view ROOT::RCmdLineOpts::GetFlagValue |
( |
std::string_view | name | ) |
const |
|
inline |
If name refers to a previously-defined non-switch flag, gets its value.
- Exceptions
-
| std::invalid_argument | if the flag was undefined or defined as a switch flag |
Definition at line 321 of file optparse.hxx.
◆ GetFlagValueAs()
template<typename T>
| std::optional< T > ROOT::RCmdLineOpts::GetFlagValueAs |
( |
std::string_view | name | ) |
const |
|
inline |
◆ GetFlagValues()
| std::vector< std::string_view > ROOT::RCmdLineOpts::GetFlagValues |
( |
std::string_view | name | ) |
const |
|
inline |
If name refers to a previously-defined non-switch flag, gets its values.
This will never return more than 1 value unless the flag is allowed to appear multiple times.
- Exceptions
-
| std::invalid_argument | if the flag was undefined or defined as a switch flag |
Definition at line 330 of file optparse.hxx.
◆ GetFlagValuesAs()
template<typename T>
| std::vector< T > ROOT::RCmdLineOpts::GetFlagValuesAs |
( |
std::string_view | name | ) |
const |
|
inline |
◆ GetSwitch()
| int ROOT::RCmdLineOpts::GetSwitch |
( |
std::string_view | name | ) |
const |
|
inline |
If name refers to a previously-defined switch (i.e.
a boolean flag), returns how many times the flag appeared (this will never be more than 1 unless the flag is allowed to appear multiple times).
- Exceptions
-
| std::invalid_argument | if the flag was undefined or defined as a flag with arguments |
Definition at line 300 of file optparse.hxx.
◆ Parse()
| void ROOT::RCmdLineOpts::Parse |
( |
const char ** | args, |
|
|
std::size_t | nArgs ) |
|
inline |
◆ ReportErrors()
| bool ROOT::RCmdLineOpts::ReportErrors |
( |
std::ostream & | stream = std::cerr | ) |
const |
|
inline |
Conveniency method to print any errors to stream.
- Returns
- true if any error was printed
Definition at line 188 of file optparse.hxx.
◆ fArgs
| std::vector<std::string> ROOT::RCmdLineOpts::fArgs |
|
private |
◆ fErrors
| std::vector<std::string> ROOT::RCmdLineOpts::fErrors |
|
private |
◆ fExpectedFlags
◆ fFlags
| std::vector<RFlag> ROOT::RCmdLineOpts::fFlags |
|
private |
◆ fSettings
The documentation for this class was generated from the following file: