Changeset fe02bf for src/UIElements/CommandLineUI/CommandLineParser.cpp
- Timestamp:
- Oct 23, 2014, 4:26:42 PM (10 years ago)
- Children:
- 7305d5
- Parents:
- 7b38d3
- git-author:
- Frederik Heber <heber@…> (10/17/14 16:50:10)
- git-committer:
- Frederik Heber <heber@…> (10/23/14 16:26:42)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/CommandLineUI/CommandLineParser.cpp
r7b38d3 rfe02bf 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.