mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 00:15:30 +00:00
o Properly react to end-of-file is loadFromStream()
o Add types SectionList and SectionKeyList o Implement getKeys() method svn-id: r21114
This commit is contained in:
parent
44f3879f58
commit
4c16b73bd1
@ -165,7 +165,7 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) {
|
||||
if (!section.name.isEmpty())
|
||||
_sections.push_back(section);
|
||||
|
||||
return !stream.ioFailed();
|
||||
return (!stream.ioFailed() || stream.eos());
|
||||
}
|
||||
|
||||
bool ConfigFile::saveToFile(const String &filename) {
|
||||
@ -295,6 +295,12 @@ void ConfigFile::setKey(const String &key, const String §ion, const String &
|
||||
}
|
||||
}
|
||||
|
||||
const ConfigFile::SectionKeyList ConfigFile::getKeys(const String §ion) const {
|
||||
const Section *s = getSection(section);
|
||||
|
||||
return s->getKeys();
|
||||
}
|
||||
|
||||
ConfigFile::Section *ConfigFile::getSection(const String §ion) {
|
||||
for (List<Section>::iterator i = _sections.begin(); i != _sections.end(); ++i) {
|
||||
if (!scumm_stricmp(section.c_str(), i->name.c_str())) {
|
||||
|
@ -59,6 +59,8 @@ public:
|
||||
String comment;
|
||||
};
|
||||
|
||||
typedef List<KeyValue> SectionKeyList;
|
||||
|
||||
/** A section in a config file. I.e. corresponds to something like this:
|
||||
* [mySection]
|
||||
* key=value
|
||||
@ -75,8 +77,11 @@ public:
|
||||
const KeyValue* getKey(const String &key) const;
|
||||
void setKey(const String &key, const String &value);
|
||||
void removeKey(const String &key);
|
||||
const SectionKeyList getKeys() const { return keys; }
|
||||
};
|
||||
|
||||
typedef List<Section> SectionList;
|
||||
|
||||
public:
|
||||
ConfigFile();
|
||||
~ConfigFile();
|
||||
@ -108,12 +113,14 @@ public:
|
||||
void setKey(const String &key, const String §ion, const String &value);
|
||||
void removeKey(const String &key, const String §ion);
|
||||
|
||||
const SectionList getSections() const { return _sections; }
|
||||
const SectionKeyList getKeys(const String §ion) const;
|
||||
|
||||
void listSections(StringSet &set);
|
||||
void listKeyValues(StringMap &kv);
|
||||
|
||||
private:
|
||||
List<Section> _sections;
|
||||
SectionList _sections;
|
||||
|
||||
Section *getSection(const String §ion);
|
||||
const Section *getSection(const String §ion) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user