MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / options

Method options

src/apputils/argparse.cpp:375–423  ·  view source on GitHub ↗

Primary entry point. This function accepts a set of format strings and variable pointers. Each string contains an option name and a scanf-like format string to enumerate the arguments of that option (eg. "-option %d %f %s"). The format string is followed by a list of pointers to the argument variables, just like scanf. All format strings and arguments are parsed to create a list of ArgOption o

Source from the content-addressed store, hash-verified

373// After all ArgOptions are created, the command line is parsed and
374// the sublist option callbacks are invoked.
375int
376ArgParse::options (const char *intro, ...)
377{
378 va_list ap;
379 va_start (ap, intro);
380
381 m_intro = intro;
382 for (const char *cur = va_arg(ap, char *); cur; cur = va_arg(ap, char *)) {
383 if (find_option (cur) &&
384 strcmp(cur, "<SEPARATOR>")) {
385 error ("Option \"%s\" is multiply defined", cur);
386 return -1;
387 }
388
389 // Build a new option and then parse the values
390 ArgOption *option = new ArgOption (cur);
391 if (option->initialize() < 0) {
392 return -1;
393 }
394
395 if (cur[0] == '\0' ||
396 (cur[0] == '%' && cur[1] == '*' && cur[2] == '\0')) {
397 // set default global option
398 m_global = option;
399 }
400
401 // Grab any parameters and store them with this option
402 for (int i = 0; i < option->parameter_count(); i++) {
403 void *p = va_arg (ap, void *);
404 if (p == NULL) {
405 error ("Missing argument parameter for \"%s\"",
406 option->name().c_str());
407 return -1;
408 }
409
410 option->add_parameter (i, p);
411
412 if (option == m_global)
413 option->set_callback ((ArgOption::callback_t)p);
414 }
415
416 // Last argument is description
417 option->description ((const char *) va_arg (ap, const char *));
418 m_option.push_back(option);
419 }
420
421 va_end (ap);
422 return 0;
423}
424
425
426

Callers 13

mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
UnitTestMainFunction · 0.80

Calls 6

parameter_countMethod · 0.80
add_parameterMethod · 0.80
set_callbackMethod · 0.80
descriptionMethod · 0.80
initializeMethod · 0.45
push_backMethod · 0.45

Tested by 3

mainFunction · 0.64
UnitTestMainFunction · 0.64
mainFunction · 0.64