aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2005-04-23 22:28:37 +0000
committerMax Horn2005-04-23 22:28:37 +0000
commita6b59c0be1514fd1a9c716f9f6995b80cef7eeb2 (patch)
tree6efc390b199c39506a46060b24f1ceb6027ff805 /common
parent55947fb319edfac1563152968b97a24295f95248 (diff)
downloadscummvm-rg350-a6b59c0be1514fd1a9c716f9f6995b80cef7eeb2.tar.gz
scummvm-rg350-a6b59c0be1514fd1a9c716f9f6995b80cef7eeb2.tar.bz2
scummvm-rg350-a6b59c0be1514fd1a9c716f9f6995b80cef7eeb2.zip
Implement some missing methods
svn-id: r17780
Diffstat (limited to 'common')
-rw-r--r--common/config-file.cpp45
-rw-r--r--common/config-file.h2
2 files changed, 38 insertions, 9 deletions
diff --git a/common/config-file.cpp b/common/config-file.cpp
index f96a4dd2ce..f8d31b783b 100644
--- a/common/config-file.cpp
+++ b/common/config-file.cpp
@@ -276,14 +276,7 @@ void ConfigFile::setKey(const String &key, const String &section, const String &
_sections.push_back(newSection);
} else {
- KeyValue *kv = s->getKey(key);
- if (!kv) {
- KeyValue newKV;
- newKV.key = key;
- newKV.value = value;
- s->keys.push_back(newKV);
- } else
- kv->value = value;
+ s->setKey(key, value);
}
}
@@ -305,4 +298,40 @@ const ConfigFile::Section *ConfigFile::getSection(const String &section) const {
return 0;
}
+bool ConfigFile::Section::hasKey(const String &key) const {
+ return getKey(key) != 0;
+}
+
+const ConfigFile::KeyValue* ConfigFile::Section::getKey(const String &key) const {
+ for (List<KeyValue>::const_iterator i = keys.begin(); i != keys.end(); ++i) {
+ if (scumm_stricmp(key.c_str(), i->key.c_str())) {
+ return &(*i);
+ }
+ }
+ return 0;
+}
+
+void ConfigFile::Section::setKey(const String &key, const String &value) {
+ for (List<KeyValue>::iterator i = keys.begin(); i != keys.end(); ++i) {
+ if (scumm_stricmp(key.c_str(), i->key.c_str())) {
+ i->value = value;
+ return;
+ }
+ }
+
+ KeyValue newKV;
+ newKV.key = key;
+ newKV.value = value;
+ keys.push_back(newKV);
+}
+
+void ConfigFile::Section::removeKey(const String &key) {
+ for (List<KeyValue>::iterator i = keys.begin(); i != keys.end(); ++i) {
+ if (scumm_stricmp(key.c_str(), i->key.c_str())) {
+ keys.erase(i);
+ return;
+ }
+ }
+}
+
} // End of namespace Common
diff --git a/common/config-file.h b/common/config-file.h
index efea9f2ace..000e8ea437 100644
--- a/common/config-file.h
+++ b/common/config-file.h
@@ -71,7 +71,7 @@ public:
String comment;
bool hasKey(const String &key) const;
- KeyValue* getKey(const String &key) const;
+ const KeyValue* getKey(const String &key) const;
void setKey(const String &key, const String &value);
void removeKey(const String &key);
};