[Scummvm-cvs-logs] CVS: scummvm/common config-file.cpp,1.20,1.21 config-file.h,1.12,1.13
Max Horn
fingolfin at users.sourceforge.net
Sat Apr 23 15:29:00 CEST 2005
Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24375
Modified Files:
config-file.cpp config-file.h
Log Message:
Implement some missing methods
Index: config-file.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/config-file.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- config-file.cpp 23 Apr 2005 14:30:53 -0000 1.20
+++ config-file.cpp 23 Apr 2005 22:28:36 -0000 1.21
@@ -276,14 +276,7 @@
_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 @@
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
Index: config-file.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/config-file.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- config-file.h 23 Apr 2005 14:30:53 -0000 1.12
+++ config-file.h 23 Apr 2005 22:28:37 -0000 1.13
@@ -71,7 +71,7 @@
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);
};
More information about the Scummvm-git-logs
mailing list