Changeset 2101 for code/branches/objecthierarchy/src/core/CommandLine.cc
- Timestamp:
- Nov 2, 2008, 12:09:55 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/core/CommandLine.cc
r2003 r2101 30 30 31 31 #include "util/String.h" 32 #include "util/SubString.h" 32 33 33 34 namespace orxonox 34 35 { 36 SetCommandLineArgument(optionsFile, "start.ini").shortcut("o"); 37 35 38 /** 36 39 @brief … … 274 277 } 275 278 } 279 280 /** 281 @brief 282 Parses both command line and start.ini for CommandLineArguments. 283 */ 284 void CommandLine::_parseAll(int argc, char** argv) 285 { 286 // parse command line first 287 std::vector<std::string> args; 288 for (int i = 1; i < argc; ++i) 289 args.push_back(argv[i]); 290 this->_parse(args); 291 292 // look for additional arguments in given file or start.ini as default 293 // They will not overwrite the arguments given directly 294 std::ifstream file; 295 std::string filename = CommandLine::getValue("optionsFile").getString(); 296 file.open(filename.c_str()); 297 args.clear(); 298 if (file) 299 { 300 while (!file.eof()) 301 { 302 std::string line; 303 std::getline(file, line); 304 line = removeTrailingWhitespaces(line); 305 //if (!(line[0] == '#' || line[0] == '%')) 306 //{ 307 SubString tokens(line, " ", " ", false, 92, false, 34, false, 40, 41, false, '#'); 308 for (unsigned i = 0; i < tokens.size(); ++i) 309 if (tokens[i][0] != '#') 310 args.push_back(tokens[i]); 311 //args.insert(args.end(), tokens.getAllStrings().begin(), tokens.getAllStrings().end()); 312 //} 313 } 314 file.close(); 315 } 316 else 317 { 318 COUT(2) << "Warning: Could not find " << filename 319 << " to get additional command line arguments." << std::endl; 320 } 321 322 try 323 { 324 _parse(args); 325 } 326 catch (orxonox::ArgumentException& ex) 327 { 328 COUT(1) << "An Exception occured while parsing " << filename << std::endl; 329 throw(ex); 330 } 331 } 276 332 }
Note: See TracChangeset
for help on using the changeset viewer.