Changeset 7912e9 for src/UIElements/CommandLineUI/CommandLineParser.cpp
- Timestamp:
- Feb 2, 2015, 7:20:43 PM (10 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 55feff5
- Parents:
- 27e464
- git-author:
- Frederik Heber <heber@…> (10/17/14 16:50:10)
- git-committer:
- Frederik Heber <heber@…> (02/02/15 19:20:43)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/CommandLineUI/CommandLineParser.cpp
r27e464 r7912e9 147 147 // std::cout << std::endl; 148 148 149 AddOptionToParser(currentOption, (CmdParserLookup["options"])); 149 AddOptionToParser(currentOption, (CmdParserLookup["options"]), 150 (optioniter->first == *iter) ? 151 true : false); 150 152 151 153 AlreadyAddedOptionNames.insert(optioniter->first); … … 174 176 ASSERT(CmdParserLookup.find(CurrentTrait.getMenuName()) != CmdParserLookup.end(), 175 177 "CommandLineParser: boost::program_options::options_description for this Action not present."); 176 AddOptionToParser(dynamic_cast<const OptionTrait * const>(&CurrentTrait),(CmdParserLookup[CurrentTrait.getMenuName()])); 178 AddOptionToParser( 179 dynamic_cast<const OptionTrait * const>(&CurrentTrait), 180 (CmdParserLookup[CurrentTrait.getMenuName()]), 181 false); 177 182 } 178 183 } … … 191 196 * \param *currentOption pointer to Action/Option to add 192 197 * \param *OptionList program_options list to add to 193 */ 194 void CommandLineParser::AddOptionToParser(const OptionTrait * const currentOption, po::options_description* OptionList) 198 * \param _DefaultAsImplicit whether to add a default value as default_value or 199 * as implicit_value (default = option token present or not, implicit = 200 option token present but not necessarily followed by argument) 201 */ 202 void CommandLineParser::AddOptionToParser( 203 const OptionTrait * const currentOption, 204 po::options_description* OptionList, 205 const bool _DefaultAsImplicit) 195 206 { 196 207 // check whether dynamic_cast in Init() suceeded … … 212 223 (currentOption->getKeyAndShortForm().c_str(), 213 224 currentOption->hasDefaultValue() ? 214 po::value < bool >()->default_value(boost::lexical_cast<int>(currentOption->getDefaultValue().c_str())) : 225 (_DefaultAsImplicit ? 226 po::value < bool >()->implicit_value(boost::lexical_cast<int>(currentOption->getDefaultValue().c_str())) : 227 po::value < bool >()->default_value(boost::lexical_cast<int>(currentOption->getDefaultValue().c_str()))) : 215 228 po::value < bool >(), 216 229 currentOption->getDescription().c_str()) … … 239 252 (currentOption->getKeyAndShortForm().c_str(), 240 253 currentOption->hasDefaultValue() ? 241 po::value < int >()->default_value(boost::lexical_cast<int>(currentOption->getDefaultValue().c_str())) : 254 (_DefaultAsImplicit ? 255 po::value < int >()->implicit_value(boost::lexical_cast<int>(currentOption->getDefaultValue().c_str())) : 256 po::value < int >()->default_value(boost::lexical_cast<int>(currentOption->getDefaultValue().c_str()))) : 242 257 po::value < int >(), 243 258 currentOption->getDescription().c_str()) … … 257 272 (currentOption->getKeyAndShortForm().c_str(), 258 273 currentOption->hasDefaultValue() ? 259 po::value < unsigned int >()->default_value(boost::lexical_cast<unsigned int>(currentOption->getDefaultValue().c_str())) : 274 (_DefaultAsImplicit ? 275 po::value < unsigned int >()->implicit_value(boost::lexical_cast<unsigned int>(currentOption->getDefaultValue().c_str())) : 276 po::value < unsigned int >()->default_value(boost::lexical_cast<unsigned int>(currentOption->getDefaultValue().c_str()))) : 260 277 po::value < unsigned int >(), 261 278 currentOption->getDescription().c_str()) … … 275 292 (currentOption->getKeyAndShortForm().c_str(), 276 293 currentOption->hasDefaultValue() ? 277 po::value < double >()->default_value(boost::lexical_cast<double>(currentOption->getDefaultValue().c_str())) : 294 (_DefaultAsImplicit ? 295 po::value < double >()->implicit_value(boost::lexical_cast<double>(currentOption->getDefaultValue().c_str())) : 296 po::value < double >()->default_value(boost::lexical_cast<double>(currentOption->getDefaultValue().c_str()))) : 278 297 po::value < double >(), 279 298 currentOption->getDescription().c_str()) … … 293 312 (currentOption->getKeyAndShortForm().c_str(), 294 313 currentOption->hasDefaultValue() ? 295 po::value < std::string >()->default_value(currentOption->getDefaultValue()) : 314 (_DefaultAsImplicit ? 315 po::value < std::string >()->implicit_value(currentOption->getDefaultValue()) : 316 po::value < std::string >()->default_value(currentOption->getDefaultValue())) : 296 317 po::value < std::string >(), 297 318 currentOption->getDescription().c_str()) … … 347 368 (currentOption->getKeyAndShortForm().c_str(), 348 369 currentOption->hasDefaultValue() ? 349 po::value < int >()->default_value(boost::lexical_cast<int>(currentOption->getDefaultValue().c_str())) : 370 (_DefaultAsImplicit ? 371 po::value < int >()->implicit_value(boost::lexical_cast<int>(currentOption->getDefaultValue().c_str())) : 372 po::value < int >()->default_value(boost::lexical_cast<int>(currentOption->getDefaultValue().c_str()))) : 350 373 po::value < int >(), 351 374 currentOption->getDescription().c_str()) … … 383 406 (currentOption->getKeyAndShortForm().c_str(), 384 407 currentOption->hasDefaultValue() ? 385 po::value < std::string >()->default_value(boost::lexical_cast< std::string >(currentOption->getDefaultValue().c_str())) : 408 (_DefaultAsImplicit ? 409 po::value < std::string >()->implicit_value(boost::lexical_cast< std::string >(currentOption->getDefaultValue().c_str())) : 410 po::value < std::string >()->default_value(boost::lexical_cast< std::string >(currentOption->getDefaultValue().c_str()))) : 386 411 po::value < std::string >(), 387 412 currentOption->getDescription().c_str()) … … 438 463 po::store(po::command_line_parser(argc,argv).options(cmdline_options).run(), vm); 439 464 } catch (std::exception &e) { 440 std::cerr << "Something went wrong with parsing the command-line arguments." << std::endl; 465 std::cerr << "Something went wrong with parsing the command-line arguments: " 466 << e.what() << std::endl; 441 467 World::getInstance().setExitFlag(134); 442 468 #ifdef HAVE_ACTION_THREAD
Note:
See TracChangeset
for help on using the changeset viewer.