Changeset 7284 for code/trunk/src/libraries/core/ConfigFileManager.cc
- Timestamp:
- Aug 31, 2010, 3:37:40 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/ConfigFileManager.cc
r7163 r7284 34 34 #include "util/Math.h" 35 35 #include "util/StringUtils.h" 36 #include "ConsoleCommand.h"37 36 #include "ConfigValueContainer.h" 38 37 #include "PathConfig.h" 38 #include "command/ConsoleCommand.h" 39 39 40 40 namespace orxonox … … 277 277 if (commentposition == std::string::npos) 278 278 { 279 value = removeTrailingWhitespaces(line.substr(pos1 + 1));279 value = line.substr(pos1 + 1); 280 280 } 281 281 else 282 282 { 283 value = removeTrailingWhitespaces(line.substr(pos1 + 1, commentposition - pos1 - 1));283 value = line.substr(pos1 + 1, commentposition - pos1 - 1); 284 284 comment = removeTrailingWhitespaces(line.substr(commentposition)); 285 285 } 286 287 value = removeTrailingWhitespaces(value); 288 value = removeSlashes(value); 286 289 287 290 if (pos2 != std::string::npos && pos3 != std::string::npos && pos3 > pos2 + 1) … … 425 428 //////////////////////// 426 429 430 static const std::string __CC_load_name = "reloadSettings"; 431 static const std::string __CC_setFilename_name = "setSettingsFile"; 432 static const std::string __CC_config_name = "config"; 433 static const std::string __CC_tconfig_name = "tconfig"; 434 static const std::string __CC_getConfig_name = "getConfig"; 435 436 SetConsoleCommand(__CC_load_name, &ConfigFile::load); 437 SetConsoleCommand(__CC_setFilename_name, &SettingsConfigFile::setFilename); 438 SetConsoleCommand(__CC_config_name, &SettingsConfigFile::config).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue()); 439 SetConsoleCommand(__CC_tconfig_name, &SettingsConfigFile::tconfig).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue()); 440 SetConsoleCommand(__CC_getConfig_name, &SettingsConfigFile::getConfig).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()); 441 427 442 SettingsConfigFile* SettingsConfigFile::singletonPtr_s = 0; 428 443 … … 430 445 : ConfigFile(filename) 431 446 { 432 ConsoleCommand* command = createConsoleCommand(createFunctor(&ConfigFile::load, this), "reloadSettings"); 433 CommandExecutor::addConsoleCommandShortcut(command); 434 command = createConsoleCommand(createFunctor(&SettingsConfigFile::setFilename, this), "setSettingsFile"); 435 CommandExecutor::addConsoleCommandShortcut(command); 436 command = createConsoleCommand(createFunctor(&SettingsConfigFile::config, this), "config"); 437 CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue()); 438 command = createConsoleCommand(createFunctor(&SettingsConfigFile::tconfig, this), "tconfig"); 439 CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue()); 440 command = createConsoleCommand(createFunctor(&SettingsConfigFile::getConfig, this), "getConfig"); 441 CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()); 447 ModifyConsoleCommand(__CC_load_name).setObject(this); 448 ModifyConsoleCommand(__CC_setFilename_name).setObject(this); 449 ModifyConsoleCommand(__CC_config_name).setObject(this); 450 ModifyConsoleCommand(__CC_tconfig_name).setObject(this); 451 ModifyConsoleCommand(__CC_getConfig_name).setObject(this); 442 452 } 443 453 444 454 SettingsConfigFile::~SettingsConfigFile() 445 455 { 456 ModifyConsoleCommand(__CC_load_name).setObject(0); 457 ModifyConsoleCommand(__CC_setFilename_name).setObject(0); 458 ModifyConsoleCommand(__CC_config_name).setObject(0); 459 ModifyConsoleCommand(__CC_tconfig_name).setObject(0); 460 ModifyConsoleCommand(__CC_getConfig_name).setObject(0); 446 461 } 447 462 … … 543 558 } 544 559 545 bool SettingsConfigFile::config(const std::string& section, const std::string& entry, const std::string& value) 546 { 547 return this->configImpl(section, entry, value, &ConfigValueContainer::set); 548 } 549 550 bool SettingsConfigFile::tconfig(const std::string& section, const std::string& entry, const std::string& value) 551 { 552 return this->configImpl(section, entry, value, &ConfigValueContainer::tset); 560 void SettingsConfigFile::config(const std::string& section, const std::string& entry, const std::string& value) 561 { 562 if (!this->configImpl(section, entry, value, &ConfigValueContainer::set)) 563 COUT(1) << "Error: Config value \"" << entry << "\" in section \"" << section << "\" doesn't exist." << std::endl; 564 } 565 566 void SettingsConfigFile::tconfig(const std::string& section, const std::string& entry, const std::string& value) 567 { 568 if (!this->configImpl(section, entry, value, &ConfigValueContainer::tset)) 569 COUT(1) << "Error: Config value \"" << entry << "\" in section \"" << section << "\" doesn't exist." << std::endl; 553 570 } 554 571
Note: See TracChangeset
for help on using the changeset viewer.