- Timestamp:
- Jan 1, 2010, 10:05:56 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gamestate/src/libraries/core/ConfigFileManager.h
r6432 r6437 39 39 40 40 #include "util/Singleton.h" 41 #include "util/StringUtils.h" 41 42 42 43 namespace orxonox // tolua_export … … 191 192 inline void setValue(const std::string& name, const std::string& value, bool bString) 192 193 { this->getOrCreateEntry(name, value, bString)->setValue(value); } 193 inline const std::string& getValue(const std::string& name, const std::string& fallback, bool bString) const194 inline const std::string& getValue(const std::string& name, bool bString) 194 195 { 195 196 ConfigFileEntry* entry = this->getEntry(name); 196 return (entry ? entry->getValue() : BLANKSTRING); 197 if (entry) 198 { 199 entry->setString(bString); 200 return entry->getValue(); 201 } 202 return BLANKSTRING; 197 203 } 198 204 inline const std::string& getOrCreateValue(const std::string& name, const std::string& fallback, bool bString) … … 201 207 inline void setValue(const std::string& name, unsigned int index, const std::string& value, bool bString) 202 208 { this->getOrCreateEntry(name, index, value, bString)->setValue(value); } 203 inline const std::string& getValue(const std::string& name, unsigned int index ) const209 inline const std::string& getValue(const std::string& name, unsigned int index, bool bString) 204 210 { 205 211 ConfigFileEntry* entry = this->getEntry(name, index); 206 return (entry ? entry->getValue() : BLANKSTRING); 212 if (entry) 213 { 214 entry->setString(bString); 215 return entry->getValue(); 216 } 217 return BLANKSTRING; 207 218 } 208 219 inline const std::string& getOrCreateValue(const std::string& name, unsigned int index, const std::string& fallback, bool bString) … … 222 233 { return this->entries_.end(); } 223 234 224 std::list<ConfigFileEntry*>::const_iterator getEntryIterator(const std::string& name) const; 225 std::list<ConfigFileEntry*>::iterator getOrCreateEntryIterator(const std::string& name, const std::string& fallback, bool bString); 226 std::list<ConfigFileEntry*>::const_iterator getEntryIterator(const std::string& name, unsigned int index) const; 227 std::list<ConfigFileEntry*>::iterator getOrCreateEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString); 228 229 inline ConfigFileEntry* getEntry(const std::string& name) const 230 { return (*this->getEntryIterator(name)); } 235 std::list<ConfigFileEntry*>::iterator getOrCreateEntryIterator(const std::string& name, const std::string& fallback, bool bString); 236 std::list<ConfigFileEntry*>::iterator getOrCreateEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString); 237 238 ConfigFileEntry* getEntry(const std::string& name) const; 231 239 inline ConfigFileEntry* getOrCreateEntry(const std::string& name, const std::string& fallback, bool bString) 232 240 { return (*this->getOrCreateEntryIterator(name, fallback, bString)); } 233 inline ConfigFileEntry* getEntry(const std::string& name, unsigned int index) const 234 { return (*this->getEntryIterator(name, index)); } 241 ConfigFileEntry* getEntry(const std::string& name, unsigned int index) const; 235 242 inline ConfigFileEntry* getOrCreateEntry(const std::string& name, unsigned int index, const std::string& fallback, bool bString) 236 243 { return (*this->getOrCreateEntryIterator(name, index, fallback, bString)); } … … 249 256 { 250 257 public: 251 ConfigFile(const std::string& filename );258 ConfigFile(const std::string& filename, bool bCopyFallbackFile = true); 252 259 virtual ~ConfigFile(); 253 260 … … 265 272 this->save(); 266 273 } 267 inline const std::string& getValue(const std::string& section, const std::string& name, bool bString) const274 inline const std::string& getValue(const std::string& section, const std::string& name, bool bString) 268 275 { 269 276 ConfigFileSection* sectionPtr = this->getSection(section); … … 274 281 inline void setValue(const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString) 275 282 { 276 this->get Section(section)->setValue(name, index, value, bString);283 this->getOrCreateSection(section)->setValue(name, index, value, bString); 277 284 this->save(); 278 285 } 279 inline const std::string& getValue(const std::string& section, const std::string& name, unsigned int index ) const286 inline const std::string& getValue(const std::string& section, const std::string& name, unsigned int index, bool bString) 280 287 { 281 288 ConfigFileSection* sectionPtr = this->getSection(section); 282 return (sectionPtr ? sectionPtr->getValue(name, index ) : BLANKSTRING);289 return (sectionPtr ? sectionPtr->getValue(name, index, bString) : BLANKSTRING); 283 290 } 284 291 const std::string& getOrCreateValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString); … … 290 297 return (sectionPtr ? sectionPtr->getVectorSize(name) : 0); 291 298 } 299 300 static const char* DEFAULT_CONFIG_FOLDER; 292 301 293 302 protected: … … 300 309 void saveIfUpdated(); 301 310 const std::string filename_; 311 const bool bCopyFallbackFile_; 302 312 bool bUpdated_; 303 313 };
Note: See TracChangeset
for help on using the changeset viewer.