Changeset 7629 in orxonox.OLD for branches/qt_gui/src/lib
- Timestamp:
- May 16, 2006, 11:36:56 PM (19 years ago)
- Location:
- branches/qt_gui/src/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/qt_gui/src/lib/parser/ini_parser/ini_parser.cc
r7626 r7629 401 401 * @return true if everything is ok false on error 402 402 */ 403 bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName )403 bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName, bool createMissing) 404 404 { 405 405 std::list<IniSection>::iterator section; … … 416 416 if (section == this->sections.end()) 417 417 { 418 IniSection sec; 419 sec.comment = ""; 420 sec.name = sectionName; 421 section = this->sections.insert(this->sections.end(), sec); 422 } 423 424 if (section == this->sections.end()) 425 { 426 PRINTF(2)("section '%s' not found for value '%s'\n", sectionName.c_str(), entryName.c_str()); 427 return false; 428 } 429 else 430 { 431 //try find item 432 std::list<IniEntry>::iterator entry; 433 for (entry = section->entries.begin(); entry!=section->entries.end(); entry++) 434 if (entry->name == entryName ) 418 this->addSection(sectionName); 419 for (section = this->sections.begin(); section != this->sections.end(); section++) 420 if ((*section).name == sectionName) 435 421 break; 436 437 //found it? 438 if ( entry != section->entries.end() ) 439 { 440 entry->value = value; 441 442 return true; 443 } 444 422 } 423 424 //try find item 425 std::list<IniEntry>::iterator entry; 426 for (entry = section->entries.begin(); entry!=section->entries.end(); entry++) 427 if (entry->name == entryName ) 428 break; 429 430 //found it? 431 if ( entry != section->entries.end() ) 432 { 433 entry->value = value; 434 435 return true; 436 } 437 else 438 { 445 439 //not found -> create it 446 440 (*section).entries.push_back(IniEntry()); … … 448 442 (*section).entries.back().name = entryName; 449 443 (*section).entries.back().value = value; 450 PRINTF(5)("Added Entry %s with Value '%s' to Section %s\n",451 (*section).entries.back().name.c_str(),452 (*section).entries.back().value.c_str(),453 (*section).name);444 PRINTF(5)("Added Entry '%s' with Value '%s' to Section '%s'\n", 445 (*section).entries.back().name.c_str(), 446 (*section).entries.back().value.c_str(), 447 (*section).name); 454 448 this->currentEntry = --(*section).entries.end(); 455 449 return true; 456 450 } 451 return false; 457 452 } 458 453 … … 725 720 void IniParser::debug() const 726 721 { 727 PRINT F(0)("Iniparser %s- debug\n", this->fileName.c_str());722 PRINT(0)("Iniparser '%s' - debug\n", this->fileName.c_str()); 728 723 if (!this->comment.empty()) 729 PRINT F(0)("FileComment:\n %s\n\n", this->comment.c_str());724 PRINT(0)("FileComment:\n '%s'\n\n", this->comment.c_str()); 730 725 731 726 if (!this->fileName.empty()) 732 727 { 728 if (sections.empty()) 729 PRINT(0)("No Sections defined\n"); 733 730 std::list<IniSection>::const_iterator section; 734 731 for (section = this->sections.begin(); section != this->sections.end(); section++) … … 737 734 PRINTF(0)(" %s\n", (*section).comment.c_str()); 738 735 PRINTF(0)(" [%s]\n", (*section).name.c_str()); 736 737 if ((*section).entries.empty()) 738 PRINT(0)("No Entries defined within Section '%s'\n", (*section).name.c_str()); 739 739 740 740 std::list<IniEntry>::const_iterator entry; … … 748 748 } 749 749 else 750 PRINTF( 1)("no opened ini-file.\n");751 } 752 750 PRINTF(0)("no opened ini-file.\n"); 751 } 752 -
branches/qt_gui/src/lib/parser/ini_parser/ini_parser.h
r7626 r7629 66 66 bool addVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "" ); 67 67 const std::string& getVar(const std::string& entryName, const std::string& sectionName, const std::string& defaultValue = "") const; 68 bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "" );68 bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "", bool createMissing = true); 69 69 void setEntryComment(const std::string& comment, const std::string& entryName, const std::string& sectionName); 70 70 const std::string& getEntryComment(const std::string& entryName, const std::string& sectionName) const; -
branches/qt_gui/src/lib/util/preferences.cc
r7627 r7629 17 17 18 18 #include "preferences.h" 19 20 using namespace std; 19 #include "lib/parser/ini_parser/ini_parser.h" 21 20 22 21 … … 281 280 //if ( didChanges ) 282 281 { 282 iniParser.debug(); 283 283 iniParser.writeFile( this->fileName ); 284 284 } -
branches/qt_gui/src/lib/util/preferences.h
r7627 r7629 9 9 #include "base_object.h" 10 10 #include "multi_type.h" 11 #include "lib/parser/ini_parser/ini_parser.h"12 11 13 12 // FORWARD DECLARATION
Note: See TracChangeset
for help on using the changeset viewer.