in src/options.cc [165:202]
bool Options::parse_args(int argc, char ** argv) {
static bool donecopy = false;
// enough space for a zero on the end
static std::vector<argp_option> argparse_options(opt_map.size()+1);
// copy options to array
if (!donecopy) {
unsigned i = 0;
for (auto it = opt_map.begin(); it != opt_map.end(); ++it, ++i) {
memcpy(&argparse_options[i], &(it->second.opt), sizeof(argp_option));
}
// zero last element
memset(&argparse_options[argparse_options.size()-1], 0, sizeof(argp_option));
}
donecopy = true;
static const struct argp the_argp = {
options:&argparse_options[0],
parser:arg_parser,
args_doc:non_opt_doc,
doc:docstring,
children:NULL,
help_filter:NULL,
argp_domain:NULL
};
if (argc <= 1) {
fprintf(stderr, "No target files specified!\n");
argp_help((const struct argp *)&the_argp, stderr, ARGP_HELP_SHORT_USAGE | ARGP_HELP_SEE, argv[0]);
return false;
}
if(argp_parse((const struct argp *)&the_argp, argc, argv, 0, NULL, (void *)this)) {
return false;
}
return true;
}