Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7235 in orxonox.OLD for branches/preferences


Ignore:
Timestamp:
Mar 21, 2006, 3:48:37 PM (19 years ago)
Author:
bensch
Message:

some compile patches

Location:
branches/preferences
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/preferences/configure.ac

    r7223 r7235  
    646646                 src/lib/parser/tinyxml/Makefile
    647647                 src/lib/parser/ini_parser/Makefile
     648                 src/lib/parser/preferences/Makefile
    648649                 src/util/Makefile
    649650                 src/world_entities/Makefile
  • branches/preferences/src/lib/parser/ini_parser/ini_parser.cc

    r7234 r7235  
    401401 * @return true if everything is ok false on error
    402402 */
    403 bool IniParser::editVar(const char* entryName, const char* value, const char* sectionName)
     403bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName)
    404404{
    405405  std::list<IniSection>::iterator section;
    406406
    407   if (sectionName != NULL)
     407  if (!sectionName.empty())
    408408  {
    409409    for (section = this->sections.begin(); section != this->sections.end(); section++)
    410       if (!strcmp((*section).name, sectionName))
     410      if ((*section).name == sectionName)
    411411        break;
    412412  }
     
    417417  {
    418418    IniSection sec;
    419     sec.comment = NULL;
    420     sec.name = new char[strlen(sectionName)+1];
    421     strcpy(sec.name, sectionName);
     419    sec.comment = "";
     420    sec.name = sectionName;
    422421    section = this->sections.insert(this->sections.end(), sec);
    423422  }
     
    425424  if (section == this->sections.end())
    426425  {
    427     PRINTF(2)("section '%s' not found for value '%s'\n", sectionName, entryName);
     426    PRINTF(2)("section '%s' not found for value '%s'\n", sectionName.c_str(), entryName.c_str());
    428427    return false;
    429428  }
     
    433432    std::list<IniEntry>::iterator entry;
    434433    for (entry = section->entries.begin(); entry!=section->entries.end(); entry++)
    435       if (!strcmp( entry->name, entryName ))
     434      if (entry->name == entryName )
    436435        break;
    437436
     
    439438    if ( entry != section->entries.end() )
    440439    {
    441       if ( entry->value != NULL )
    442       {
    443         delete[] entry->value;
    444       }
    445       entry->value = new char[strlen(value)+1];
    446       strcpy(entry->value, value);
     440      entry->value = value;
    447441
    448442      return true;
     
    451445    //not found -> create it
    452446    (*section).entries.push_back(IniEntry());
    453     (*section).entries.back().comment = NULL;
    454     (*section).entries.back().name = new char[strlen(entryName)+1];
    455     strcpy((*section).entries.back().name, entryName);
    456     (*section).entries.back().value = new char[strlen(value)+1];
    457     strcpy((*section).entries.back().value, value);
     447    (*section).entries.back().comment = "";
     448    (*section).entries.back().name = entryName;
     449    (*section).entries.back().value = value;
    458450    PRINTF(5)("Added Entry %s with Value '%s' to Section %s\n",
    459     (*section).entries.back().name,
    460     (*section).entries.back().value,
     451    (*section).entries.back().name.c_str(),
     452    (*section).entries.back().value.c_str(),
    461453    (*section).name);
    462454    this->currentEntry = --(*section).entries.end();
  • branches/preferences/src/lib/parser/ini_parser/ini_parser.h

    r7221 r7235  
    6969    bool addVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "" );
    7070    const std::string& getVar(const std::string& entryName, const std::string& sectionName, const std::string& defaultValue = "") const;
     71    bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "");
    7172    void setEntryComment(const std::string& comment, const std::string& entryName, const std::string& sectionName);
    7273    const std::string& getEntryComment(const std::string& entryName, const std::string& sectionName) const;
Note: See TracChangeset for help on using the changeset viewer.