Changeset 5936 in orxonox.OLD
- Timestamp:
- Dec 6, 2005, 2:12:18 AM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/event/key_mapper.cc
r5915 r5936 132 132 int* index; 133 133 134 iniParser-> getFirstVar();134 iniParser->firstVar(); 135 135 while(iniParser->getCurrentName()) 136 136 { … … 151 151 } 152 152 153 iniParser-> getFirstVar();153 iniParser->firstVar(); 154 154 while(iniParser->getCurrentName()) 155 155 { -
trunk/src/lib/gui/gtk_gui/gui_exec.cc
r5241 r5936 254 254 255 255 /** 256 * Reads in Configuration Data.256 * @brief Reads in Configuration Data. 257 257 * @param widget from which Widget on should be saved. 258 258 */ … … 265 265 return; 266 266 267 iniParser. getFirstSection();267 iniParser.firstSection(); 268 268 Widget* groupWidget = widget; 269 269 const char* groupName; … … 272 272 while (groupName = iniParser.getCurrentSection()) 273 273 { 274 printf("GROUP:::%s\n", groupName); 274 275 if((groupWidget = locateGroup(widget, groupName, 1))==NULL) 275 276 { … … 281 282 PRINT(0)("Group %s located.\n", static_cast<Packer*>(groupWidget)->groupName); 282 283 283 iniParser.getFirstVar(); 284 while(iniParser.getCurrentName()) 285 { 286 varInfo.variableName = iniParser.getCurrentName(); 284 const char* entryName; 285 iniParser.firstVar(); 286 while(entryName = iniParser.getCurrentName()) 287 { 288 printf("ENTRY:::%s = %s\n", entryName, iniParser.getCurrentValue()); 289 varInfo.variableName = entryName; 287 290 varInfo.variableValue = iniParser.getCurrentValue(); 288 291 groupWidget->walkThrough(this->readFileText, &varInfo, 0); -
trunk/src/lib/util/ini_parser.cc
r5935 r5936 63 63 while(!this->sections.empty()) 64 64 { 65 66 IniSection section = this->sections.front(); 65 IniSection section = this->sections.front(); 67 66 68 67 // in all entries of the sections … … 79 78 this->sections.pop_front(); 80 79 } 80 this->currentSection = this->sections.end(); 81 81 this->setFileName(NULL); 82 82 } … … 196 196 * @return true on success false otherwise 197 197 */ 198 bool IniParser::writeFile(const char* fileName) 198 bool IniParser::writeFile(const char* fileName) const 199 199 { 200 200 FILE* stream; //!< The stream we use to read the file. … … 209 209 else 210 210 { 211 std::list<IniSection>:: iterator section;211 std::list<IniSection>::const_iterator section; 212 212 for (section = this->sections.begin(); section != this->sections.end(); section++) 213 213 { 214 214 fprintf(stream, "\n [%s]\n", (*section).name); 215 215 216 std::list<IniEntry>:: iterator entry;216 std::list<IniEntry>::const_iterator entry; 217 217 for (entry = (*section).entries.begin(); entry != (*section).entries.end(); entry++) 218 218 fprintf(stream, " %s = %s\n", (*entry).name, (*entry).value); … … 238 238 this->currentSection = --this->sections.end(); 239 239 if (!this->sections.empty()) 240 this->currentEntry = (*this->currentSection).entries.begin();240 this->currentEntry = (*this->currentSection).entries.begin(); 241 241 PRINTF(5)("Added Section %s\n", sectionName); 242 242 return true; … … 248 248 * @param sectionName: the name of the section to set the cursor to 249 249 * @return true on success or false if the section could not be found 250 */251 bool IniParser::getSection( 250 */ 251 bool IniParser::getSection(const char* sectionName) 252 252 { 253 253 std::list<IniSection>::iterator section; … … 259 259 return true; 260 260 } 261 262 261 return false; 263 262 } … … 267 266 * @brief moves to the first section 268 267 */ 269 void IniParser:: getFirstSection()268 void IniParser::firstSection() 270 269 { 271 270 this->currentSection = this->sections.begin(); … … 283 282 if (this->currentSection == this->sections.end()) 284 283 return NULL; 285 else 286 { 287 this->currentSection++; 288 } 289 if (this->currentSection == this->sections.end()) 290 return NULL; 284 285 this->currentSection++; 291 286 292 287 if (this->currentSection != this->sections.end()) … … 303 298 * @brief moves to the first Variable of the current Section 304 299 */ 305 void IniParser::getFirstVar() 306 { 307 if (this->currentSection != this->sections.end()) 300 void IniParser::firstVar() 301 { 302 if (!this->sections.empty() && 303 this->currentSection != this->sections.end()) 308 304 this->currentEntry = (*this->currentSection).entries.begin(); 309 305 } … … 342 338 { 343 339 std::list<IniSection>::iterator section; 344 340 345 341 if (sectionName != NULL) 346 342 { … … 351 347 else 352 348 section = this->currentSection; 349 if (section == this->sections.end()) 350 return false; 353 351 354 352 if (section == this->sections.end()) … … 364 362 (*section).entries.back().value = new char[strlen(value)+1]; 365 363 strcpy((*section).entries.back().value, value); 366 PRINTF(5)("Added Entry %s with Value '%s' to Section %s\n", entryName, value, (*section).name); 364 PRINTF(5)("Added Entry %s with Value '%s' to Section %s\n", 365 (*section).entries.back().name, 366 (*section).entries.back().value, 367 (*section).name); 367 368 return true; 368 369 } … … 387 388 if (sectionName != NULL) 388 389 { 389 390 390 for (section = this->sections.begin(); section != this->sections.end(); section++) 391 391 { … … 399 399 else 400 400 section = this->currentSection; 401 402 if (section == this->sections.end()) 403 return (defaultValue); 401 404 402 405 std::list<IniEntry>::const_iterator entry; … … 420 423 const char* IniParser::getCurrentSection() const 421 424 { 422 return (this->currentSection!=NULL) ? 423 this->currentSection->name : 424 NULL; 425 if (!this->sections.empty() && 426 this->currentSection != this->sections.end()) 427 return this->currentSection->name; 428 else 429 return NULL; 425 430 } 426 431 … … 432 437 { 433 438 if (!this->sections.empty() && 439 this->currentSection != this->sections.end() && 434 440 this->currentEntry != (*this->currentSection).entries.end()) 435 441 return (*this->currentEntry).name; … … 443 449 const char* IniParser::getCurrentValue() const 444 450 { 445 if (!this->sections.empty() 446 && this->currentEntry != (*this->currentSection).entries.end()) 451 if (!this->sections.empty() && 452 this->currentSection != this->sections.end() && 453 this->currentEntry != (*this->currentSection).entries.end()) 447 454 return (*this->currentEntry).value; 448 455 else -
trunk/src/lib/util/ini_parser.h
r5935 r5936 43 43 44 44 bool readFile(const char* fileName); 45 bool writeFile(const char* fileName) ;45 bool writeFile(const char* fileName) const; 46 46 47 47 bool addSection(const char* sectionName); … … 51 51 bool isOpen() const { return (this->fileName != NULL)? true : false; }; 52 52 53 void getFirstSection();53 void firstSection(); 54 54 const char* nextSection(); 55 55 … … 60 60 const char* getVar(const char* entryName, const char* sectionName, const char* defaultValue = "") const; 61 61 62 void getFirstVar();62 void firstVar(); 63 63 bool nextVar(); 64 64
Note: See TracChangeset
for help on using the changeset viewer.