Changeset 6417 for code/trunk/src/libraries/core/ConfigFileManager.cc
- Timestamp:
- Dec 25, 2009, 10:23:58 PM (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
r5929 r6417 51 51 if (identifier != Identifier::getLowercaseStringIdentifierMapEnd()) 52 52 { 53 std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));54 if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())55 return (*variable).second->set(value);53 std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname)); 54 if (variable != identifier->second->getLowercaseConfigValueMapEnd()) 55 return variable->second->set(value); 56 56 } 57 57 return false; 58 } 59 60 std::string getConfig(const std::string& classname, const std::string& varname) 61 { 62 return ConfigFileManager::getInstance().getValue(ConfigFileType::Settings, classname, varname, "", true); 58 63 } 59 64 … … 63 68 if (identifier != Identifier::getLowercaseStringIdentifierMapEnd()) 64 69 { 65 std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));66 if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())67 return (*variable).second->tset(value);70 std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname)); 71 if (variable != identifier->second->getLowercaseConfigValueMapEnd()) 72 return variable->second->tset(value); 68 73 } 69 74 return false; … … 94 99 this->value_ = value; 95 100 else 96 this->value_ = "\"" + addSlashes(stripEnclosingQuotes(value)) + "\"";101 this->value_ = '"' + addSlashes(stripEnclosingQuotes(value)) + '"'; 97 102 } 98 103 … … 107 112 std::string ConfigFileEntryValue::getFileEntry() const 108 113 { 109 if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)110 return (this->name_ + "="+ this->value_);111 else 112 return (this->name_ + "="+ this->value_ + " " + this->additionalComment_);114 if (this->additionalComment_.empty()) 115 return (this->name_ + '=' + this->value_); 116 else 117 return (this->name_ + '=' + this->value_ + " " + this->additionalComment_); 113 118 } 114 119 … … 119 124 std::string ConfigFileEntryVectorValue::getFileEntry() const 120 125 { 121 if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)122 return (this->name_ + "[" + multi_cast<std::string>(this->index_) + "]" + "="+ this->value_);123 else 124 return (this->name_ + "[" + multi_cast<std::string>(this->index_) + "]=" + this->value_ + " "+ this->additionalComment_);126 if (this->additionalComment_.empty()) 127 return (this->name_ + '[' + multi_cast<std::string>(this->index_) + ']' + '=' + this->value_); 128 else 129 return (this->name_ + '[' + multi_cast<std::string>(this->index_) + "]=" + this->value_ + ' ' + this->additionalComment_); 125 130 } 126 131 … … 166 171 std::string ConfigFileSection::getFileEntry() const 167 172 { 168 if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)169 return ( "[" + this->name_ + "]");170 else 171 return ( "["+ this->name_ + "] " + this->additionalComment_);173 if (this->additionalComment_.empty()) 174 return ('[' + this->name_ + ']'); 175 else 176 return ('[' + this->name_ + "] " + this->additionalComment_); 172 177 } 173 178 … … 246 251 std::getline(file, line); 247 252 248 std::stringtemp = getStripped(line);253 const std::string& temp = getStripped(line); 249 254 if (!isEmpty(temp) && !isComment(temp)) 250 255 { … … 256 261 { 257 262 // New section 258 std::stringcomment = line.substr(pos2 + 1);263 const std::string& comment = line.substr(pos2 + 1); 259 264 if (isComment(comment)) 260 265 newsection = new ConfigFileSection(line.substr(pos1 + 1, pos2 - pos1 - 1), comment); … … 288 293 commentposition = getNextCommentPosition(line, commentposition + 1); 289 294 } 290 std::string value = "", comment = "";295 std::string value, comment; 291 296 if (commentposition == std::string::npos) 292 297 { … … 377 382 { 378 383 std::map<std::string, Identifier*>::const_iterator it2 = Identifier::getStringIdentifierMap().find((*it1)->getName()); 379 if (it2 != Identifier::getStringIdentifierMapEnd() && (*it2).second->hasConfigValues())384 if (it2 != Identifier::getStringIdentifierMapEnd() && it2->second->hasConfigValues()) 380 385 { 381 386 // The section exists, delete comment … … 384 389 for (std::list<ConfigFileEntry*>::iterator it3 = (*it1)->entries_.begin(); it3 != (*it1)->entries_.end(); ) 385 390 { 386 std::map<std::string, ConfigValueContainer*>::const_iterator it4 = (*it2).second->getConfigValueMap().find((*it3)->getName());387 if (it4 != (*it2).second->getConfigValueMapEnd())391 std::map<std::string, ConfigValueContainer*>::const_iterator it4 = it2->second->getConfigValueMap().find((*it3)->getName()); 392 if (it4 != it2->second->getConfigValueMapEnd()) 388 393 { 389 394 // The config-value exists, delete comment … … 459 464 if (it->second->hasConfigValues()) 460 465 { 461 for (std::map<std::string, ConfigValueContainer*>::const_iterator it2 = (*it).second->getConfigValueMapBegin(); it2 != (*it).second->getConfigValueMapEnd(); ++it2)466 for (std::map<std::string, ConfigValueContainer*>::const_iterator it2 = it->second->getConfigValueMapBegin(); it2 != it->second->getConfigValueMapEnd(); ++it2) 462 467 it2->second->update(); 463 468
Note: See TracChangeset
for help on using the changeset viewer.