Changeset a5f2fa for src/UIElements
- Timestamp:
- May 8, 2017, 2:00:09 PM (8 years ago)
- Branches:
- ForceAnnealing_goodresults, ForceAnnealing_tocheck
- Children:
- a2a8de
- Parents:
- 7c7696
- git-author:
- Frederik Heber <heber@…> (03/23/17 17:38:46)
- git-committer:
- Frederik Heber <frederik.heber@…> (05/08/17 14:00:09)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/CommandLineUI/CommandLineParser.cpp
r7c7696 ra5f2fa 36 36 37 37 #include <boost/filesystem.hpp> 38 #include <boost/lexical_cast.hpp> 39 #include <boost/program_options/option.hpp> 40 #include <boost/program_options/value_semantic.hpp> 38 41 #include <boost/program_options.hpp> 39 42 #include <fstream> … … 461 464 } 462 465 466 /** This is due to the answer by Aleksey Vitebskiy 467 * in http://stackoverflow.com/questions/4107087/accepting-negative-doubles-with-boostprogram-options 468 * 469 */ 470 std::vector<po::option> ignore_numbers(std::vector<std::string>& args) 471 { 472 std::vector<po::option> result; 473 int pos = 0; 474 while(!args.empty()) { 475 const std::string& arg = args[0]; 476 bool isNumber = true; 477 try { 478 boost::lexical_cast<double>(arg); 479 } catch(boost::bad_lexical_cast) { 480 isNumber = false; 481 } 482 if (isNumber) { 483 result.push_back(po::option()); 484 po::option& opt = result.back(); 485 486 opt.position_key = pos++; 487 opt.value.push_back(arg); 488 opt.original_tokens.push_back(arg); 489 490 args.erase(args.begin()); 491 } else { 492 break; 493 } 494 } 495 496 return result; 497 } 498 463 499 /** Parses the command line arguments. 464 500 * Calls program_options::store() and program_options::notify() … … 471 507 bool status = true; 472 508 try { 473 po::store(po::command_line_parser(argc,argv). options(cmdline_options).run(), vm);509 po::store(po::command_line_parser(argc,argv).extra_style_parser(&ignore_numbers).options(cmdline_options).run(), vm); 474 510 } catch (std::exception &e) { 475 511 std::cerr << "Something went wrong with parsing the command-line arguments: "
Note:
See TracChangeset
for help on using the changeset viewer.