Changeset 11071 for code/trunk/src/libraries/core/config/ConfigFile.cc
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/config/ConfigFile.cc
r10624 r11071 35 35 36 36 #include <boost/filesystem.hpp> 37 38 #include <iterator> 39 #include <algorithm> 40 #include <fstream> 37 41 38 42 #include "util/Convert.h" … … 93 97 try 94 98 { 95 boost::filesystem::copy_file(defaultFilepath, filepath); 99 std::ifstream input(defaultFilepath.string().c_str(), std::ifstream::in | std::ifstream::binary); 100 std::ofstream output(filepath.string().c_str(), std::ofstream::out | std::ofstream::binary); 101 copy(std::istreambuf_iterator<char>(input), std::istreambuf_iterator<char>(), std::ostream_iterator<char>(output)); 96 102 orxout(internal_info, context::config) << "Copied " << this->filename_ << " from the default config folder." << endl; 97 103 } … … 108 114 if (file.is_open()) 109 115 { 110 ConfigFileSection* newsection = 0;116 ConfigFileSection* newsection = nullptr; 111 117 112 118 while (file.good() && !file.eof()) … … 135 141 } 136 142 137 if (newsection != 0)143 if (newsection != nullptr) 138 144 { 139 145 if (isComment(line)) … … 228 234 } 229 235 230 for ( std::list<ConfigFileSection*>::const_iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)231 { 232 file << (*it)->getFileEntry() << endl;233 234 for ( std::list<ConfigFileEntry*>::const_iterator it_entries = (*it)->getEntriesBegin(); it_entries != (*it)->getEntriesEnd(); ++it_entries)235 file << (*it_entries)->getFileEntry() << endl;236 for (ConfigFileSection* section : this->sections_) 237 { 238 file << section->getFileEntry() << endl; 239 240 for (ConfigFileEntry* entry : section->getEntries()) 241 file << entry->getFileEntry() << endl; 236 242 237 243 file << endl; … … 270 276 271 277 /** 272 @brief Returns a pointer to the section with given name (or NULLif the section doesn't exist).273 */ 274 ConfigFileSection* ConfigFile::getSection(const std::string& section ) const275 { 276 for ( std::list<ConfigFileSection*>::const_iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)277 if ( (*it)->getName() == section)278 return (*it);279 return NULL;278 @brief Returns a pointer to the section with given name (or nullptr if the section doesn't exist). 279 */ 280 ConfigFileSection* ConfigFile::getSection(const std::string& sectionName) const 281 { 282 for (ConfigFileSection* section : this->sections_) 283 if (section->getName() == sectionName) 284 return section; 285 return nullptr; 280 286 } 281 287 … … 283 289 @brief Returns a pointer to the section with given name. If it doesn't exist, the section is created. 284 290 */ 285 ConfigFileSection* ConfigFile::getOrCreateSection(const std::string& section )286 { 287 for ( std::list<ConfigFileSection*>::iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)288 if ( (*it)->getName() == section)289 return (*it);291 ConfigFileSection* ConfigFile::getOrCreateSection(const std::string& sectionName) 292 { 293 for (ConfigFileSection* section : this->sections_) 294 if (section->getName() == sectionName) 295 return section; 290 296 291 297 this->bUpdated_ = true; 292 298 293 return (*this->sections_.insert(this->sections_.end(), new ConfigFileSection(section )));299 return (*this->sections_.insert(this->sections_.end(), new ConfigFileSection(sectionName))); 294 300 } 295 301 … … 301 307 bool sectionsUpdated = false; 302 308 303 for ( std::list<ConfigFileSection*>::iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)304 { 305 if ( (*it)->bUpdated_)309 for (ConfigFileSection* section : this->sections_) 310 { 311 if (section->bUpdated_) 306 312 { 307 313 sectionsUpdated = true; 308 (*it)->bUpdated_ = false;314 section->bUpdated_ = false; 309 315 } 310 316 }
Note: See TracChangeset
for help on using the changeset viewer.