MCPcopy Create free account
hub / github.com/davisking/dlib / parse

Method parse

dlib/cmd_line_parser/cmd_line_parser_kernel_1.h:411–650  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409 typename sequence2
410 >
411 void cmd_line_parser_kernel_1<charT,map,sequence,sequence2>::
412 parse (
413 int argc_,
414 const charT** argv
415 )
416 {
417 // make sure there aren't any arguments hanging around from the last time
418 // parse was called
419 this->argv.clear();
420
421 // make sure that the options have been cleared of any arguments since
422 // the last time parse() was called
423 if (have_parsed_line)
424 {
425 options.reset();
426 while (options.move_next())
427 {
428 static_cast<option_t*>(options.element().value())->clear();
429 }
430 options.reset();
431 }
432
433 // this tells us if we have seen -- on the command line all by itself
434 // or not.
435 bool escape = false;
436
437 const unsigned long argc = static_cast<unsigned long>(argc_);
438 try
439 {
440
441 for (unsigned long i = 1; i < argc; ++i)
442 {
443 if (argv[i][0] == _dT(charT,'-') && !escape)
444 {
445 // we are looking at the start of an option
446
447 // --------------------------------------------------------------------
448 if (argv[i][1] == _dT(charT,'-'))
449 {
450 // we are looking at the start of a "long named" option
451 string_type temp = &argv[i][2];
452 string_type first_argument;
453 typename string_type::size_type pos = temp.find_first_of(_dT(charT,'='));
454 // This variable will be 1 if there is an argument supplied via the = sign
455 // and 0 otherwise.
456 unsigned long extra_argument = 0;
457 if (pos != string_type::npos)
458 {
459 // there should be an extra argument
460 extra_argument = 1;
461 first_argument = temp.substr(pos+1);
462 temp = temp.substr(0,pos);
463 }
464
465 // make sure this name is defined
466 if (!options.is_in_domain(temp))
467 {
468 // the long name is not a valid option

Callers

nothing calls this directly

Calls 9

number_of_argumentsMethod · 0.80
clearMethod · 0.45
resetMethod · 0.45
move_nextMethod · 0.45
valueMethod · 0.45
sizeMethod · 0.45
addMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected