carb::options::getArgString

Defined in carb/extras/Options.h

inline int carb::options::getArgString(int argc, char **argv, int argIndex, const char **value)

Retrieves a single argument value from the next argument.

Remark

This parses a single option’s value from the argument list. The value may either be in the same argument as the option name itself, separated by an equal sign (‘=’), or in the following argument in the list. If an argument cannot be found (ie: no arguments remain and an equal sign is not found), this will fail.

Note

If the argument’s value is quoted (single or double quotes), the entry in the original argument string will be modified to strip off the terminating quotation mark character. If the argument’s value is not quoted, nothing will be modified in the argument string.

Parameters
  • argc[in] The number of arguments in the argument vector. This must be at least 1.

  • argv[in] The full argument vector to parse. This may not be nullptr.

  • argIndex[in] The zero-based index of the argument to parse.

  • value[out] Receives the start of the value’s string.

Returns

The number of arguments that were consumed. This may be 0 or 1.

Returns

-1 if no value could be found for the option.