Changeset 78ea3c for src/UIElements
- Timestamp:
- Jun 21, 2017, 10:02:50 PM (8 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChangeBugEmailaddress, ChemicalSpaceEvaluator, EmpiricalPotential_contain_HomologyGraph_documentation, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, Fix_Verbose_Codepatterns, ForceAnnealing_oldresults, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, IndependentFragmentGrids_IntegrationTest, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, StoppableMakroAction, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps
- Children:
- 310445
- Parents:
- be848d (diff), 101d2d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/CommandLineUI/CommandLineParser.cpp
rbe848d r78ea3c 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> … … 463 466 } 464 467 468 /** This is due to the answer by Aleksey Vitebskiy 469 * in http://stackoverflow.com/questions/4107087/accepting-negative-doubles-with-boostprogram-options 470 * 471 */ 472 std::vector<po::option> ignore_numbers(std::vector<std::string>& args) 473 { 474 std::vector<po::option> result; 475 int pos = 0; 476 while(!args.empty()) { 477 const std::string& arg = args[0]; 478 bool isNumber = true; 479 try { 480 boost::lexical_cast<double>(arg); 481 } catch(boost::bad_lexical_cast) { 482 isNumber = false; 483 } 484 if (isNumber) { 485 result.push_back(po::option()); 486 po::option& opt = result.back(); 487 488 opt.position_key = pos++; 489 opt.value.push_back(arg); 490 opt.original_tokens.push_back(arg); 491 492 args.erase(args.begin()); 493 } else { 494 break; 495 } 496 } 497 498 return result; 499 } 500 465 501 /** Parses the command line arguments. 466 502 * Calls program_options::store() and program_options::notify() … … 473 509 bool status = true; 474 510 try { 475 po::store(po::command_line_parser(argc,argv). options(cmdline_options).run(), vm);511 po::store(po::command_line_parser(argc,argv).extra_style_parser(&ignore_numbers).options(cmdline_options).run(), vm); 476 512 } catch (std::exception &e) { 477 513 std::cerr << "Something went wrong with parsing the command-line arguments: "
Note:
See TracChangeset
for help on using the changeset viewer.