13#include "../safeguards.h"
24 const char *s = this->
cont;
29 if (*s !=
'-')
return -1;
34 for (
auto &option : this->
options) {
35 if (option.longname !=
nullptr && !strcmp(option.longname, s)) {
37 return this->
GetOpt(option);
45 for (
auto &option : this->
options) {
46 if (option.shortname !=
'\0' && *s == option.shortname) {
47 this->
cont = (s[1] !=
'\0') ? s + 1 :
nullptr;
48 return this->
GetOpt(option);
58 switch (option.
type) {
64 if (this->
cont !=
nullptr) {
79 default: NOT_REACHED();
Library for parsing command-line options.
@ ODF_OPTIONAL_VALUE
An option with an optional value.
@ ODF_NO_VALUE
A plain option (no value attached to it).
@ ODF_HAS_VALUE
An option with a value.
ArgumentSpan arguments
Remaining command line arguments.
int GetOpt()
Find the next option.
const char * cont
Next call to GetOpt should start here (in the middle of an argument).
const OptionSpan options
Command line option descriptions.
const char * opt
Option value, if available (else nullptr).
OptionDataType type
The type of option.
char id
Unique identification of this option data, often the same as shortname.