Changeset 13697
- Timestamp:
- 02/05/08 12:12:31 (5 months ago)
- Files:
-
- trunk/gdal/frmts/ilwis/ilwisdataset.cpp (modified) (7 diffs)
- trunk/gdal/frmts/ilwis/ilwisdataset.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gdal/frmts/ilwis/ilwisdataset.cpp
r13693 r13697 70 70 // Construction/Destruction 71 71 ////////////////////////////////////////////////////////////////////// 72 IniFile::IniFile() 73 { 74 72 IniFile::IniFile(const string& filenam) 73 { 74 filename = filenam; 75 Load(); 76 bChanged = false; // Start tracking changes 75 77 } 76 78 77 79 IniFile::~IniFile() 78 80 { 79 80 } 81 82 void IniFile::Open(const string& filenam) 83 { 84 filename = filenam; 85 86 Load(); 87 } 88 89 void IniFile::Close() 90 { 91 Flush(); 81 if (bChanged) 82 { 83 Store(); 84 bChanged = false; 85 } 92 86 93 87 for (Sections::iterator iter = sections.begin(); iter != sections.end(); ++iter) … … 116 110 (*entries)[key] = value; 117 111 } 118 } 112 bChanged = true; 113 } 114 119 115 string IniFile::GetKeyValue(const string& section, const string& key) 120 116 { … … 139 135 SectionEntries *entries = (*iterSect).second; 140 136 (*entries).erase(key); 137 bChanged = true; 141 138 } 142 139 } … … 151 148 (*entries).clear(); 152 149 sections.erase(iterSect); 150 bChanged = true; 153 151 } 154 152 } … … 214 212 } 215 213 216 void IniFile:: Flush()214 void IniFile::Store() 217 215 { 218 216 FILE *filIni = VSIFOpenL(filename.c_str(), "w+"); … … 263 261 return string(); 264 262 265 IniFile MyIniFile; 266 MyIniFile = IniFile(); 267 MyIniFile.Open(filename); 268 269 string ret = MyIniFile.GetKeyValue(section, entry); 270 271 MyIniFile.Close(); 272 273 return ret; 263 IniFile MyIniFile (filename); 264 265 return MyIniFile.GetKeyValue(section, entry);; 274 266 } 275 267 … … 280 272 return false; 281 273 282 IniFile MyIniFile; 283 MyIniFile = IniFile(); 284 MyIniFile.Open(fn); 274 IniFile MyIniFile (fn); 285 275 286 276 MyIniFile.SetKeyValue(sSection, sEntry, sValue); 287 MyIniFile.Close();288 277 return true; 289 278 } trunk/gdal/frmts/ilwis/ilwisdataset.h
r13694 r13697 192 192 { 193 193 public: 194 bool operator() (const string&, const string&) const;194 bool operator() (const string&, const string&) const; 195 195 }; 196 196 … … 201 201 { 202 202 public: 203 IniFile(); 204 virtual ~IniFile(); 205 206 void Open(const string& filename); 207 void Close(); 208 209 void SetKeyValue(const string& section, const string& key, const string& value); 210 string GetKeyValue(const string& section, const string& key); 211 212 void RemoveKeyValue(const string& section, const string& key); 213 void RemoveSection(const string& section); 203 IniFile(const string& filename); 204 virtual ~IniFile(); 205 206 void SetKeyValue(const string& section, const string& key, const string& value); 207 string GetKeyValue(const string& section, const string& key); 208 209 void RemoveKeyValue(const string& section, const string& key); 210 void RemoveSection(const string& section); 214 211 215 212 private: 216 string filename; 217 Sections sections; 218 219 void Load(); 220 void Flush(); 221 }; 222 223 213 string filename; 214 Sections sections; 215 bool bChanged; 216 217 void Load(); 218 void Store(); 219 }; 220 221
