10 #if !defined(ALMAARG_H)
23 std::cerr << msg1 << std::string(opt.
name,opt.
namelen) << msg2 << std::endl;
29 if (msg) printError(
"Unknown option '", option,
"'\n");
39 if (msg) printError(
"Option '", option,
"' requires an argument\n");
47 if (option.
arg != 0 && strtol(option.
arg, &endptr, 10)){};
48 if (endptr != option.
arg && *endptr == 0)
51 if (msg) printError(
"Option '", option,
"' requires a long integer argument\n");
59 unsigned long ulval = 0;
61 if (option.
arg != 0 && (ulval=strtoul(option.
arg, &endptr, 10))){};
62 if (endptr != option.
arg && *endptr == 0 && ulval <= UINT_MAX)
65 if (msg) printError(
"Option '", option,
"' requires an unsigned integer argument\n");
73 if (option.
arg != 0 && strtod(option.
arg, &endptr)){};
74 if (endptr != option.
arg && *endptr == 0)
77 if (msg) printError(
"Option '", option,
"' requires a floating point argument\n");
85 if (option.
arg != 0) {
86 std::string argVal(option.
arg);
88 argVal = str_tolower(argVal);
89 if (argVal ==
"true" || argVal ==
"false")
92 if (msg) printError(
"Option '", option,
"' requires a value of 'true' or 'false'\n");
This is the only file required to use The Lean Mean C++ Option Parser.
! The argument is acceptable for the option.
static option::ArgStatus Float(const option::Option &option, bool msg)
an associated value is required and must be a valid floating point (double)
static option::ArgStatus Bool(const option::Option &option, bool msg)
an associated value is required and must be either "true" or "false" ignores case ...
static void printError(const char *msg1, const option::Option &opt, const char *msg2)
const char * arg
Pointer to this Option's argument (if any).
A parsed option from the command line together with its argument if it has one.
Functions for checking the validity of option arguments.
extend the option::Arg struct to provide the necessary argument checking for the alma apps for use wi...
static option::ArgStatus Unknown(const option::Option &option, bool msg)
unknown argument
int namelen
The length of the option name.
static option::ArgStatus uInt(const option::Option &option, bool msg)
an associated value is required and must be an unsigned int
TableExprNode trim(const TableExprNode &node)
static option::ArgStatus Required(const option::Option &option, bool msg)
an associated value is required opt=arg, no constraints on type
ArgStatus
Possible results when checking if an argument is valid for a certain option.
static option::ArgStatus Long(const option::Option &option, bool msg)
an associated value is required and must be an a long integer
! The argument is not acceptable and that's fatal.
const char * name
The name of the option as used on the command line.