Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5951 in orxonox.OLD for trunk/src/lib/parser


Ignore:
Timestamp:
Dec 7, 2005, 1:18:38 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: cool functions

Location:
trunk/src/lib/parser/ini_parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/parser/ini_parser/ini_parser.cc

    r5949 r5951  
    544544
    545545/**
    546  *
     546 * Finds the Section Iterator of the Section Called sectionName
     547 * @param sectionName the Name of the Section to get the Iterator from
    547548 */
    548549std::list<IniParser::IniSection>::const_iterator IniParser::getSectionIT(const char* sectionName) const
    549550{
    550   std::list<IniSection>::const_iterator section;
     551  std::list<IniSection>::const_iterator section = this->currentSection;
    551552  if (sectionName != NULL)
    552   {
    553553    for (section = this->sections.begin(); section != this->sections.end(); section++)
    554     {
    555554      if (!strcmp((*section).name, sectionName))
    556       {
    557555        break;
    558       }
    559     }
    560   }
    561   else
    562     section = this->currentSection;
    563 
    564556  return section;
    565557}
    566558
    567 /**
    568  *
     559
     560/**
     561 * Finds the Section Iterator of the Section Called sectionName
     562 * @param sectionName the Name of the Section to get the Iterator from
     563 */
     564std::list<IniParser::IniSection>::iterator IniParser::getSectionIT(const char* sectionName)
     565{
     566  std::list<IniSection>::iterator section = this->currentSection;
     567  if (sectionName != NULL)
     568    for (section = this->sections.begin(); section != this->sections.end(); section++)
     569      if (!strcmp((*section).name, sectionName))
     570        break;
     571  return section;
     572}
     573
     574
     575/**
     576 * Finds the Entry Iterator of the Section Called sectionName and entry called EntryName
     577 * @param entryName the Name of the Entry to get the Iterator from
     578 * @param sectionName the Name of the Section to get the Iterator from
    569579 */
    570580std::list<IniParser::IniEntry>::const_iterator IniParser::getEntryIT(const char* entryName, const char* sectionName) const
     
    572582  if (entryName == NULL)
    573583    return this->currentEntry;
    574 
    575 }
    576 
     584  std::list<IniSection>::const_iterator section = this->getSectionIT(sectionName);
     585  std::list<IniEntry>::const_iterator entry = this->currentEntry;
     586
     587  if (section != this->sections.end())
     588    for (entry = (*section).entries.begin(); entry != (*section).entries.end(); entry++)
     589      if (!strcmp((*entry).name, entryName))
     590        break;
     591  return entry;
     592}
     593
     594
     595/**
     596 * Finds the Entry Iterator of the Section Called sectionName and entry called EntryName
     597 * @param entryName the Name of the Entry to get the Iterator from
     598 * @param sectionName the Name of the Section to get the Iterator from
     599 */
     600std::list<IniParser::IniEntry>::iterator IniParser::getEntryIT(const char* entryName, const char* sectionName)
     601{
     602  if (entryName == NULL)
     603    return this->currentEntry;
     604  std::list<IniSection>::iterator section = this->getSectionIT(sectionName);
     605  std::list<IniEntry>::iterator entry = this->currentEntry;
     606
     607  if (section != this->sections.end())
     608    for (entry = (*section).entries.begin(); entry != (*section).entries.end(); entry++)
     609      if (!strcmp((*entry).name, entryName))
     610        break;
     611  return entry;
     612}
    577613
    578614
  • trunk/src/lib/parser/ini_parser/ini_parser.h

    r5946 r5951  
    9595
    9696    std::list<IniSection>::const_iterator getSectionIT(const char* sectionName) const;
     97    std::list<IniSection>::iterator getSectionIT(const char* sectionName);
     98
    9799    std::list<IniEntry>::const_iterator getEntryIT(const char* entryName, const char* sectionName = NULL) const;
     100    std::list<IniEntry>::iterator getEntryIT(const char* entryName, const char* sectionName = NULL);
    98101
    99102  private:
Note: See TracChangeset for help on using the changeset viewer.