13#include "../safeguards.h"
24 std::string_view s = this->
cont;
29 if (s[0] !=
'-')
return -1;
34 for (
auto &option : this->
options) {
35 if (option.longname == s) {
37 return this->
GetOpt(option);
45 for (
auto &option : this->
options) {
46 if (option.shortname !=
'\0' && s[0] == option.shortname) {
47 this->
cont = s.substr(1);
48 return this->
GetOpt(option);
58 switch (option.
type) {
64 if (!this->
cont.empty()) {
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.
std::string_view cont
Next call to GetOpt should start here (in the middle of an argument).
std::string_view opt
Option value, if available (else empty).
ArgumentSpan arguments
Remaining command line arguments.
int GetOpt()
Find the next option.
const OptionSpan options
Command line option descriptions.
OptionDataType type
The type of option.
char id
Unique identification of this option data, often the same as shortname.