[Scummvm-cvs-logs] SF.net SVN: scummvm: [21114] scummvm/trunk/common
sev at users.sourceforge.net
sev at users.sourceforge.net
Mon Mar 6 18:25:01 CET 2006
Revision: 21114
Author: sev
Date: 2006-03-06 18:23:37 -0800 (Mon, 06 Mar 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=21114&view=rev
Log Message:
-----------
o Properly react to end-of-file is loadFromStream()
o Add types SectionList and SectionKeyList
o Implement getKeys() method
Modified Paths:
--------------
scummvm/trunk/common/config-file.cpp
scummvm/trunk/common/config-file.h
Modified: scummvm/trunk/common/config-file.cpp
===================================================================
--- scummvm/trunk/common/config-file.cpp 2006-03-06 20:22:14 UTC (rev 21113)
+++ scummvm/trunk/common/config-file.cpp 2006-03-07 02:23:37 UTC (rev 21114)
@@ -165,7 +165,7 @@
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 @@
}
}
+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())) {
Modified: scummvm/trunk/common/config-file.h
===================================================================
--- scummvm/trunk/common/config-file.h 2006-03-06 20:22:14 UTC (rev 21113)
+++ scummvm/trunk/common/config-file.h 2006-03-07 02:23:37 UTC (rev 21114)
@@ -59,6 +59,8 @@
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 @@
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 @@
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;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list